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: 

Assign component occurrence to variable

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Moreon
349 Views, 2 Replies

Assign component occurrence to variable

 

Hi,

 

I'm trying with vb.net to assign a virtual component to a variable. The following code creates the virtual component "Assembly" if it doesn't exists :

 

Dim _asmCompDef As AssemblyComponentDefinition
_asmCompDef = _doc.ComponentDefinition

 

Dim identity As Matrix
identity = _invApp.TransientGeometry.CreateMatrix

 

Dim occs As ComponentOccurrence
occs = _asmCompDef.Occurrences.AddVirtual("Assembly", identity)

 

I don't know how to assign this virtual component to a variable.

This code creates an error :

 

Dim existingOcc As ComponentOccurrence
existingOcc = _asmCompDef.Occurrences.Item("Assembly")

 

 

 

 

 

 

2 REPLIES 2
Message 2 of 3
adam.nagy
in reply to: Moreon

Hi,

 

The best thing is always to test things in VBA. There you would have got a Type mismatch error that could have pointed you in the right direction.

Item() expects a Long input parameter. You could use ItemByName instead, but that as well will also need the occurrence counter too, i.e. "Assembly:1"

 

I hope this helps,



Adam Nagy
Autodesk Platform Services
Message 3 of 3
Moreon
in reply to: adam.nagy

Your advice has helped. Thanks alot.

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

Post to forums  

Autodesk Design & Make Report