Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ComponentOccurrenceProxy Type Mismatch error.

1 REPLY 1
Reply
Message 1 of 2
herrwolf1
459 Views, 1 Reply

ComponentOccurrenceProxy Type Mismatch error.

 

Hello,
In the following code, the 'For' loop crashes. It throws a type mismatch error. I change the drawing LOD and view representations to the different options, all to no avail. Can someone point me in the right direction?

' Set a reference to the currently active drawing document. Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' Get the active sheet.
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

' Get the selected view.
Dim oDrawView As Inventor.DrawingView
oDrawView = oDrawDoc.ActiveSheet.DrawingViews.Item(1)

' Get the assembly shown in the view.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = oDrawView.ReferencedDocumentDescriptor.ReferencedDocument

' Get the component defenition
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition

' Get all of the leaf occurrences of the assembly.
Dim oLeafOccs As ComponentOccurrencesEnumerator
oLeafOccs = oAsmCompDef.Occurrences.AllLeafOccurrences

Dim oOccProxy As ComponentOccurrenceProxy
For Each oOccProxy In oLeafOccs
' Work goes here.
Next

 

 

1 REPLY 1
Message 2 of 2
ekinsb
in reply to: herrwolf1

The occurrences return by the AllLeafOccurrences property might not all be proxies.  If you have any parts placed in the top assembly those will be standard occurrences, not proxies.  Just change the variable type from ComponentOccurrenceProxy to ComponentOccurrence.  Since ComponentOccurrenceProxy is derived from ComponentOccurrence it will correctly handle both standard occurrences and proxies.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report