Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Feature Information Extent ToNext References

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
JoeBarnes4076
552 Views, 5 Replies

Feature Information Extent ToNext References

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

 

5 REPLIES 5
Message 2 of 6
adam.nagy
in reply to: JoeBarnes4076

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, 



Adam Nagy
Autodesk Platform Services
Message 3 of 6
JoeBarnes4076
in reply to: adam.nagy

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

Message 4 of 6
adam.nagy
in reply to: JoeBarnes4076

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,



Adam Nagy
Autodesk Platform Services
Message 5 of 6
JoeBarnes4076
in reply to: adam.nagy

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. 

 

Message 6 of 6
adam.nagy
in reply to: JoeBarnes4076

Sorry, I meant the VBA watches window, but was not clear about it:

http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html

 



Adam Nagy
Autodesk Platform Services

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums