The first is to send the selected axis to work zero. Create a button on the screen and set its buttonnumber to any number 20000 to 21999. Save the following macro to your macro folder with the name Mxxxxx.txt where xxxxx is the number you gave to buttonnumber.
- Code: Select all
// ================================================================================================
// Mx - Send selected MPG axis to work zero (20000 <= x <= 21999)
// ================================================================================================
int Axis = GetSelectedAxis();
if (Axis < 0)
{
exec.AddStatusmessage("No axis selected");
return;
}
exec.Code("G1 " + AxisNames[Axis] + "0");
// ================================================================================================
#Events
// ================================================================================================
const int MPGXaxisselect = 155;
const string AxisNames = "XYZABC";
// ================================================================================================
int GetSelectedAxis()
{
for (int i = 0; i < 6; ++i)
if (exec.GetLED(MPGXaxisselect + i))
return i;
return -1;
}
// ================================================================================================
The second macro is to send the selected axis to the given coordinate. You need one more button with an other buttonnumber. You also need a field where you can write the needed coordinate. Set the labelnumber of the new field to a number above 20000. Save the macro to this number. Edit the line where NewPositionField is set to 21000 and replace 21000 with your labelnumber. If you created the field on the jog screen then replace "AS3" with "AS3jog" in the macro.
- Code: Select all
// ================================================================================================
// Mx - Send selected MPG axis to work position read from a field (20000 <= x <= 21999)
// ================================================================================================
int Axis = GetSelectedAxis();
if (Axis < 0)
{
exec.AddStatusmessage("No axis selected");
return;
}
double GotoPos;
if (!Double.TryParse(AS3.Getfield(NewPositionField), out GotoPos))
{
exec.AddStatusmessage("Position is not numeric");
return;
}
exec.Code("G1 " + AxisNames[Axis] + GotoPos.ToString("F6"));
// ================================================================================================
#Events
// ================================================================================================
const int MPGXaxisselect = 155;
const string AxisNames = "XYZABC";
const int NewPositionField = 21000;
// ================================================================================================
int GetSelectedAxis()
{
for (int i = 0; i < 6; ++i)
if (exec.GetLED(MPGXaxisselect + i))
return i;
return -1;
}
// ================================================================================================
Now you're ready to run.