double Zmin = -100; //Max.Z depth double Feedrate = 250; //Feedrate for probing double retractheight = 10; //The retract height double newZ; bool Check = AS3.Getcheckboxstate(20001); if (Check) { newZ = AS3.Getfielddouble(20002); } else { newZ = 0; } exec.Callbutton(161); //Handrad abschalten exec.Code("G31 Z" + Zmin + "F" + Feedrate); // Start probing while(exec.IsMoving()){} // Wait while there is motion exec.Wait(200); //Safety wait for the UC100 syncronisation exec.ChangeaxisDROvalue(2, newZ.ToString()); //Change the DRO value exec.Wait(200); //Safety wait for the UC100 syncronisation if(!exec.Ismacrostopped()) // If tool change was not interrupted with a stop only then validate new tool number { double Zup = exec.GetZmachpos() + retractheight; //Calculate the new coordinate for the retract of Z axis exec.Code("G00 G53 Z" + Zup); //Retract the Z-axis while(exec.IsMoving()){} // Wait while there is motion } exec.Callbutton(226); //Handrad einschalten exec.Wait(200);