/* M20002
Part Extents Macro to test material fit
ported from Mach3 to C# for uccnc, thanks to BR549/Vmax549/TP for the original macro
25/06/2016 - robertspark
3/19/17 - E Brust - Allow mid points for round items.
NOTE: Set your feedrate and Dwell Time according to you machine parameters / units / requirements.
*/
double FR = 100; // sets Feedrate
double DT = 3000; // Sets Dwell Time (mSec, 3000 = 3 sec)
double XMax;
double XMin;
double YMax ;
double YMin ;
double numobjects;
numobjects=Convert.ToDouble(AS3.Getfield(894));
if(numobjects==0)
{
MessageBox.Show("Load a File And Restart");
return;
}
XMax = Convert.ToDouble(AS3.Getfield(888)); // 888 Diagnostics_maxX
XMin = Convert.ToDouble(AS3.Getfield(885)); // 885 Diagnostics_minX
YMax = Convert.ToDouble(AS3.Getfield(889)); // 889 Diagnostics_maxY
YMin = Convert.ToDouble(AS3.Getfield(886)); // 886 Diagnostics_minY
DialogResult tst;
tst = MessageBox.Show("Is your part round / want to hit midpoints? Click YES for centers of sides/circle, NO for corners/square" , "mode", MessageBoxButtons.YesNo);
DialogResult result;
result = MessageBox.Show("Is Your Z HEIGHT Safe To Travel?", "check!!!" , MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.Yes)
{
if (tst == System.Windows.Forms.DialogResult.Yes)
{
/* exec.Code("G92 X0 Y0 Z0"); // Zero the DRO's
exec.Code("G01 X" + XMin + " Y" + YMin + " F" + FR); // Move to Minimum X & Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep(); */
exec.Code("G04 P" + DT);
exec.Code("G01 x" + XMin + " y" + (YMin+YMax)/2 + " F" + FR); // Move to Maximum Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
/* exec.Code("G04 P" + DT);
exec.Code("G01 Y" + YMax); // Move to Maximum Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep(); */
exec.Code("G04 P" + DT);
exec.Code("G01 X" + (XMin+XMax)/2 + "Y" + YMax); // Move to Maximum X Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
/* exec.Code("G04 P" + DT);
exec.Code("G01 X" + XMax); // Move to Maximum X Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep(); */
exec.Code("G04 P" + DT);
exec.Code("G01 x" + XMax + " Y" + (YMin+YMax)/2); // Move to Minimum Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
/* exec.Code("G04 P" + DT);
exec.Code("G01 Y" + YMin); // Move to Minimum Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep(); */
exec.Code("G04 P" + DT);
exec.Code("G01 X" + (XMin+XMax)/2 + " Y" + YMin); // Move to Minimum X Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
/* exec.Code("G04 P" + DT);
exec.Code("G01 X" + XMin); // Move to Minimum X Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep(); */
exec.Code("G04 P" + DT);
exec.Code("G01 X0 Y0"); // Move to 0,0 X & Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
}
if (tst == System.Windows.Forms.DialogResult.No)
{
exec.Code("G92 X0 Y0 Z0"); // Zero the DRO's
exec.Code("G01 X" + XMin + " Y" + YMin + " F" + FR); // Move to Minimum X & Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
exec.Code("G04 P" + DT);
exec.Code("G01 Y" + YMax); // Move to Maximum Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
exec.Code("G04 P" + DT);
exec.Code("G01 X" + XMax); // Move to Maximum X Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
exec.Code("G04 P" + DT);
exec.Code("G01 Y" + YMin); // Move to Minimum Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
exec.Code("G04 P" + DT);
exec.Code("G01 X" + XMin); // Move to Minimum X Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
exec.Code("G04 P" + DT);
exec.Code("G01 X0 Y0"); // Move to 0,0 X & Y Coordinates
while(exec.IsMoving()){}
exec.Wait(200);
Console.Beep();
}
}
if (result == System.Windows.Forms.DialogResult.No)
{
MessageBox.Show("Move Z To A Safe Position And Restart");
}
Return to Ask a question from support here
Users browsing this forum: Majestic-12 [Bot] and 36 guests