DesignerGuy16
Mechanical
- Jun 18, 2008
- 303
This macro is to change the BOM options on all configurations to "User Specified Name" and set that name as a variable (custom property in the part). Trying to get this to work. Problem is the code only works if you have a configuration selected before starting the macro. If you have nothing selected, it will select the other configurations visibly, and change the setting on the active configuration. I've even tried using CurrentDoc.ShowConfiguration2 (ConfigName), it does change the active configuration, but will still only update the active configuration when the macro is ran.
James Spisich
Design Engineer, CSWP
Code:
Sub ConfigSetup()
Set swApp = CreateObject("SldWorks.Application")
Set CurrentDoc = swApp.ActiveDoc
Set SelMgr = CurrentDoc.SelectionManager
Set swConfMgr = CurrentDoc.ConfigurationManager
Set swConfig = swConfMgr.ActiveConfiguration
' Set Config Specific name to $PRP:"PartShtSize"$PRP:"PartBase"
PartNumber1 = "$PRP:" & """" & "PartShtSize" & """" & "$PRP:" & """" & "PartBase" & """"
ConfigCount = CurrentDoc.GetConfigurationCount
ConfigNames = CurrentDoc.GetConfigurationNames
For i = 0 To ConfigCount - 1
ConfigName = ConfigNames(i)
boolstatus = CurrentDoc.Extension.SelectByID2(ConfigName, "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
CurrentDoc.GetConfigurationByName (ConfigName)
swConfig.UseAlternateNameInBOM = True
swConfig.AlternateName = PartNumber1
Next i
End Sub
James Spisich
Design Engineer, CSWP