I have successfully modified another macro to save a part as a STL file, I just need to add one more function to it: save all the configurations of the part with the naming convention - "filename" - "Configuration name".STL in the same folder as the open part.
I saw this thread:
Not sure if I can just cut and paste that section into my code or not, without knowing exactly what each step is doing.
My code so far is:
Dim swApp As SldWorks.SldWorks 'Solidworks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swExportData As SldWorks.ExportPdfData
Dim boolstatus As Boolean
Dim filename As String
Dim lErrors As Long
Dim lWarnings As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "No current document", vbCritical
If swModel.GetType <> swDocPART Then
MsgBox "This Macro only works on Parts", vbCritical
Set swModelDocExt = swModel.Extension
Set swExportData = swApp.GetExportFileData(swExportStlUnits)
filename = swModel.GetPathName
If filename = "" Then
MsgBox "Please save the file first and try again", vbCritical
filename = Strings.Left(filename, Len(filename) - 6) & "STL"
boolstatus = swModelDocExt.SaveAs(filename, 0, 0, swExportData, lErrors, lWarnings)
If boolstatus Then
MsgBox "Save as STL successful" & vbNewLine & filename
MsgBox "Save as STL failed, Error code:" & lErrors
Any help greatly appreciated.