//This is the Constructor macro which executes once when the application gets loaded

//*****************  rem Modified Sep/20/2024 by CNC4PC  *******************
//*****************************  CNC4PC block  *****************************
//*****************  PTS Block  *******************

string Z_Top = exec.Readkey("UserTextfields", "20001", "Z_Top");
if (Z_Top == "Z_Top")
{
double Z_Top_d = 5;
AS3.Setfield(Z_Top_d, 20001);
exec.Writekey("UserTextfields", "20001", "5");
}
else
{
double Z_Top_d = double.Parse(Z_Top);
AS3.Setfield(Z_Top_d, 20001);
}

string Z_min_height = exec.Readkey("UserTextfields", "20002", "Z_min_height");
if (Z_min_height == "Z_min_height")
{
double Z_min_height_d = -50;
AS3.Setfield(Z_min_height_d, 20002);
exec.Writekey("UserTextfields", "20002", "-50");
}
else
{
double Z_min_height_d = double.Parse(Z_min_height);
AS3.Setfield(Z_min_height_d, 20002);
}

string Offset_Z = exec.Readkey("UserTextfields", "20003", "Offset_Z");
if (Offset_Z == "Offset_Z")
{
double Offset_Z_d = 0;
AS3.Setfield(Offset_Z_d, 20003);
exec.Writekey("UserTextfields", "20003", "0");
}
else
{
double Offset_Z_d = double.Parse(Offset_Z);
AS3.Setfield(Offset_Z_d, 20003);
}

string Probing_FR = exec.Readkey("UserTextfields", "20006", "Probing_FR");
if (Probing_FR == "Probing_FR")
{
double Probing_FR_d = 30;
AS3.Setfield(Probing_FR_d, 20006);
exec.Writekey("UserTextfields", "20006", "30");
}
else
{
double Probing_FR_d = double.Parse(Probing_FR);
AS3.Setfield(Probing_FR_d, 20006);
}


string Cut_Height = exec.Readkey("UserTextfields", "20010", "Cut_Height");
if (Cut_Height == "Cut_Height")
{
double Cut_Height_d = 3;
AS3.Setfield(Cut_Height_d, 20010);
exec.Writekey("UserTextfields", "20010", "30");
}
else
{
double Cut_Height_d = double.Parse(Cut_Height);
AS3.Setfield(Cut_Height_d, 20010);
}

string Check_probe_disable = exec.Readkey("UserCheckboxes", "20006", "Check_probe_disable");
if (Check_probe_disable == "Check_probe_disable")
{
bool Check_probe_disable_b = false;
AS3.Setcheckboxstate(Check_probe_disable_b, 20006);
exec.Writekey("UserCheckboxes", "20006", "False");
}
else
{
bool Check_probe_disable_b = Convert.ToBoolean(Check_probe_disable);
AS3.Setcheckboxstate(Check_probe_disable_b, 20006);
}

//***************************  End CNC4PC block  ****************************
