Standard WorkPlane getting

Top  Previous  Next

In this function gikXIndex means the plane at X=0, which is of course the YZ Plane. And so on.


HRESULT GetStdWorkPlaneByIndex (CComPtr<WorkPlane>& pWorkPlane,

                                const UINT ikIndex, // gikXIndex, gikYIndex, gikZIndex

                                CComPtr<PartComponentDefinition>& pPartCompDef) 


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

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

        return E_FAIL ;



    // Get the work plane from the list of work planes in the part...

    HRESULT hRes = pPartCompDef->WorkPlanes->get_Item(CComVariant(ikIndex), &pWorkPlane);

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

        ShowCOMError (hRes,L"GWPBI but 'get' %d failed\n",ikIndex);

        return E_FAIL ;



    return S_OK ;


Here is how to use the function:


    hRes = GetStdWorkPlaneByIndex (pFlangiaPlane,

                                   gikYIndex, // the plane at Y=0, XZ

                                   pFlangiaCompDef) ;





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