Which component traverse method should I use?

Hi folks,

What’s the difference between these methods: AssemblyDoc::GetComponents or Configuration::GetRootComponent3?

Configuration::GetRootComponent3 remarks: An IComponent2 object is based on the currently active configuration; one assembly configuration might suppress the component, while another might display it. Therefore, your traversal of IComponent2 objects might vary if you switch to a different configuration.

I have suppressed children components and both methods got it all.

I think these methods have different objectives:

GetComponents is for getting a flat list of all components in an assembly, with or without child components.

GetRootComponent3 allows you to traverse the component/assembly structure. You start at the top, then get the direct children from the root component, then you can go deeper.

1 Like

In my experience, I use Configuration.GetRootComponent3 when I need to switch configurations. I have had issues with the Component2 returned from AssemblyDoc not behaving correctly after switching configurations.

1 Like