ilogic rule - dxf export - layers

ilogic rule - dxf export - layers

aurel_e
Collaborator Collaborator
700 Views
2 Replies
Message 1 of 3

ilogic rule - dxf export - layers

aurel_e
Collaborator
Collaborator

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
0 Likes
701 Views
2 Replies
Replies (2)
Message 2 of 3

dutt.thakar
Collaborator
Collaborator

@aurel_e 

 

Can you check out this link and see if that helps?

 

http://www.hjalte.nl/18-setting-extra-layers-in-dxf-exports

 

 

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 3

aurel_e
Collaborator
Collaborator

Thanks @dutt.thakar 

Yes I have seen that JelteDeJong post. It looks to me another situation though. Or I don't know how to adapt that to my case. That exports the dxf from the ipt and you can choose different layers for different edges.

My Ilogic is exporting all dxfs from the assembly level. I could save 2 different versions of the code (ie one that exports the bend lines and the other that exports just the contours) but I wanted something better...

The best solution I have found is adding this line

 

ExpSettingQuestion = MessageBox.Show("Do you want to export Bend Lines?", "DXF Export Settings", MessageBoxButtons.YesNo)

 

and jumping to different parts of the code according to the answer.

0 Likes