Save flat pattern as dxf with bend line and layers

Save flat pattern as dxf with bend line and layers

Anonymous
Not applicable
521 Views
1 Reply
Message 1 of 2

Save flat pattern as dxf with bend line and layers

Anonymous
Not applicable

I Have a code to export all sheet metal flat pattern from an assembly that was working good till new need companie,

i need to be able to customize layers and export bed line and or etched line. it look like i'm near to make work, but i can not figure what i'm missing here. Need Help! Here's

Sub Main()
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)

Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document

For Each oRefDoc In oRefDocs
SMPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) -4) & ".ipt"
Dim FNamePos As Long
FNamePos = InStrRev(oRefDoc.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(oRefDoc.FullFileName, Len(oRefDoc.FullFileName) -FNamePos)

If oRefDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
			oRefDoc = ThisApplication.Documents.Open(SMPathName, True)
	
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oRefDoc.ComponentDefinition
		
		oCompDef.FlatPattern.Edit

       If oCompDef.HasFlatPattern = False Then
                    oCompDef.Unfold()
                Else
                    oCompDef.FlatPattern.Edit()
                End If
				
                Dim sOut As String
                sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PR?OFILE"
	 	  
		  	oCompDef.DataIO.WriteDataToFile(sOut,docFName)
                
            oCompDef.FlatPattern.ExitEdit()
	  
		
oPath = ThisDoc.Path	

Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
	oMat = iProperties.Material(docFName)
	oThickness = iProperties.Value(docFName, "Custom","G_T")
	
	oDXFFolder = oPath  & "\Plasma-DXF\"  &"\" & oMat &"\"& oThickness &"\"
	
	oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) -4) & ".dxf"
	
	oDXFName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) -4) & ".dxf"
	
	
	oDXFFolder2 = oPath & "\Plasma-DXF\"

	If Not System.IO.Directory.Exists(oDXFFolder) Then
    	System.IO.Directory.CreateDirectory(oDXFFolder)
	End If

oDataMedium.FileName = oDXFFolder & oFileName 
DefaultChoice = True
	
		
		Dim Cm As CommandManager = ThisApplication.CommandManager
		Cm.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent,oDataMedium.FileName)
		
                                     
          Dim oCDef As ControlDefinition 
		  'oCDef = Cm.ControlDefinitions.Item("GeomToDXFCommand")
          oCDef.Execute() 

		  		
	oDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartSwitchRepresentationCmd")
	oDef.Execute	
   
	oRefDoc.Close

End If
Next
'- - - - - - - - - - - - -
MessageBox.Show("New Files Created in: " & vbLf & oDXFFolder2, "iLogic")

Shell("explorer.exe " & oDXFFolder2,vbNormalFocus)

End Sub

de code

0 Likes
522 Views
1 Reply
Reply (1)
Message 2 of 2

johnsonshiue
Community Manager
Community Manager

Hi! Could you take a look at the following page and see if it helps?

 

https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-9F5075D3-00C5-47B3-8BF9-F97E8680B39E

 

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes