oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oFolder = oPath & "\" & "DXF" 'Check for the DXF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oCompDef As SheetMetalComponentDefinition oCompDef = oDoc.ComponentDefinition 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_PROFILE&Interi​orProfilesLayer=IV_INTERIOR_PROFILES&InvisibleLayers=IV_FEATURE_PROFILES_DOWN;IV_TANGENT;IV_BEND;IV_BEND_DOWN;I V_FEATURE_PROFILES;IV_FEATURE_PROFILES&OuterProfileLayerColor=255,0,0" Dim sFname As String sFname =oFolder & "\" & oFileName & ".dxf" oCompDef.DataIO.WriteDataToFile( sOut, sFname) oDoc = ThisApplication.ActiveDocument Dim oSMDef As SheetMetalComponentDefinition oSMDef = oDoc.ComponentDefinition oSMDef.FlatPattern.ExitEdit ' End Sub