Could someone advise what the following functions and bits of code do ? Are they legacy functions of how to obtain information (fields) from screensets directly?
Thanks in advance.
line 8 - Getactualoffset() ?
line 10 - Wzval ?
line 10 - TOZval ?
line 10 - G92zval ?
line 11 - double safeZ = exec.mainform.UCsetup.UCset.Generalsettings.SafeZ;?
line 13 - double Softlimitsrelative = exec.mainform.UCsetup.UCset.Axis[2].UC100axis.SoftLimitP - exec.ofc.Wzval - exec.ofc.TOZval - exec.ofc.G92zval;?
I am guessing that the exec.mainform.UCsetup.UCset.Axis[2].UC100axis.SoftLimitP part of the code is another way to obtain the Axis [2] (Z-axis, positive soft limit number) from the screenset? another way would have been Getfield(42);? (Zaxissoftlimitplus)
not sure about the exec.ofc.xxxx bits.... could they have been obtained from fields too?
if(exec.mainform.UCsetup.UCset.Generalsettings.Enablesoftlimits)?
I am guessing that this is another way to check if softlimits have been enabled?
Full macro code posted below:
- Code: Select all
// Go to Zero with safeZ
if(exec.GetXpos()==0 && exec.GetYpos()==0 && exec.GetZpos()==0 && exec.GetApos()==0 && exec.GetBpos()==0 && exec.GetCpos()==0)
{
return; // if all position DROs are already zero then return
}
exec.Getactualoffset();
double safeZ = exec.mainform.UCsetup.UCset.Generalsettings.SafeZ;
double Softlimitsrelative = exec.mainform.UCsetup.UCset.Axis[2].UC100axis.SoftLimitP - exec.ofc.Wzval - exec.ofc.TOZval - exec.ofc.G92zval;
if(exec.mainform.UCsetup.UCset.Generalsettings.Enablesoftlimits)
{
if(safeZ>Softlimitsrelative)
{
safeZ = Softlimitsrelative;
if(exec.GetXpos()!=0 || exec.GetYpos()!=0 || exec.GetApos()!=0 || exec.GetBpos()!=0 || exec.GetCpos()!=0)
{
DialogResult result = MessageBox.Show(exec.mainform.MSG.Message[45], "Confirmation", MessageBoxButtons.YesNo);
if(result == DialogResult.No)
{
return;
}
}
}
}
while(exec.IsMoving()){}
int originaldistancemode = exec.actualdistmode; // remember the distance mode
int originalmodalmode = exec.actualmodal; // remember the modal mode
exec.Code("G90"); // Set system to absolute distance mode
exec.Wait(100);
if(exec.GetXpos()!=0 || exec.GetYpos()!=0 || exec.GetApos()!=0 || exec.GetBpos()!=0 || exec.GetCpos()!=0)
{
if(exec.GetZpos()<safeZ) //Move Z only if the Z coordinate is lower than the safeZ
{
exec.Code("G00 Z"+ safeZ); // Move Z up to safeZ defined by user, above the zero plane
while(exec.IsMoving()){}
}
exec.Code("G00 X0 Y0 A0 B0 C0"); // Move XYABC to Zero
while(exec.IsMoving()){}
exec.Code("G00 Z0"); // Move Z to 0
while(exec.IsMoving()){}
}
else
{
exec.Code("G00 Z0"); // Move Z to 0
while(exec.IsMoving()){}
}
exec.Code("G" + originaldistancemode); // Set system back to the original distance mode
exec.Code("G" + originalmodalmode); // Set system back to the original modal mode