AnsweredAssumed Answered

Saving individual sheets as .dxf w/sheet name

Question asked by Chris Iozzi on Jan 23, 2020
Latest reply on Jan 31, 2020 by Deepak Gupta

I have tried every .dxf macro I could come up with, and my process is to name all my sheets the file (part name) and make a single .dxf of each sheet.  I keep getting (4) copies of the .dxf of each sheet for some reason and I have no clue how to control this....The macro also puts a "00" in front of all the file names.

 

I am using Deepak's code here

 

Sub main()

 

Dim swApp                   As SldWorks.SldWorks

Dim swModel                 As SldWorks.ModelDoc2

Dim swDraw                  As SldWorks.DrawingDoc

Dim swSheet                 As SldWorks.Sheet

Dim vSheetNameArr           As Variant

Dim vSheetName              As Variant

Dim bRet                    As Boolean

Dim swExportPDFData         As SldWorks.ExportPdfData

Dim lErrors                 As Long

Dim lWarnings               As Long

 

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

 

' Is document active?

 

If swModel Is Nothing Then

 

    swApp.SendMsgToUser2 "A Drawing document must be active.", swMbWarning, swMbOk

 

    Exit Sub

 

End If

 

 

' Is it a Drawing document?

 

If swModel.GetType <> swDocDRAWING Then

 

    swApp.SendMsgToUser2 "A Drawing document must be active.", swMbWarning, swMbOk

 

    Exit Sub

 

End If

 

 

Set swDraw = swModel

Set swSheet = swDraw.GetCurrentSheet

 

vSheetNameArr = swDraw.GetSheetNames

For Each vSheetName In vSheetNameArr

 

bRet = swDraw.ActivateSheet(vSheetName): Debug.Assert bRet

 

swDraw.ViewZoomtofit2

 

Set swExportPDFData = swApp.GetExportFileData(1)

swExportPDFData.SetSheets swExportData_ExportSpecifiedSheets, vSheetName

swModel.Extension.SaveAs vSheetName + ".dxf", 0, 0, swExportPDFData, lErrors, lWarnings

 

Next vSheetName

 

End Sub

Outcomes