trying to write a macro to read the current configuration custom properties, and save-as a combination of these properties. I have it working fine for the "default" config. but can't get it to work with the current config.
I think it is a simple as setting the "cfg" variable to the current. But I am not getting what is wrong with the ways I have tried.
Dim swApp As Object
Sub main()
Dim swApp As SldWorks.SldWorks
Dim SWmoddoc As SldWorks.ModelDoc2
Dim config As SldWorks.Configuration
Dim cfg As String
Dim cusPropMgr As SldWorks.CustomPropertyManager
'used to combine together custom prop.
Dim partnumber As String
Dim rev As String
Dim description As String
Dim newname As String
Dim swname As String
Set swApp = Application.SldWorks
Set SWmoddoc = swApp.ActiveDoc
Set config = SWmoddoc.GetActiveConfiguration
Set cusPropMgr = config.CustomPropertyManager
cfg = "default"
partnumber = SWmoddoc.GetCustomInfoValue(cfg, "partno")
rev = SWmoddoc.GetCustomInfoValue(cfg, "Rev")
description = SWmoddoc.GetCustomInfoValue(cfg, "description")
newname = partnumber + "-r" + rev + "-" + description
swname = partnumber + "-" + description
PathName = SWmoddoc.GetPathName 'this gets the full path of the current open document (including filename)
FilePath = Left(PathName, InStrRev(PathName, "\")) 'uses to full pathname to get the folder path, to be added to the save as file name
If (SWmoddoc.GetType = swDocASSEMBLY) Then
SWmoddoc.SaveAs (FilePath + partnumber + ".sldasm")
ElseIf (SWmoddoc.GetType = swDocPART) Then
SWmoddoc.SaveAs (FilePath + swname + ".sldprt")
SWmoddoc.SaveAs (FilePath + newname + ".step")
End If
End Sub
thank you very much for any suggestions
Robert
SolidworksApi macros