Maybe you can Handle that with a Macroloop like that.
- Code: Select all
// ================================================================================================
// Restore last tool number on startup
// ================================================================================================
bool ResetNow = exec.GetLED(ResetLED);
if (FirstRun && !ResetNow)
{
while (!exec.GetLED(ResetLED))
Thread.Sleep(10);
ResetNow = exec.GetLED(ResetLED);
}
FirstRun = false;
if (NeedCheck && !ResetNow)
{
Thread.Sleep(100);
exec.Codesync("");
if (!exec.Ismacrostopped())
{
string LTstr = exec.Readkey("MyValues", "ToolNumber", "0");
int LastTool = Convert.ToInt32(LTstr);
exec.Setcurrenttool(LastTool);
exec.Code("F300"); // Sets Feedrate
exec.Code("S10000"); // Sets RPM
// Uncomment the next 3 lines to turn on tool length offset for the loaded tool
// exec.Wait(100);
// int Currenttool = exec.Getcurrenttool();
// exec.Code("G43 H" + Currenttool.ToString());
exec.AddStatusmessage("Tool number T" + LastTool.ToString() + " restored.");
NeedCheck = false;
loop = false;
}
else
{
exec.AddStatusmessage("Waiting stop to clear...");
Thread.Sleep(1000);
}
}
// ================================================================================================
#Events
// ================================================================================================
const int ResetLED = 25;
static bool FirstRun = true;
static bool NeedCheck = true;
// ================================================================================================
and that code in M99999.txt to Save the Last Tool by Closing UCCNC
- Code: Select all
exec.Writekey("MyValues", "ToolNumber", AS3.Getfielddouble(897).ToString()); // Read & Save Last Tool
I Have write that Code in a M99995.txt an set a Macroloop. After hitting the Reset Button, the Last Tool while be writen in UCCNC.