#
# open_cut_y 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+Zdist^2);
ASSIGN: Same_xy= ((1-(Xdist>0.0001))*(1-(Zdist>0.0001)));
ASSIGN: Same_z= 1-(Ydist>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
RAPID: Y= Initial_z-Yorgshift;
RAPID: X= Xstart; Z= Zstart;
RAPID: Y= MAX(Yendr,Ystart)+ Tool_clearance;
CASE: 1
RAPID: Y= Yendr+Tool_clearance;
RAPID: X= Xstart; Z= Zstart;
CASE: 2
RAPID: Y= Initial_z-Yorgshift;
RAPID: X= Xstart; Z= Zstart;
RAPID: Y= Rap_level+Tool_clearance;
CASE: 3
FEED: X= Xstart; Z= Zstart;
CASE: 4,5,6,7
#DO NOTHING
END SELECT: 
