A Design Table will work.
Yes, it is possibility, but it will be easier and fast set configiration manually.
I don't want create all configuration. I want set configuration for parts in assembly.
You can use a design table within the assembly to do that. You are right, sometimes it is easier to do it manually.
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.
It sounds difficult. Thanks for your idea. I will try find some solution.