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
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
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
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
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
it will export dxf files from NX 8.5.
www.nxjournaling.com
RE: Export FLAT Pattern with a name equal to an attribut
www.nxjournaling.com
RE: Export FLAT Pattern with a name equal to an attribut
Thanks a lot. This code could be OK but the original layers are not respected. Have a look at the given example
Regards
Didier Psaltopoulos
http://www.psi-cad.fr
RE: Export FLAT Pattern with a name equal to an attribut
www.nxjournaling.com
RE: Export FLAT Pattern with a name equal to an attribut
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
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 Modulewww.nxjournaling.com
RE: Export FLAT Pattern with a name equal to an attribut
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