Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
llorden4
1527 Views, 10 Replies

Object type 'System.__ComObject' cannot be converted to 'Inventor.ComponentOccur

I'm baffled on this error, I've run into it before typically with Event Triggers that conflict with iLogic for some reason (such as run rule on file open).

 

I've added a New Rule to one of my template files and am now constantly getting this error run my other "tried and proven" rules is fired after an object has been installed.  What's baffling to me is that the rules run just fine (still) as-is in my previous file and is un-altered.  Suppressing the new rule does not make this error go away.  It's nothing terribly complex, I am creating a series of planes and then moving them into a folder in an assembly file (no other action).  Removing ALL event triggers does nothing to stop this here either.

Error Message:

Error in rule: Plane Generator, in document: Plane Int Test.iam

Object of type 'System.__ComObject' cannot be converted to type 'Inventor.ComponentOccurrence'

 

More Info:

System.Runtime.InteropServices.COMException (0x80004005): Object of type 'System.__ComObject' cannot be converted to type 'Inventor.ComponentOccurrence'.
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.BrowserPaneObject.AddBrowserFolder(String Name, Object BrowserNodes)
at LmiRuleScript.FlatPlanes()
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

I have located the error to be occurring in this section of iLogic, I can Try/Catch to skip but the result means I don't get these moved to a folder.

If PlaneClear = True Then
	Dim oFolder As BrowserFolder = Nothing
	Dim oTopNode As BrowserNode = oPane.TopNode
	Dim plFlatNodes As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Dim oNode As BrowserNode
	For Each oNode In oTopNode.BrowserNodes
		Dim idx As Integer: idx = InStr(oNode.FullPath, "Plane ")
		If idx > 0 Then Call plFlatNodes.Add(oNode)
	Next oNode
	If plFlatNodes.Count > 0 Then oFolder = oPane.AddBrowserFolder("WorkPlanes - Flat", plFlatNodes)
End If

Any ideas on what's might be triggering this issue and a means to catch/prevent the error?

 

Autodesk Inventor Certified Professional