//Macro M45 Tool Height Set // Install Taster // Z down to touch off // Set Z Zero // Install Tool to set // Move down to less than 25mm of touch probe // Call M41 Qxx where xx is teh tool # if(Qvar == null) { MessageBox.Show(" Q variable is missing, Restart "); return; } exec.AddStatusmessage("Starting Z tool Touch off"); while(exec.IsMoving()){} exec.Code(" G91"); while(exec.IsMoving()){} exec.Code("G31 Z -25 F50"); // Depth of Z to probe while(exec.IsMoving()){} exec.Code ("G00 Z" + 1); // Retract 1mm above the plate while(exec.IsMoving()){} exec.Wait(100); exec.Code("G31 Z -1.5 F5" ); // Probe Z slowly for better resolution while(exec.IsMoving()){} exec.Wait(200); exec.Code("G90"); while(exec.IsMoving()){} exec.Code("G0 G53 Z0"); while(exec.IsMoving()){} double Toffset =(exec.Getvar(5063)); exec.Wait(100); if (Qvar <= 20 && Qvar >=1 ) { AS3.Setfield(Toffset, (195+Convert.ToInt32(Qvar))); exec.Wait(100); AS3.Validatefield((195+Convert.ToInt32(Qvar))); exec.Wait(100); exec.AddStatusmessage( "Tool # " +Qvar +" Updated "); exec.Wait(100); } if(Qvar <= 96 && Qvar >= 21) { AS3.Setfield(Toffset, (900+Convert.ToInt32(Qvar))); exec.Wait(100); AS3.Validatefield((900+Convert.ToInt32(Qvar))); exec.Wait(100); exec.AddStatusmessage(" Tool # " +Qvar +" Updated "); exec.Wait(100); } exec.AddStatusmessage( "Tool Set Routine Completed "); //eof