Macro: Auto export DXF from flatten view

Hi Team,

I have a macro which will converts sheet metal to DXF.

Macro Process:

Sheet metal to Flatten and export to DXF and retract to UnFlatten,

Here I'm facing a error in  DXF file, After exporting from sheet metal part to dxf there is no view or drawing inside the DXF file it looks like empty sheet.

Can someone help me to find out the issues ?

Dim swApp As SldWorks.SldWorks

Dim Part As ModelDoc2

Dim swModel                 As SldWorks.ModelDoc2

Dim swPart                  As SldWorks.PartDoc

Dim sModelName              As String

Dim sPathName               As String

Dim varAlignment            As Variant

Dim dataAlignment(11)       As Double

Dim swSelMgr                As SldWorks.SelectionMgr

Dim swFace                  As SldWorks.Face2

Dim swFeat As SldWorks.Feature

Dim path As String

Dim folderpath As String

Dim boolstatus As Boolean

Private Sub CommandButton1_Click()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

'If part is not sheet metal quit

If Part.GetBendState = 0 Then Exit Sub

Dim Featnum As Long

Dim Feat As Feature

'Travers through the tree starting at the end.

For Featnum = 0 To Part.GetFeatureCount - 1 ' To 0 Step -1

    'Select each feature

    Set Feat = Part.FeatureByPositionReverse(Featnum)

    If Feat.GetTypeName2() = "FlatPattern" Then

        Feat.Select (False)

        Part.EditUnsuppress2

       Exit For

    End If

   

Next Featnum

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("Face1", "FACE", 0, 0, 0, False, 0, Nothing, 0)

'Get Path and file name of the flat pattern dxf

path = Part.GetPathName

path = Mid(path, 1, Len(path) - 7)

path = path & "-Flat.DXF"

'Create or update flat pattern DXF

boolstatus = Part.ExportFlatPatternView(path, 0)

    'Select each feature

    Set Feat = Part.FeatureByPositionReverse(Featnum)

    If Feat.GetTypeName2() = "FlatPattern" Then

        Feat.Select (False)

        Part.EditSuppress2

    End If

'Inform the user that the file has been created

MsgBox "Flat Pattern DXF Created"

End Sub

Regards,

Kishore

SolidworksApi macros