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: 

ObjectsEnumerator, get_Item: What is the type of the item?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
oransen
515 Views, 2 Replies

ObjectsEnumerator, get_Item: What is the type of the item?

ObjectsEnumerator, get_Item will give me a WorkPlane, WorkPoint or WorkAxis. But I've found that it will not fail if I ask for a WorkPoint instead of a WorkPlane for example.

 

Can I pass get_Item a more general pointer and then cast it to the approriate type?

 

CComPtr<ObjectsEnumerator> pObjs = nullptr ;
pElement->get_ResultFeatures (&pObjs) ;
        
const int ikNumObjs = pObjs->Count ;
TRACE (L"PatternElement %d has %d result features\n",ix,ikNumObjs) ; 
for (int iObj = 1 ; iObj <= ikNumObjs ; iObj++) {
    CComPtr<WorkPlane> pWP = nullptr ; // !!!HERE!!! Is there something more general than WorkPlane? 
    hRes = pObjs->get_Item (iObj,(IDispatch**)&pWP) ;
    if (FAILED(hRes) || (pWP == nullptr)) {
        TRACE (L"get_Item WP failed") ;
        return ;

In other words, in the ResultFeatures, how do I identify the type of the feature?

2 REPLIES 2
Message 2 of 3
philippe.leefsma
in reply to: oransen

Please check the API Help Files before asking questions: you will see that the class hierarchy is mentioned there for each object. Unfortunately WorkPoint/Plane/Axis do not derive from a comon base class.

 

In C++ you will have to try casting the object in order to determine the type. Another approach may be to use late binding to retrieve the Type (ObjectTypeEnum) which is the only comon property all API objects have. You have to consider if it worth the pain of invoking late binded property from C++.

 

In languages like .Net, things are much easier as you can use the "is" operator to test your types.

 

Regards,

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
oransen
in reply to: philippe.leefsma

Hmm. Ok. Thanks.

 

(PS I DID check the docs, could not find the hierarchy I was looking for, hence my question!)

 

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

Post to forums  

Autodesk Design & Make Report