Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
DWhiteley
291 Views, 1 Reply

Add compnent occurences crash.

This line crashes Inventor and I can't make out what the problem is, can anyone see why?  Thanks Dave

 

' Get the active assembly.

Dim oAsmDoc As AssemblyDocument

oAsmDoc = m_inventorApplication.ActiveDocument

' Get the assembly component definition.

Dim oAsmDef As AssemblyComponentDefinition

oAsmDef = oAsmDoc.ComponentDefinition

' Get all of the leaf occurrences of the assembly.

Dim oLeafOccs As ComponentOccurrencesEnumerator

oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences

' Iterate through the occurrences and print the name.

Dim oOcc As ComponentOccurrence '' tried Dim oOcc as Object as well

For Each oOcc In oLeafOccs

       'Debug.Print(oOcc.Name)

              Comps.Add(oOcc) ''' crashes INVENTOR (dim comps as Objectcollection ' I can't change this)

Next