How is the macro supposed to know what component needs its configuration changed? Is it the first component in the assembly? Is it the largest? Is it the one with a certain name? Before a macro can run correctly, certain preconditions need to be present. Hence you need to determine what those preconditions are before any macro can be written.
Is it possible to apply the current configuration of parts in the current assembly to all the configurations of the assembly…something like the “apply to all” when setting configs.
1. For each config in the assembly (IModelDoc2::GetConfigurationNames)
1. Activate it (IModelDoc2::ShowConfiguration2)
2. For each component in the assembly (IAssemblyDoc::GetComponents)
1.Set the desired configuration name (IComponent2::ReferencedConfiguration)
Ready to start learning the SolidWorks API? Sign up for FREE membership here.Keep up with new videos, macros, and training events by joining our mailing list:
How do you change the configuration of a specific part purely by code, not by having the user select the part first?
How is the macro supposed to know what component needs its configuration changed? Is it the first component in the assembly? Is it the largest? Is it the one with a certain name? Before a macro can run correctly, certain preconditions need to be present. Hence you need to determine what those preconditions are before any macro can be written.
Is it possible to apply the current configuration of parts in the current assembly to all the configurations of the assembly…something like the “apply to all” when setting configs.
You could do this:
1. For each config in the assembly (IModelDoc2::GetConfigurationNames)
1. Activate it (IModelDoc2::ShowConfiguration2)
2. For each component in the assembly (IAssemblyDoc::GetComponents)
1.Set the desired configuration name (IComponent2::ReferencedConfiguration)