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?
Solved! Go to Solution.
Solved by philippe.leefsma. Go to Solution.
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.
Hmm. Ok. Thanks.
(PS I DID check the docs, could not find the hierarchy I was looking for, hence my question!)