WorkAxes in Inventor programs

Top  Previous  Next

In a Part there are always three standard WorkAxes, the X Y and Z axes. Here is the "Z Axis":

 

Z-Axis-Inventor-Programming

 

When you search for axes by name, use "X Axis", "Y Axis",and "Z Axis" to get the standard ones. However remember that your use may not be in an English speaking country, and in that case you can use this function:

 

HRESULT GetStdWorkAxisByIndex (CComPtr<WorkAxis>& pWorkAxis,

                              const UINT ikIndex, // 1 2 3 = X Y Z

                              CComPtr<PartComponentDefinition>& pPartCompDef)

{

   if ((ikIndex < gikXIndex) || (ikIndex > gikZIndex)) {

       TRACE (L"GetWorkAxisByIndex index out of range: %d\n",gikXIndex) ;

       return (E_FAIL) ;

   }

 

   // Get the axis in the part by name...

   HRESULT hRes = pPartCompDef->WorkAxes->get_Item(CComVariant(ikIndex), &pWorkAxis);

   if (FAILED(hRes) || (pWorkAxis == nullptr)) {

       ShowCOMError (hRes,L"GetWorkAxisByIndex but  'get' failed\n");

       return (E_FAIL) ;

   }

 

   return (S_OK) ;

}

 

Like many things WorkAxes are inside PartComponentDefinition, and you can get hold of them like this:

 

   CComPtr<PartComponentDefinition>& pPartCompDef ;

   ...

   pPartCompDef->WorkAxes->get_Item(CComVariant(pszWorkAxisName), &pWorkAxis);

 

Note that the plural of Axis is Axes, not Axiss!

 

 

 

 

 

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