×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Export FLAT Pattern with a name equal to an attribut

Export FLAT Pattern with a name equal to an attribut

Export FLAT Pattern with a name equal to an attribut

(OP)
Hi,

The below steps of the attached journal work well:

- Check for flat pattern => OK

- Check for existing attribut "DXF" => OK

I have 2 questions

1°) How to change the below line to export the flat pattern included in the part without giving the name ?

Dim flatPattern1 As NXOpen.Features.FlatPattern = CType(workPart.Features.FindObject("FLAT_PATTERN(13)"), NXOpen.Features.FlatPattern)

2°) How to create a dxf file with the name of the DXF attribut ?

Thanks in advance

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: Export FLAT Pattern with a name equal to an attribut

What version of NX?

One of your recent threads mentions NX 8.5, but the journal in this thread was recorded in NX 10.

www.nxjournaling.com

RE: Export FLAT Pattern with a name equal to an attribut

(OP)
Hi Cowski,

First of all I need a solution in NX8.5 but after in NX10

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: Export FLAT Pattern with a name equal to an attribut

(OP)
Hi Cowski,

I forgot to say that I prefer using file export dxf (with only included flat pattern) because export flat pattern doesn't respect original layers. (another thread)

Thanks in advance

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: Export FLAT Pattern with a name equal to an attribut

So your flat pattern is on the drawing sheet and you just need to export a dxf of the drawing sheet(s)?

www.nxjournaling.com

RE: Export FLAT Pattern with a name equal to an attribut

So your flat pattern is on the drawing sheet and you just need to export a dxf of the drawing sheet(s)?

www.nxjournaling.com

RE: Export FLAT Pattern with a name equal to an attribut

(OP)
Hi Cowski,

No, I need to export a dxf of the modeling flat pattern entities

I am not obliged to have a sheet and in the given example, I have no sheet.

In fact I tried during a NX session

1°)
Export Flat Pattern
==> the result in AUTOCAD is not good regarding to the layers (entities

2°)
Display Flat Pattern View
File Export DXF then I select the Flat Pattern entities
The result in AUTOCAD is OK (entities remain in layer 250 and 251 for some part)

I would like the same action (2°)) with a journal.

Thanks in advance

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

RE: Export FLAT Pattern with a name equal to an attribut

What is "DXF_Attribut", is it the desired output file's full path (such as "C:\output\somefile.dxf"), or does it hold the folder path that you want to export to (such as "C:\output\), or is it something else entirely?

You'll want to modify the code below to verify and make use of the "DXF_Attribut" variable; but I think the rest of the code does what you want.

CODE

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module2

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim workPart As Part = theSession.Parts.Work
    Dim lw As ListingWindow = theSession.ListingWindow


    Sub Main()

        ' Vérification de l'existence d'un flat pattern

        lw.Open()
        Dim dxfFile As String = workPart.FullPath.Replace(".prt", ".dxf")



        Dim myFlatPattern As Features.FlatPattern = GetFlatPattern()
        If IsNothing(myFlatPattern) Then
            lw.WriteLine("Fin du programme car la part ne contient pas de Flat Pattern")
            Exit Sub
        End If

        Dim DXF_Attribut As String = ""

        'retrieve DXF attribute
        Try
            DXF_Attribut = workPart.GetStringUserAttribute("DXF", -1)
        Catch ex As Exception
            While DXF_Attribut = ""
                DXF_Attribut = InputBox("Enter DXF Attribut", "DXF_Attribut", "")
            End While
            workPart.SetUserAttribute("DXF", -1, DXF_Attribut, Update.Option.Now)
        End Try

        'code to verify DXF_Attribut is a valid folder/file path, create folder if needed

        'export flat pattern to dxf
        'lw.WriteLine("exporting dxf to: " & dxfFile)
        ExportDxf(myFlatPattern, dxfFile)

        lw.Close()

    End Sub

    Function GetFlatPattern() As Features.FlatPattern

        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return Nothing
        End If

        For Each myFeature As Features.Feature In workPart.Features
            If TypeOf (myFeature) Is Features.FlatPattern Then
                Return myFeature
            End If
        Next

        'if we make it here, no flat pattern was found
        Return Nothing

    End Function

    Sub ExportDxf(ByVal theFlatPattern As Features.FlatPattern, ByVal outputFile As String)


        Dim myFlatPatternBuilder As Features.SheetMetal.FlatPatternBuilder = workPart.Features.SheetmetalManager.CreateFlatPatternBuilder(theFlatPattern)
        Dim flatPatternViewName As String = myFlatPatternBuilder.FlatPatternViewName
        'lw.WriteLine("flat pattern view name: " & flatPatternViewName)
        myFlatPatternBuilder.Destroy()

        Dim dxfdwgCreator1 As DxfdwgCreator
        dxfdwgCreator1 = theSession.DexManager.CreateDxfdwgCreator()

        With dxfdwgCreator1
            .ExportData = DxfdwgCreator.ExportDataOption.Modeling
            .ViewEditMode = True
            .InputFile = workPart.FullPath
            .OutputFile = outputFile
            .ObjectTypes.Curves = True
            .ObjectTypes.Annotations = True
            .ObjectTypes.Structures = True
            .AutoCADRevision = DxfdwgCreator.AutoCADRevisionOptions.R2010
            .FlattenAssembly = False
            .WidthFactorMode = DxfdwgCreator.WidthfactorMethodOptions.AutomaticCalculation
            .LayerMask = "*"
            .ViewList = flatPatternViewName

        End With

        Dim nXObject2 As NXObject
        nXObject2 = dxfdwgCreator1.Commit()

        dxfdwgCreator1.Destroy()


    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module 

www.nxjournaling.com

RE: Export FLAT Pattern with a name equal to an attribut

(OP)
Thanks a lot cowski,

I succeed by adding the following lines:

'code to verify DXF_Attribut is a valid folder/file path, create folder if needed

Dim dxfFile As String = "c:\temp\" + DXF_Attribut + ".dxf"

The result is perfect

Now, I have just to go through all part in assembly.

Regards
Didier Psaltopoulos
http://www.psi-cad.fr

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources