Hello Everyone,
I am creating a tool to display feature information and highlight the associated geometry for appropriate extent options. My code is based directly from the sample “Display feature information API Sample”.
I am having same issue with both the FromToExtent and ToExtent options. If the toExtent.ToEntity is referencing a Workplane, Workpoint or Vertex it does exactly what I want it to do. If the toNext.ToEntity is referencing a planar surface it doesn’t work with the following error “Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))”
Any help or suggestions would be greatly appreciated
Joe
Dim myExtrudeDef As ExtrudeDefinition myExtrudeDef = oExtrude1.Definition . . Select Case myExtrudeDef.ExtentType. . Case kToExtent Dim toExt As ToExtent Set toExt = extrudeDef.Extent Try Dim oHightlightSetNew As HighlightSet oHightlightSetNew = oapp.ActiveDocument.CreateHighlightSet Dim oRed As Inventor.Color oRed = oapp.TransientObjects.CreateColor(255, 0, 0) oRed.Opacity = 0.5 oHightlightSetNew.Color = oRed oHightlightSetNew.Clear() oHightlightSetNew.AddItem(toExt.ToEntity) m_inventorApplication.ActiveDocument.SelectSet.Select(toExt.ToEntity) Catch ex As Exception End Try
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Hi Joe,
Could you please provide a non-confidential document that can be used to reproduce the issue on our side?
Inside the VBA Watches window does the
toExt.ToEntity
object appear OK? Which is the exact line of code throwing an error?
Which version of Inventor are you using?
Cheers,
Sorry for the delay, vacation season.
The error is thrown on line oHightlightSetNew.AddItem(toExt.ToEntity)
In the Visual Studio watch window the toExt.ToEntity is inaccessible when the reference is a face. Image_1
looks ok whan reference is to a Workplane or WorkPoint
The attached file is a test part
I am using Autodesk Inventor 2015 Update 1
Hi Joe,
If you check in VBA then you can see that the object type in case of an extrusion going to a face is "toExt.ToEntity : : Variant/Object/Faces", and both the SelectSet.Select() and highlightSet.AddItem() expect a single object.
So you'll just have to iterate through the Faces and add them one by one:
If TypeOf toExt.ToEntity Is Faces Then Dim f As Face For Each f In toExt.ToEntity Call oHightlightSetNew.AddItem(f) Call doc.SelectSet.Select(f) Next Else Call oHightlightSetNew.AddItem(toExt.ToEntity) Call doc.SelectSet.Select(toExt.ToEntity) End If
Cheers,
Thanks for the help
The VBA object browser and the Visual studio Object browser and the API help .chm only refer to "toExt.ToEntity" as type object.
Sorry, I meant the VBA watches window, but was not clear about it:
http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html