// Go to Park position 1 macro double parkZ = -30; double parkX = 0; double parkY = 0; if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58)) // If machine was not homed then it is unsafe to move in machine coordinates, stop here... { MessageBox.Show("The machine was not yet homed, home the machine before run to parking position!"); exec.Stop(); return; } double XCoordMove = parkX - exec.GetXpos(); double XCoordEnd = exec.GetXmachpos() + XCoordMove; double XMin = exec.mainform.UCsetup.UCset.Axis[0].UC100axis.SoftLimitN; double XMax = exec.mainform.UCsetup.UCset.Axis[0].UC100axis.SoftLimitP; double YCoordMove = parkY - exec.GetYpos(); double YCoordEnd = exec.GetYmachpos() + YCoordMove; double YMin = exec.mainform.UCsetup.UCset.Axis[1].UC100axis.SoftLimitN; double YMax = exec.mainform.UCsetup.UCset.Axis[1].UC100axis.SoftLimitP; if (XCoordEnd < XMin || XCoordEnd > XMax || YCoordEnd < YMin || YCoordEnd > YMax) { MessageBox.Show("Parking relative location of " + parkX + "," + parkY + " is outside the machine table.\n" + "Abs X = " + Math.Round(exec.GetXmachpos(), 4) + ", Park X = " + Math.Round(XCoordEnd, 4) + ", Range = " + XMin + ".." + XMax + "\n" + "Abs Y = " + Math.Round(exec.GetYmachpos(), 4) + ", Park Y = " + Math.Round(YCoordEnd, 4) + ", Range = " + YMin + ".." + YMax + "\n"); return; } int originalmodalmode = exec.actualmodal; // remember the modal mode while(exec.IsMoving()){} // Move to ParkZ, but only if we are lower than park position if (exec.GetZmachpos() < parkZ) { exec.Code("G00 G53 Z"+ parkZ); // Move Z up first to park1 Z position while(exec.IsMoving()){} exec.Wait(200); } exec.Code("G00 X" + parkX +" Y" + parkY); // Move to XY park1 position while(exec.IsMoving()){} exec.Code("G" + originalmodalmode); // Set system back to the original distance mode