Change custom properties for multiple model configurations

This is the default snippet code example that I use for changing custom properties:

For Each config_name In config_names
    
    swModel.ShowConfiguration2 config_name

    Set swCustomPropMgr = swModel.Extension.CustomPropertyManager(config_name)
        
    swCustomPropMgr.Add3 "MyCustomFieldName", swCustomInfoText, "CustomValue", swCustomPropertyDeleteAndAdd
    
    swModel.Extension.EditRebuildAll
Next

That’s the point: the model only updates the custom property if the configuration is activated (ModelDoc2::ShowConfiguration2). Time consumption is main issue right now.

Is there any faster method (macro running time)?

I copied your code and am running it without the ShowConfiguration2 line and without the EditRebuildAll line and it updates all configurations including inactive ones whether the property already exists or not. I'm not sure what to recommend without more info.

3 Answers

3

Works OK for me as well. Can you record/share a video showing the issue?

Forgot to mention this issue is about assembly models.

@BigCrazyAl , @Gupta9665

Please retest the code.

I am getting the same result. All configurations update without any need to activate the configuration.

Works OK for both part and assembly files.

To debug, kindly share the complete macro and the model files having the issue.