Exception on attempt to read value of DrivenBy property of one particular WorkPlane

Exception on attempt to read value of DrivenBy property of one particular WorkPlane

Maxim-CADman77
Advisor Advisor
374 Views
3 Replies
Message 1 of 4

Exception on attempt to read value of DrivenBy property of one particular WorkPlane

Maxim-CADman77
Advisor
Advisor

I'd like to know the reason of Exception ("Unspecified error", HResult 0x80004005) on attempt to read the value of "DrivenBy" Property of one particular WorkPlane* with the below iLogic code:

 

 

For each oWPl in ThisDoc.Document.ComponentDefinition.WorkPlanes
	logger.debug("oWPl.Name = " & oWPl.Name)

	' If oWPl.DefinitionType.ToString <> "kTwoPlanesWorkPlane" Then Continue FOR
	If System.Enum.GetName(GetType(WorkPlaneDefinitionEnum), oWPl.DefinitionType) <> "kTwoPlanesWorkPlane" Then Continue FOR

	Dim oWPlDBs As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	try
		oWPlDBs = oWPL.DrivenBy' 80004005 !!!!!!
	catch ex As Exception
		logger.debug("    ex.Data = " & ex.Data.ToString)
		logger.debug("    ex.HResult = " & ex.HResult)
		logger.debug("    ex.Message = " & ex.Message)
		logger.debug("    ex.Source = " & ex.Source)
		logger.debug("    ex.StackTrace = " & ex.StackTrace)
	end try
	logger.debug("      DrivenBy = " & oWPlDBs.Count)
Next

 

 

I also converted the code to VB.net in order to get some more details by means of VisualStudio debugger and got "Exception has been thrown by the target of an invocation" ... which has no much sense for me.

 

Sample IPT (Inventor 2022) is attached.

 

* The WorkPlane "Part2 WP" was created ByTwoPlanes (middle between Faces of the flat Body)

 

PS: This issue was found in context of project that is supposed to either find existing "middle plane" or create it (if there is no one yet).

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
375 Views
3 Replies
Replies (3)
Message 2 of 4

nmunro
Collaborator
Collaborator
Accepted solution

It appears you need to look at the oWPl.Definition property instead of the DrivenBy property. You already know it is a "two planes" workplane definition so you can cast the Definition to a TwoPlanesWorkPlaneDef object. This will contain a Plane1 and Plane2 property that you must also type test as they could be planar faces or workplanes in a part. Once you have the two planar references you should be able to proceed.

        


https://c3mcad.com

0 Likes
Message 3 of 4

Maxim-CADman77
Advisor
Advisor

@nmunro  
I wonder how you got aware of the properties' names (I mean "Plane1" and "Plane2")?
... definitely not from official  WorkPlane.Definition article.


Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 4 of 4

nmunro
Collaborator
Collaborator

Although pretty much everything is available if you know where to look, Inventor's API documentation can be a pain to navigate. I've always found VBA to be the best tool for testing even if you are using iLogic or developing add-ins since you can set break points and can view the state of all variables via the watch window. A very simple macro can enable exploration of the current state of affairs. 

        


https://c3mcad.com