Hi @diego_dorta . Try this code:
Sub Main
Dim oDoc As Document = ThisApplication.ActiveDocument
If TypeOf oDoc Is PartDocument Then
Dim oPartDoc As PartDocument = oDoc
Dim sActiveMS As String = oPartDoc.ModelStateName
If TypeOf oPartDoc.ComponentDefinition Is SheetMetalComponentDefinition Then
Dim oPartDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
Dim sDirectName As String = System.IO.Path.GetDirectoryName(oDoc.FullDocumentName)
Dim sNameDoc As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullDocumentName)
Dim sPartNumb, sNameAndPath As String
'[Seting export DXF
Dim sSetDXF As String = "FLAT PATTERN DXF?AcadVersion=R12&RebaseGeometry=True&SimplifySpline=True&InteriorProfilesLayer=IV_INTERIOR_PROFILES&InvisibleLayers=IV_TANGENT;IV_BEND;IV_BEND_DOWN;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL&SplineToleranceDouble=0.01"
' Dim sSetDXF As String = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PROFILE"
']
For Each oMS As ModelState In oPartDef.ModelStates
oMS.Activate()
sPartNumb = oPartDoc.PropertySets("Design Tracking Properties")("Part Number").Value
sNameAndPath = sDirectName & "\" & sPartNumb & ".dxf"
Dim oDataIO As DataIO = oPartDef.DataIO
Call oDataIO.WriteDataToFile(sSetDXF, sNameAndPath)
Next
oPartDef.ModelStates.Item(sActiveMS).Activate()
Else
MessageBox.Show("Active document is not SheetMetalDocument!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Else
MessageBox.Show("Active document is not PartDocument!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub