Pro/TOOLKIT sample program (15) mapkey

Pro/TOOLKIT can not fully realize all the functions of Pro/E.
For Pro/TOOLKIT, there is no API function, so it needs to be implemented with Mapkey.
You can record a Mapkey first and then call ProMacroLoad to execute Mapkey.
To record Mapkey under wildfire 5:
Tools - > map key

After recording, you can click Save to view the pseudo code of the Mapkey.

Example: to change the arrow style of all dimensions of a drawing to double arrow

In Pro/TOOLKIT, there is no API to modify arrow style of drawing size. If you want to modify arrow style of drawing size with code, you can only use Mapkey.
First, record a Mapkey that modifies the arrow style of the drawing size. Check the pseudo code of the Mapkey as follows:

~ Command ProCmdDwgModArrowStyle ;#DOUBLE ARROW;#DONE/RETURN;

Then call ProMacroLoad to execute.
The effect before and after implementation is shown in the following figure:

The following code implementation changes the arrow style of all dimensions in the current drawing to double arrow.

// Drawing dimension access function
ProError DrwDimensionVisitAction(ProDimension  *dimension,
                                 ProError      status,
                                 ProAppData     data)
    vector<ProDimension>* pDimVec = (vector<ProDimension>*)data;
    return PRO_TK_NO_ERROR;

// Change the arrow style for all dimensions in the current drawing
int ChangeDrwDimsArrowStyle(uiCmdCmdId  command,
                            uiCmdValue *p_value,
                            void       *p_push_command_data)
    // Get current drawing
    ProError err;
    ProMdl mdlCurr;
    err = ProMdlCurrentGet(&mdlCurr);
    ProMdlType mdlType;
    err = ProMdlTypeGet(mdlCurr, &mdlType);
    if (mdlType != PRO_MDL_DRAWING)
        return -1;

    // Traverse all dimensions in the drawing
    vector<ProDimension> allDims;
    err = ProDrawingDimensionVisit((ProDrawing)mdlCurr, PRO_DIMENSION, 
        DrwDimensionVisitAction, NULL, &allDims);

    // Execute Mapkey
    wstring wstrMapkey = L"~ Command `ProCmdDwgModArrowStyle` ;#DOUBLE ARROW;#DONE/RETURN;";
    vector<ProDimension>::iterator iterDim = allDims.begin();
    for (; iterDim != allDims.end(); ++iterDim)
        err = ProSelbufferClear();
        ProSelection dimSel;
        err = ProSelectionAlloc(NULL, &(*iterDim), &dimSel);
        err = ProSelbufferSelectionAdd(dimSel);

        // Load and execute Mapkey
        err = ProMacroLoad((wchar_t*)wstrMapkey.c_str());
        err = ProMacroExecute();
    err = ProWindowRepaint(-1);

    return 0;

Added by robpoe on Sat, 02 May 2020 07:14:31 +0300