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: 

IV2009: How do i retrieve the object type (SketchEntity::ReferencedEntity)?

4 REPLIES 4
Reply
Message 1 of 5
kvetter
343 Views, 4 Replies

IV2009: How do i retrieve the object type (SketchEntity::ReferencedEntity)?

Hello.

I want to retrieve all external "context" references of a part document.

My solution is:
- Loop through all feature
- Loop through all sketches
- Loop through all sketch entities and search for referenced entities

But, how do i retrieve the right object type of the property "ReferencedEntity" (Object "SketchEntity")?

I got the object, but where can i get the object type of the reference?

Thanks in advance.
Klaus
4 REPLIES 4
Message 2 of 5
Josh_Petitt
in reply to: kvetter


what language?



you should be able to use object.Type to get the type constant.

Message 3 of 5
kvetter
in reply to: kvetter

I'm using C#.

Meanwhile i got the type of the referenced entity (using Microsoft.VisualBasic.Information.TypeName(...)).
The retrieved type is "_IRxWorkPoint", but here's the next problem.

The interop (Autodesk.Inventor.Interop.dll) has an definition of this type, but didn't expose this type for using.

Any idea?
Message 4 of 5
Josh_Petitt
in reply to: kvetter

AFAIK, all Inventor objects define a method .Type that will return a ObjectTypeEnum (e.g. kWorkPointObject). This will allow you to determine what type of object you've got. Use this to then cast your generic object to a more specific object (if needed). (I think C# implemented a built-in "safe cast" that can be used.)
Message 5 of 5
Josh_Petitt
in reply to: kvetter




If you are trying to execute different code depending on what type of object you have, then a slick way to do this is to create a map (or associative container, I don't know exactly what they call it in C#). For the key use the Microsoft.VisualBasic.Information.TypeName(...) function (this returns a string), and for the value store a functor. Then you can loop thru the objects and grab the appropriate functor out of the map. This avoids having a huge, slow, "if...then...elseif...else" branching statement.



Although, if you only have to handle a few object types, then this may be more overhead than is required.

Edited by: Josh_Petitt on May 26, 2009 4:30 PM

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

Post to forums  

Autodesk Design & Make Report