AnsweredAssumed Answered

Save As Part Number

Question asked by Dave Robinson on Mar 30, 2012
Latest reply on Apr 2, 2012 by Keith Rice

I'm back again for more awkward API related questions....


After solving my problem yesterday of combinign properties to generate a part number i'd now like to make it simple for us to save as the part number automatically/using a macro.


I've seen on a few other threads the use of this Macro (from Felipe!)


Sub main()

Dim swApp As SldWorks.SldWorks

Dim SWmoddoc As SldWorks.ModelDoc2

Dim partnumber As String

Set swApp = Application.SldWorks

Set SWmoddoc = swApp.ActiveDoc

'Use this....To Get the value from the Properties in the CUSTOM tab

partnumber = SWmoddoc.CustomInfo("Number")

'Or this....To Get the value from the Configuration Specific Tab

'partnumber = SWmoddoc.GetCustomInfoValue("Default", "Number")

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 + partnumber + ".sldprt")

End If

End Sub



Now i'm trying this but not a lot is happening when I change:


partnumber = SWmoddoc.CustomInfo("Number")




partnumber = SWmoddoc.CustomInfo("Part Number")   [my custom property field = $PRP:"Model Number"-$PRP:"Zone Ref"-$PRP:"Sequential Number"]


From what I can figure out is this trying to read the inputted value rather than the evaluated value and thus is falling over due to the inputted value being a string of properties together...


Help and feedback always appreciated!!