Add compnent occurences crash.

Add compnent occurences crash.

DWhiteley
Advisor Advisor
306 Views
1 Reply
Message 1 of 2

Add compnent occurences crash.

DWhiteley
Advisor
Advisor

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

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

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

I cannot tell from the code you pasted if/how you initialize the "Comps" variable.

It should be something like

Comps = ThisApplication.TransientObjects.CreateObjectCollection()

Cheers, 



Adam Nagy
Autodesk Platform Services
0 Likes