Virtual Component

Virtual Component

Anonymous
Not applicable
371 Views
2 Replies
Message 1 of 3

Virtual Component

Anonymous
Not applicable
I have made a custom dialog for placing new components.
I struggle with the creation of Virtual Components.
My code for creating "regular" components works fine, but after selecting Virtual and clicking OK I get the standard Insert Component dialog.

I do this:
------------------------------------------------------------
HandlingCode = Inventor.HandlingCodeEnum.kEventCanceled
Dim virtComp As Inventor.VirtualComponentDefinition
Dim VirtPos As Inventor.Matrix
VirtPos = oApp.TransientGeometry.CreateMatrix
virtComp = DocumentObject.ComponentDefinition.Occurrences.AddVirtual(NrGenOccName, VirtPos)
-------------------------------------------------------------
When stepping throug the code, I get an error on the last line saying: "Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.VirtualComponentDefinition'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D4652AC1-D4B9-4D65-8C2B-942D74411B1C}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

THe Virtual Component is created, but as I said, I get the standard dialog from Inventor for inserting components, as if I returned kEventNotHandeled as HandlingCode...

Does anybody have an idea what is wrong?
0 Likes
372 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
The AddVirtual method returns a ComponentOccurrence. And you are attempting
to cast it to a VirtualComponentDefinition. Declaring virtComp as
ComponentOccurrence should make this run fine.

Sanjay-

wrote in message news:5643765@discussion.autodesk.com...
I have made a custom dialog for placing new components.
I struggle with the creation of Virtual Components.
My code for creating "regular" components works fine, but after selecting
Virtual and clicking OK I get the standard Insert Component dialog.

I do this:
------------------------------------------------------------
HandlingCode = Inventor.HandlingCodeEnum.kEventCanceled
Dim virtComp As Inventor.VirtualComponentDefinition
Dim VirtPos As Inventor.Matrix
VirtPos = oApp.TransientGeometry.CreateMatrix
virtComp =
DocumentObject.ComponentDefinition.Occurrences.AddVirtual(NrGenOccName,
VirtPos)
-------------------------------------------------------------
When stepping throug the code, I get an error on the last line saying:
"Unable to cast COM object of type 'System.__ComObject' to interface type
'Inventor.VirtualComponentDefinition'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{D4652AC1-D4B9-4D65-8C2B-942D74411B1C}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."

THe Virtual Component is created, but as I said, I get the standard dialog
from Inventor for inserting components, as if I returned kEventNotHandeled
as HandlingCode...

Does anybody have an idea what is wrong?
Message 3 of 3

Anonymous
Not applicable
Yes of course, I saw that right after posting the question.
Thanks for the answer anyway.

-Ronny-
0 Likes