How would I select all components and sub-components?

How would I select all components and sub-components?

i-make-robots
Advocate Advocate
983 Views
1 Reply
Message 1 of 2

How would I select all components and sub-components?

i-make-robots
Advocate
Advocate

I have an assembly with many components and sub-components.  I built a selection set of the ones I want to keep visible.  I want to invert selection and hide the rest.  Default "invert selection" doesn't seem to work, no matter what filter options I choose.  I'd like to write a script that does the invert I'm looking for (select all components at all levels of the document tree except those in the original selection set).  Is this straightforward?  In the API reference I see where everything is located in the hierarchy except sub-components. 

Thank you!

0 Likes
984 Views
1 Reply
Reply (1)
Message 2 of 2

MichaelT_123
Advisor
Advisor

 Hi Mr. I-Make-Robots,

 

Components can not be selected only occurrences can.

However, all design's components can be found.

The task you described is not difficult:

- find all occurrences in your design - occLst = rootComponent.allOccurrences 

- for tasks other then selection component list might be useful - compLast = design.allComponents

- iterate through occLst (or compLst) list excluding elements you do not want

- perform the action of your choice on the rest

 

Regards

MichaelT

MichaelT