#
# open_cut MACRO
# This positions for multiple depth contours
# If the distance from the last endpoint to this startpoint
# is greater than the tool diameter (this can be changed to whatever
# value you want)
#
ASSIGN: Pathstartpt
ASSIGN: Xdist= ABS(Xstart-Xendr);
ASSIGN: Ydist= ABS(Ystart-Yendr);
ASSIGN: Zdist= ABS(Zstart-Zendr);
ASSIGN: Xy_dist= SQR(Xdist^2+Ydist^2);
ASSIGN: Same_xy= ((1-(Xdist>0.0001))*(1-(Ydist>0.0001)));
ASSIGN: Same_z= 1-(Zdist>0.0001);
ASSIGN: In_tdia= 1-(Xy_dist>Tool_dia);
#
# This select case does the movements between the last contour
# and this contour
# Case 0 IS NOT the same xy OR z and the XY distance IS NOT within tool dia.
#
# Case 5 IS the same xy AND NOT z and the XY distance IS within tool dia.
#
SELECT: (4*Same_xy+2*Same_z+In_tdia)
CASE: 0
ASSIGN: Codes= Coolant_off;
RAPID: Z= Initial_z-Zorgshift;
POSITION_XY: X= Xstart; Y= Ystart;
#RAPID: Z= MAX(Zendr,Zstart)+ Tool_clearance;
RAPID: Z= Rap_level+ Tool_clearance;
CASE: 1
RAPID: Z= Zendr+Tool_clearance;
POSITION_XY: X= Xstart; Y= Ystart;
CASE: 2
ASSIGN: Codes= Coolant_off;
RAPID: Z= Initial_z-Zorgshift;
POSITION_XY: X= Xstart; Y= Ystart;
#RAPID: Z= Rap_level+Tool_clearance;
RAPID: Z= Zrapid_level+Tool_clearance;
CASE: 3
FEED: X= Xstart; Y= Ystart;
CASE: 4,5,6,7
#DO NOTHING
END SELECT: 
