Default Move Events

The code below assumes that a STEP-NC file is in memory and annotated with ARM objects as described in the Getting Started instructions.

The example below uses a cursor to print the tool movements in a process. Each call to next() will return a move event (STIXCTL_MOVE) and the active element on the process stack will be some type of movement element. Check the type of that element with getActiveType().

After testing whether it is a linear move, arc, or helix, we print the destination coordinates, tool axis, and any arc parameters associated with the move. These are the most common parameters, but a position may have others, like surface normal or feed multiplier.


// Print coordinates and tool axis information for a move
//
void printend(StixCtlCursor &ctl, StixCtlPos p)
{
    double v[3];
    ctl.getPosXYZ(v, p);
    printf ("  END: XYZ: %.5g %.5g %.5g", v[0], v[1], v[2]);
    
    if (ctl.getPosDirZ(v, p))
	printf ("  ZDIR: %.5g %.5g %.5g", v[0], v[1], v[2]);

    printf ("\n");
}


// Print arc center, radius, and direction for an arc move
//
void printarc(StixCtlCursor &ctl, StixCtlPos p)
{
    double v[3];
    printf ("  ARC: %s", ctl.getArcIsCW(p)? "CW": "CCW");
    
    ctl.getArcCenter(v, p);
    printf ("  CENTER: %.5g %.5g %.5g", v[0], v[1], v[2]);

    printf ("  RADIUS: %.5g", ctl.getArcRadius(p));
    printf ("  ANGLE: %.5g", ctl.getArcAngle(p));
    printf ("\n");
}


int main (int argc, char **argv)
{
    [ ... read file and other setup ... ]

    StixCtlCursor p;
    p.startProject(design);
    while (p.next()) {
	switch (p.getActiveType())
	{
	case STIXCTL_TYPE_MOVE:
	    printf ("LINEAR MOVE\n");
	    printend(p, p.getMoveEnd());
	    break;
	    
	case STIXCTL_TYPE_MOVE_ARC:
	    printf ("ARC MOVE\n");
	    printarc(p, p.getMoveArc());
	    printend(p, p.getMoveEnd());
	    break;

	case STIXCTL_TYPE_MOVE_HELIX:
	    printf ("HELIX MOVE\n");
	    printarc(p, p.getMoveArc());
	    printend(p, p.getMoveEnd());
	    break;

	default:
	    printf ("UNKNOWN MOVE\n");
	    break;
	}
    }
    return 0;
}

When run on a file with some linear and arc moves, it produces the following output. The data was a series of three-axis toolpaths, so none of the positions have a tool axis direction.

LINEAR MOVE
  END: XYZ: 0 0 0
LINEAR MOVE
  END: XYZ: 0 2 0
ARC MOVE
  ARC: CW  CENTER: 2 2 0  RADIUS: 2  ANGLE: 90
  END: XYZ: 2 4 0
ARC MOVE
  ARC: CCW  CENTER: 2 6 0  RADIUS: 2  ANGLE: 90
  END: XYZ: 4 6 0
LINEAR MOVE
  END: XYZ: 4 6 0
LINEAR MOVE
  END: XYZ: 6 6 0
ARC MOVE
  ARC: CCW  CENTER: 8 6 0  RADIUS: 2  ANGLE: 90
  END: XYZ: 8 4 0
ARC MOVE
  ARC: CW  CENTER: 8 2 0  RADIUS: 2  ANGLE: 90
  END: XYZ: 10 2 0
LINEAR MOVE
  END: XYZ: 10 2 0
LINEAR MOVE
  END: XYZ: 10 0 0