Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What I'm trying to do is detect if a Sweep exists - any sweep, not just a specific name (that part works) and then run an iLogic rule if it does. But when I convert to a string to do Feature.IsActive(), then it gives me a "Unable to cast COM object" error.
'Ref the part
Dim oDoc As Inventor.Document oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition
'Find the sweep, reguardless of name, and ref it Dim oSweep As SweepFeature oSweep = oDef.Features.SweepFeatures.Item(1)
'This line is throwing the error, because it doesn't like being a string If Feature.IsActive(oSweep) Then iLogicVb.RunRule("CalcSweep") Else 'Do something End If
Unable to cast COM object of type 'System.__ComObject' to class type 'System.String'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
How can I make this work?
Solved! Go to Solution.