Showing results for 
Search instead for 
Did you mean: 

Select part/sub-assembly in sub-assemblies




I have a list of Occurrence objects contains all the Occurrences in all levels of the assembly (just a flat tree of occurrences)

I want to Select (highlight) some occurrence from this list.

When the occurrence is at the top level it works with ActiveSelectSet.Add(OccurrenceList[x])

But when this is a part in sub assembly, or sub-sub assembly, or deeper, as i understand i have to use TopLevelAssembly.CreateReference(...), then i could add it to ActiveSelectSet.

I sew all the posts about it in the forum, but still no success/no understanding how can i get reference to SOME OCCURRENCE in some sub-sub-sub... assembly?

Or some other way to select/highlight it


Please help Smiley Happy



Re: Select part/sub-assembly in sub-assemblies

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Instead of storing the occurrence objects of each subassembly in the list, store either the Occurrence objects from the toplevel assembly and a SubOccurrence object for all deeper assembly levels. This allows you to easily access the Reference property of a SubOccurrence to use it in the highlight set or select set.


If you want to continue with the Occurrence objects in your list, then you have to create the references recursively bottom-up from the lowest level until the toplevel.

To create a reference to a part in a subassembly, you will call CreateReference on the toplevel assembly with the subassembly occurrence as the first argument and the occurrence object inside the subassembly as the second argument. For deeper levels, you will need to create then references to the previously created reference object.


BTW: If you have the same subassembly duplicated in your assembly, you won't be able to distinguish between two same subparts in your assembly with your flat list of occurrences approach, but with the suboccurrence objects you will.