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")
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
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,