Coder88, I’ll post this later on its own page but in the mean time this should do:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swExport As SldWorks.ExportPdfData
Dim vSheetNames As Variant
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
vSheetNames = swDraw.GetSheetNames
Set swExport = swApp.GetExportFileData(swExportPdfData)
swExport.SetSheets swExportData_ExportAllSheets, vSheetNames
swModel.Extension.SaveAs “C:\export.pdf”, swSaveAsCurrentVersion, swSaveAsCurrentVersion, _
swExport, Empty, Empty
End Sub
Currently i’m trying to create a macro to save the flat pattern dxf from the drawing level. The issue i’m having is opening the part after getting information from the drawing level. I’ve tried this example and many other but the file never opens. Below is my dim and open code
Ready to start learning the SolidWorks API? Sign up for FREE membership here.Keep up with new videos, macros, and training events by joining our mailing list:
Can you make a macro that will save a drawing as a pdf? The help tutorial isn’t helping me fix my problem.
Coder88, I’ll post this later on its own page but in the mean time this should do:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swExport As SldWorks.ExportPdfData
Dim vSheetNames As Variant
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
vSheetNames = swDraw.GetSheetNames
Set swExport = swApp.GetExportFileData(swExportPdfData)
swExport.SetSheets swExportData_ExportAllSheets, vSheetNames
swModel.Extension.SaveAs “C:\export.pdf”, swSaveAsCurrentVersion, swSaveAsCurrentVersion, _
swExport, Empty, Empty
End Sub
Currently i’m trying to create a macro to save the flat pattern dxf from the drawing level. The issue i’m having is opening the part after getting information from the drawing level. I’ve tried this example and many other but the file never opens. Below is my dim and open code
Dim swApp As SldWorks.SldWorks
Dim Name As String
Set swApp = Application.SldWorks
swApp.Visible = True
Name = Filepath & FileName & “.SLDPRT”
swApp.OpenDoc6 Name, swDocPART, swOpenDocOptions_Silent, “”, longstatus, longwarnings
I can upload the rest of the code if needed.
Any help would be appreciated,
I’ll send you an email about this. I need to see the full macro.