What sort of WorkFeature is this?

Top  Previous  Next

Unfortunately WorkPoint WorkAxis and WorkPlane objects do not have a common parent. If you get a pointer to one of these things from an ObjectsCollection you have to work a bit harder than normal to get their type. Here is an example, assuming you already have an ObjectsEnumerator and want to get hold of the iObj th item:

 

 

   CComPtr<ObjectsEnumerator> pObjs = ... ;

   int iObj = ...

   ...

   CComPtr<WorkPlane> pWPlane = nullptr ;

   CComPtr<WorkPoint> pWPoint = nullptr ;

   CComPtr<WorkAxis> pWAxis = nullptr ;

   pObjs->get_Item (iObj,(IDispatch**)&pWPlane) ;

   pObjs->get_Item (iObj,(IDispatch**)&pWPoint) ;

   pObjs->get_Item (iObj,(IDispatch**)&pWAxis) ;

 

   if ((pWPlane != nullptr) && (pWPlane->GetType() == kWorkPlaneObject)) {

       // pWPlane is a valid workplane

 

   } else if ((pWPoint != nullptr) && (pWPoint->GetType() == kWorkPointObject)) {

       // pWPoint is a valid workpoint

 

   } else if ((pWAxis != nullptr) && (pWAxis->GetType() == kWorkAxisObject)) {

       // pWAxis is a valid axis

 

   } else {

       // This is probably an error 

   }

 

.

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)