Set the axes' starting positions

Before you transform ACS to MCS, you need to use SetAxisPositionOffset to set the axes' starting positions, because the axes may not stay at the positions you want to transform. Without using SetAxisPositionOffset, the transformed result could be wrong.

You may wonder why we don't use SetGroupPositionOffset to set the starting positions, because SetGroupPositionOffset is used to set a group's position, not an axis. Using SetGroupPositionOffset doesn't affect an axis' position in ACS. To make sure each axis stays at the position you want to transform from ACS, you need to use SetAxisPositionOffset.

To quickly set each axis' starting position, we use the function SetAllAxesStartingPosition to perform the task. When you use this function, enter the total number of your axes for the parameter totalAxis so that all your axes' starting positions can be set at once. SetAllAxesStartingPosition is used in the main function. See Main function in Chapter 9 to know where it is used.

Copy
VOID SetAllAxesStartingPosition(int totalAxis)
{
    //Set the starting positions.
    double setPosition = 0;

    for (int i = 0; i < totalAxis; i++)
    {
        KsCommandStatus Position = WaitForCommand(5, FALSE, SetAxisPositionOffset(i,
            setPosition, FALSE, mcImmediately));
        if (Position.Error)
            RtPrintf("SetAxisPositionOffset failed: %d\n\n", Position.ErrorId);
    }
}