Message 1 of 3
Virtual Component

Not applicable
06-29-2007
04:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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?
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?