by Parkgrr » Sun Jan 29, 2023 10:02 pm
Hi
Hijacking this as it seems to have slowed down. Having a similar issue. Quite random tool lengths, I'm sure my code just sucks. Would someone mind taking a gander at what I've written?
double ZMove = 14.8966; //Travel Distance to probe
double ZPos = exec.GetZmachpos();
exec.Callbutton(182); //Remove tool offset
double OldZpos = ZPos; // Set Old z position to current z position
ZPos = ZPos - ZMove; //Set Zpos to Zpos minus distance to probe
exec.Code("G31 Z" + ZPos + " F5.0" ); // Probes the tool length.
while(exec.IsMoving()){}
ZPos = exec.GetZmachpos();
while(exec.IsMoving()){}
if(ZPos == OldZpos) // Check if the the tool positon was found.
{
MessageBox.Show("ERROR! The tool did not hit the probe and DRO was not set");
exec.Stop();
return;
}
double Zoffset = AS3.Getfielddouble(873); //Set Zoffset to the current Z Mach coord
double Toffset = (Zoffset - ZShift); //Set Toffset to be current Z minus Zshift
exec.Code("G49"); // Cancel/delete tool offset
exec.Wait(100);
AS3.Setfieldtext("Removed Tool Offset ",2000);
AS3.Setfield(Toffset , (195+Tool));
exec.Callbutton(780); // Save tooltable
AS3.Setfieldtext("The Tool Table Is Updated ",2000);
AS3.Setfieldtext(" ",2000);
AS3.Setfieldtext("Applying G43 ",2000);
exec.Wait(1000);
exec.Code("G43 H" +Tool );
AS3.Setfieldtext(" G43 H" +Tool +" Applied ",2000);
AS3.Setfieldtext(" ",2000);
exec.AddStatusmessage("G43 Applied");