In an assembly, I try to retrieve the "Part number displayed when used in a BOM:" value of the component I selected. I already get the name of the configuration of the selected component with the code below but I dry a little for the part number displayed in the nomenclature. Does anyone have the solution?
Dim swApp As SldWorks.SldWorks Sun swSelMgr As SldWorks.selectionMgr Dim swModel As SldWorks.ModelDoc Dim ConfigMgr As ConfigurationManager Dim Component As SldWorks.Component2
Sub main()
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swSelMgr = swModel.SelectionManager Set ConfigMgr = swModel.ConfigurationManager
'Select component Debug.Print "Selection Type = " & swSelMgr.GetSelectedObjectType2(1) Set Component = swSelMgr.GetSelectedObjectsComponent4(1, -1)
' Show Config1 and make it the active configuration Debug.Print "ConfigName SelectedComponent =" & Component.ReferencedConfiguration Debug.Print "ConfigName SelectedComponent = " & ConfigMgr.ActiveConfiguration.UseAlternateNameInBOM
Dim ActiveConfig As String Dim bRet As Boolean Dim ConfigMgr As ConfigurationManager Dim Component As SldWorks.Component2 Dim ParamConfigValue as Variant Dim swApp As SldWorks.SldWorks Sun swSelMgr As SldWorks.selectionMgr Dim swModel As SldWorks.ModelDoc
Sub main()
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swSelMgr = swModel.SelectionManager Set ConfigMgr = swModel.ConfigurationManager
' Active Configuration ID and Name Recovery 'IDconfig = swModel.ConfigurationManager.ActiveConfiguration.GetID ActiveConfig = swModel.ConfigurationManager.ActiveConfiguration.Name bRet = ConfigMgr.GetConfigurationParams(ActiveConfig, "PART $NUMERO", ParamConfigValue) 'Debug.Print' Config ID enabled on opening: " & IDconfig Debug.Print "Config name active on opening: " & ActiveConfig Debug.Print "Number used in BOMs: " & ParamConfigValue(1) 'ParamConfigValue 1 matches Part Number used in BOM
Dim ActiveConfig As String Dim bRet As Boolean Dim ConfigMgr As ConfigurationManager Dim Component As SldWorks.Component2 Dim ParamConfigValue as Variant Dim swApp As SldWorks.SldWorks Sun swSelMgr As SldWorks.selectionMgr Dim swModel As SldWorks.ModelDoc
Sub main()
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swSelMgr = swModel.SelectionManager Set ConfigMgr = swModel.ConfigurationManager
' Active Configuration ID and Name Recovery 'IDconfig = swModel.ConfigurationManager.ActiveConfiguration.GetID ActiveConfig = swModel.ConfigurationManager.ActiveConfiguration.Name bRet = ConfigMgr.GetConfigurationParams(ActiveConfig, "PART $NUMERO", ParamConfigValue) 'Debug.Print' Config ID enabled on opening: " & IDconfig Debug.Print "Config name active on opening: " & ActiveConfig Debug.Print "Number used in BOMs: " & ParamConfigValue(1) 'ParamConfigValue 1 matches Part Number used in BOM