I'm writing some tests for an addin. After I make my changes to the document, I want to save the whole assembly. However, I don't want to change the original set of files, so I want to save the assembly heirarchy into a new directory. Through the UI, the save as command allows me to select the all the parts and save them to a new directory. Here's the macro that I wrote to do the same, but it only saves the main sldasm and nothing else.
Option ExplicitSub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim boolstatus As Boolean
Dim filename As String
Dim lErrors As Long
Dim lWarnings As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
filename = "C:\\Temp\\test.sldasm"
' filename = "C:\\Temp\\" ' Gives error
' filename = "C:\\Temp" ' Gives error
boolstatus = swModelDocExt.SaveAs(filename, swSaveAsCurrentVersion, swSaveAsOptions_SaveReferenced + swSaveAsOptions_Copy, _
Nothing, lErrors, lWarnings)
Debug.Print boolstatus, lErrors, lWarnings
End Sub
I also tried removing the _Copy option. No difference.
SolidworksApi macros
