5 Replies Latest reply on Mar 7, 2017 4:01 PM by Filip Vymola

    How to set configuration for parts in assembly?

    Filip Vymola



      I've got part with 3 configuration - we can call it as PartA. PartA has got 3 configuration - PartA-1, PartA-2, PartA-3. I've got assembly as well. We can call it as AssyABC. AssyABC has got 3 configuration - AssyABC-1, AssyABC-2, AssyABC-3.


      I need set part and assembly configuration as you see below:




                PartA with configuration PartA-1


                 PartA with configuration PartA-2


                PartA with configuration PartA-3


      Is it possible create this via macro? Configuration for parts and assemblies I created via macro. Unfortunately I don't know how get started. The configuration name for assy and parts is the same.

        • Re: How to set configuration for parts in assembly?
          Keith Carter


          A Design Table will work.

          • Re: How to set configuration for parts in assembly?
            Nilesh Patel

            Hi Filip,


            As Keith Carter mentioned design would be best option but if would like to do it through a macro then, you could follow these steps:


            1. Get the configuration list of your final assembly using IModelDoc2.GetConfigurationNames which will return the array of names of assembly configurations.

            2. Run a loop for each configuration and follow these steps:

                      a. Activate the configuration using IModelDoc.ShowConfiguration2 method

                      b. Get the list of top level components for the active configuration using IAssemblyDoc.GetComponents which will return an array for components.

                      c. Run the loop through each component and follow these steps:

                                i. Get the IModelDoc2 object for the component using IComponent2.GetModelDoc2. This IModelDoc2 oject is for component which is different that IModelDoc2 ojbect obtained in step 1.

                                ii. Get the configuration names of the component using IModelDoc2.GetConfigurationNames and run the loop through each configuration

                                          X. Compare the name of the component configuration to assembly configuration and if they match, set the component configuration using IComponent2.ReferencedConfiguration = "Component Configuration Name".

                                          XX. Rebuilt the assembly using IModelDoc2.EditReebuilt (This IModelDoc2 object is the one obtained in step 1)

            3. Save the final assembly using IModelDoc2.Save (This IModelDoc2 object is the one obtained in step 1)


            I have not tried these codes but it should work. It will change the configuration of top level component only. Similar to what design table would do. If your final assembly contains sub assemblies and if you want to change its component configuration too, then it will become more complicated.


            Give it a try and let us know how you go. If you stuck then post your codes and someone will guide you.