Message 1 of 6
Instantiating SubOccurances

Not applicable
07-30-2011
03:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
Perhaps I've been looking at this for too long, but I can't figure out why I can't get a reference to a subOccurance by name.
I have been trying to get a reference for the Sub-Assembly named 'Control R7' using the following:
'Set a reference to the active document. oInvAssyDoc = oInvApp.ActiveDocument 'Set a reference to an active assembly component definition. oInvAssyCompDef = oInvAssyDoc.ComponentDefinition 'Set a reference to the occurances in the component definition. oInvAssyCompOccs = oInvAssyCompDef.Occurrences 'Create a reference to the 'Markers' ComponentOccurance. Dim location_markers_left_occ As Inventor.ComponentOccurrence = oInvAssyCompOccs.ItemByName("Location Markers Left") ' Get a reference to the Location Markers Left Component Occurances. Dim lm_left_sub_occs As Inventor.ComponentOccurrences = location_markers_left_occ.SubOccurrences ' Get a reference to the occurance named 'Control R7' Dim control_left As Inventor.ComponentOccurrence = lm_left_sub_occs.ItemByName("Control R7")
This does not work.
However if I loop through the occurances in lm_left_sub_occs I can set control_left as follows:
For Each comp_occ As Inventor.ComponentOccurrence In lm_left_sub_occs If comp_occ.Name = ("Control R7") Then Console.WriteLine("Control R7 is here!") control_left = comp_occ End If Next
Can anyone please explain why I can't access the occurance by name.
Regards
Chris