Message 1 of 3
ilogic rule - dxf export - layers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I use the code below to export all the dxf flat pattern of the assembly.
I know how to change it manually to export different features, change colors and layers name, but I would like when I run the rule to be presented with a form where I could choose which features to export (mainly will be to make visible or not the Bend lines, Feature profiles ... etc.) what colors and layer names.
Is it possible?
Sub Main()
oPath = ThisDoc.Path
Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
Dim New_Folder_Path As String = oPath & "\" & "LASER"
My.Computer.FileSystem.CreateDirectory(New_Folder_Path)
Dim R_Part As String
For Each doc As Document In oAsmDoc.AllReferencedDocuments
If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Try
R_Part = doc.DisplayName
dXF_Path = New_Folder_Path
Try
My.Computer.FileSystem.CreateDirectory(dXF_Path)
Catch
End Try
Call Make_DXF(doc,oAsmDoc,dXF_Path)
Catch
End Try
InventorVb.DocumentUpdate()
iLogicVb.UpdateWhenDone = True
End If
Next
MsgBox("Done!",,"DXF Export")
End Sub
Sub Make_DXF(oDoc As Document,AsmDoc As Document, File_Location As String)
doc = ThisDoc.Document
Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition
Dim MyLOD_Name As String
MyLOD_Name = oAssyDef.RepresentationsManager.ActiveLevelOfDetailRepresentation.Name
If Not MyLOD_Name = "Master" Then
Call oAssyDef.RepresentationsManager.LevelOfDetailRepresentations.Item(1).Activate
End If
Dim oBOM As BOM = AsmDoc.ComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView = oBOM.BOMViews.Item("Parts Only")
For Each oBOMRow As BOMRow In oBOMView.BOMRows
Dim rDoc As Document = oBOMRow.ComponentDefinitions.Item(1).Document
If rDoc.DisplayName = oDoc.DisplayName Then
ThisApplication.Documents.Open(oDoc.FullFileName, False)
Dim Part_Name As String = oDoc.DisplayName.Replace(".ipt", "")
Dim oFilename As String = File_Location & "\" & Part_Name & ".dxf"
ThisApplication.SilentOperation = True
Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
oCompDef.FlatPattern.ExitEdit
End If
Dim optionList As List(Of String) = New List(Of String)()
optionList.Add("AcadVersion=2004")
optionList.Add("OuterProfileLayer=0")
optionList.Add("InteriorProfilesLayer=0")
optionList.Add("UnconsumedSketchesLayer=YELLOW")
optionList.add("UnconsumedSketchesLayerColor=255;255;0") 'here i make the UnconsumedSketchesLayer lines red!
optionList.add("") 'you can add other options here
optionList.add("") 'and more options
' if you want you can add more lines for more options
Dim sOut As String
sOut = "FLAT PATTERN DXF?AcadVersion=2000" _
+ "&InvisibleLayers=IV_TANGENT;IV_FEATURE_PROFILES;IV_ARC_CENTERS;IV_BEND;IV_BEND_DOWN;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_FEATURE_PROFILES_DOWN"
For Each opt In optionList
sOut = sOut & "&" & opt
Next
sOut = sOut & "?OFILE"
oCompDef.DataIO.WriteDataToFile(sOut, oFilename)
oCompDef.FlatPattern.ExitEdit
oDoc.Close
Exit For
End If
Next
End Sub