// M706 G7 + G8 Macroloop Emulate // G7 Emulate (Via Macro M707 + M706 macroloop, clear Macro with M708 & reset to default Radius Mode) /* G7 Lathe Diameter Mode Program G7 to enter the diameter mode for axis X on a lathe. When in the diameter mode the X axis moves on a lathe will be 1/2 the distance to the center of the lathe. For example X1 would move the cutter to 0.500” from the center of the lathe thus giving a 1” diameter part. G8 Lathe Radius Mode Program G8 to enter the radius mode for axis X on a lathe. When in Radius mode the X axis moves on a lathe will be the distance from the center. Thus a cut at X1 would result in a part that is 2" in diameter. G8 is default at power up. */ // check flag, if VAR 750 = 0, save spindle speed + sleep. intVar706Flag = Convert.ToInt32(exec.Getvar(706)); if ( intVar706Flag != 352 ) // flag set { if ( intFlag706Set == 1 ) { // reset X-Axis Steps per Unit to original setting & clear internal macro flag {allows for change of state reset} AS3.Setfield(dblXAxisStepsPerSave, 8); AS3.Validatefield(8); intFlag706Set = 0; // clear internal macro flag } // Do nothing and return from loop } // if VAR 706 = 352 (flag set), save X-axis Steps per Unit for later reset and Set Steps per unit to 1/2 (diameter mode) else { if ( intFlag706Set != 1 ) { dblXAxisStepsPerSave = Convert.ToDouble(AS3.Getfield(8)); // save X-Axis Steps per Unit double dblStepsDia = dblXAxisStepsPerSave / 2; AS3.Setfield(dblStepsDia, 8); AS3.Validatefield(8); intFlag706Set = 1; // set internal macro flag } // Do nothing and return from loop } Thread.Sleep(50); #Events static int intVar706Flag; static int intFlag706Set; static double dblXAxisStepsPerSave;