- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to use iLogic to generate an array of workpoints on the hull of a tugboat (to export heights to an Excel sheet indexed by x,y coordinates), but I keep getting the following error message:
Error in rule: Generate_WPoints, in document: Hull Shape.ipt
Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.Face'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{5DF8608B-6B16-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).and under "More Info":
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.Face'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{5DF8608B-6B16-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
I think it has something to do with the named geometry I am trying to use. I have a surface model of the hull, which includes 15 surfaces that I have named Hull0 - Hull14. I have written one rule to generate a grid of vertical workplanes and another to generate work axes at the intersections of the workplanes, each guided by parameters for overall width and length, along with the desired mesh size. That brings us to the code in question.
'Set up variables for the current part document and its components.
Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
'This line is necessary to work with named geometry.
Dim oNames As NamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
'These variables are to intersect axes with surfaces to generate points.
Dim oPoint As WorkPoint
Dim oAxis As WorkAxis
Dim oHull As Face
'Define and initialize incrementing variables starting at FWD Port corner.
Dim X, Y As Integer
X = 0
Y = -1 * Mesh * Floor(OAW / Mesh / 2) / (1 in)
'Increment through all existing work axes. Find which, if any, hull surface
'each axis intersects with, create a workpoint there, and name it.
While Y <= OAW / (2 in)
X = 0
While X <= OAL / (1 in)
oAxis = oDef.WorkAxes.Item("Axis_" & CStr(X) & "_" & CStr(Y))
For k = 0 To 14
oHull = oNames.FindEntity("Hull" & CStr(k))
oPoint = oDef.WorkPoints.AddByCurveAndEntity(oHull, oAxis)
oPoint.Name = "Point_" & CStr(X) & "_" & CStr(Y)
Next
X = X + Mesh / (1 in)
End While
Y = Y + Mesh / (1 in)
End WhileI would greatly appreciate the silver bullet for the error in this code. However, I would just as heartily welcome any constructive suggestions improving my workflow.
Solved! Go to Solution.