REM The default script here moves the tool back To m6start If Any movement has occured during the tool change..Code "(Please change to working coordinates)"If GetOEMDRO(46) = 6 Then  	' Simple Auto Zero' Based on the macros created be Big Tex -  May 25 2010' and modified by Poppa Bear 11dec10Dim ZNew, Zplate, ZMaxRetract, ZplatetomaterialDim XWork, YWork, XMachine, YMachine, ZMachineDim XScale, YScale, ZScaleDim xtoprobe, ytoprobeDim PlateOffset, MatOffset, TotalOffsetDim MatOffsetYNDim ZClear, ClearAllowDim CurrentFeedDim CurrentAbsIncDim ResponseXWork = GetOEMDRO(800)  ' Get Current X Work CoordinateYWork = GetOEMDRO(801)  ' Get Current Y Work CoordinateXMachine = GetOemDRO(83)  ' Get Current X Machine CoordinateYMachine = GetOemDRO(84)  ' Get Current Y Machine CoordinateZMachine = GetOemDRO(85)   ' Get Current Z Machine CoordinatePlateOffset = GetUserDRO(1851)  ' Get Plate Thickness DROMatOffset = GetUserDRO(1815)  ' Get Material Offset DROIf GetOEMDRO(46) = 6 Then	PlateOffset = 6.35ElseIf GetOEMDRO(46) = 4 Then        PlateOffset = -1.857480315Else	PlateOffset = 1End IfIf GetOEMLED(1863) Then  ' Set Flag if Material Offset is used	MatOffsetYN=1	Else	MatOffsetYN=0End If'Get Axis Scale factorsZScale = GetOEMDRO(61)'Set All Axis' Scale to 1Call SetOEMDRO(61,1)Sleep(250)CurrentFeed = GetOemDRO(818)  ' Get the current feedrate to return to laterCurrentAbsInc = GetOemLED(48)   ' Get the current G90/G91 stateZclear=GetOEMDRO(1814) ' Get Z Clearance Plane from DRO'//////// the block below will set all your reusable vars depending on Inch or mm.'//////// this sets the vars so you only need ONE large block of probing code.If GetOEMLED(801) Then  ' On = English Measure INCHFirstProbeDist = 12.0 ' Probe down 12 inchesFirstRetractDist = 0.05 ' Then retract .05 inchSecProbeDist = 0.25 ' Then probe down .25 inchesFirstProbeFeed = 50.0 ' First probe feed @ 10 ipmSecondProbeFeed = 1.0 ' Second probe feed @ 1 ipmClearAllow = 0.125 ' Max Allowable Clearance = Z Machine Zero - .125inElse ' Off = Metric Measure MMFirstProbeDist = 305.0 ' Probe down 305mmFirstRetractDist = 1.0 ' Then retract 1mmSecProbeDist = 6.0 ' Then probe down 6mmFirstProbeFeed = 1270 ' First probe feed @ 250 mm/minSecondProbeFeed = 25.0 ' Second probe feed @ 25 mm/minClearAllow = 2.0 ' Max Allowable Clearance = Z Machine Zero - 2mmPlateOffset = PlateOffset * 25.4End If'//////// Error Condition checking codeIf GetOemLED(16)<>0 Then ' Check for Machine CoordinatesCode "(Please change to working coordinates)"Exit Sub ' Exit if in Machine CoordinatesEnd IfIf GetOemLED(825)<>0 ThenCode "(Z-Plate Grounded Check connection and try again)"Exit Sub ' Exit if probe is trippedEnd If''If PlateOffset < 0 Then''Code "(Plate Thickness < 0 - Please Correct and try again)"''Exit Sub ' Exit If Plate Thickness is less than 0''End IfIf MatOffsetYN=1 Then	If MatOffset < 0 Then	Code "(Warning - Material Offset < 0)"	Sleep(3000)	End IfEnd IfIf ZClear <= 0 ThenCode "(Clearance Plane Must > 0 - Please Reset)"Exit Sub ' Exit If Clearance Plane is less than  or equal to 0End IfIf MatOffsetYN=1 Then  ' If Use Material Offset = Yes	TotalOffset = PlateOffset - MatOffset	Else	TotalOffset = PlateOffsetEnd If'//////// Start Probing Code, Probe In -Z direction.'//////// The vars will be Inch or Metric from above if/else statmentIf GetOEMDRO(46) = 6 Or GetOEMDRO(46) = 4 Then	Code "G0 G53 Z" & -1	While IsMoving() ' Wait for probe move to finish	Wend	Code "G0 G53 X340.37 Y444.6371"	While IsMoving() ' Wait for probe move to finish	WendEnd Ifsleep(1000) ' Pause for 1 second to give time to position probe plateCode "F" & FirstProbeFeed ' Set feedrate to 10 ipm or 300mm/minCode "(Probing for Z Zero.....)" ' Puts this message in the status barZNew = (GetOEMDro(802) - FirstProbeDist ) ' Probe move to current Z - 6 inchesCode "G90 G31 Z" & ZnewWhile IsMoving() ' Wait for probe move to finishWendZNew = GetVar(2002) ' Read the touch pointCode "G0 Z" & ( ZNew + FirstRetractDist ) ' Move up .05 inch or 1mm in case of overshootWhile IsMoving()WendCode "F" & SecondProbeFeed ' Set feedrate to 1 ipm or 25mm/minZNew = (GetOEMDro(802) - SecProbeDist ) ' Probe move to current Z - .25 inchesCode "G90 G31 Z" & ZnewWhile IsMoving()WendZNew = GetVar(2002) ' Read the touch pointCode "G0 Z" & ZNew ' Move back to hit point in case of overshootWhile IsMoving()WendCall SetOEMDRO (802, TotalOffset) ' Set the Z axis DRO to plate thicknesssleep(500) ' Pause for DRO to update.'Make Sure Z Clearance Plane is below Home Switch. If not, Notify User and Proceed.ZMaxRetract = Abs(GetOemDRO(85)) - ClearAllow ' Distance to Home Switch - Clearance AllowanceCode "G0 G53 Z" & -0.1While IsMoving()WendCode "G0 X" & XWork & " Y" & YWorkWhile IsMoving()WendCall SetOEMDRO(61,ZScale)Sleep(250)Code "(Z axis is now zeroed.)"If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to itCode "G91" End If Elsex = GetToolChangeStart( 0 )y = GetToolChangeStart( 1 )z = GetToolChangeStart( 2 )a = GetToolChangeStart( 3 )b = GetToolChangeStart( 4 )c = GetToolChangeStart( 5 )if(IsSafeZ() = 1) Then   SafeZ = GetSafeZ()   if  SafeZ  > z then StraightTraverse x, y,SafeZ, a, b, c       StraightFeed  x, y,  z  , a, b, celseCode"G00 X" & x & "Y" & yEnd IfEnd If   