Rem	VBScript To probe In the z axis

DoOemButton(1003)

If GetOemLed (825) <> 0 Then 		'Check to see if the probe is already grounded or faulty
	Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Else
	'Code "G4 P2"				'Pause 1 seconds to give time to position probe plate
	Sleep 100
	PlateOffset = 4.9				'<--- !!!!!!!!!!!!!! Write here you plate thickness !!!!!!!!!!!!!!
	CurrentFeed = GetOemDRO(818) 	'Get the current feedrate to return to later
	Code "F75"					'slow down feedrate to 4 ipm
	Sleep 500

Rem	Probe In the z direction
	ZNew = GetDro(2) - 50			'probe move to current z - 50 mm
	Code "G31Z" &ZNew
	While IsMoving()				'wait for probe move to finish
	Wend

	'ZNew = GetVar(2002) 			'read the touch point
	'Code "G0 Z" &ZNew 			'move back to hit point incase there was overshoot
	'While IsMoving ()
	'Wend

	If PlateOffset <> 0 Then
		Call SetDro (2, PlateOffset)	'set the Z axis DRO to  plate thickness
		Sleep 500 			'Pause for Dro to update.
		Sleep 500
		ZNew = PlateOffset + 10		'ZNew = plate thickness + 10 mm
		Sleep 500
		'ZNew = 2				' as variant. But ZNew coordinate should be more than a thickness of a plate
		Code "G0 Z" &ZNew 		'put the Z retract height you want here
		Code "(Z axis is now zeroed)" 	'puts this message in the status bar
	End If

	Sleep 200
	Code "F" &CurrentFeed 		'Returns to prior feed rate
End If                       
      
