# Starting G-code for auto Z probe offset

So, I like to take off my glass build plate from my printer bed because I don't like to put any force on the bed bearings but this presents an issue. I have an inductive bed leveling probe and each time I remove the plate the Z offset seems to be off on the next print.

Instead of re-leveling my bed and setting the Z offset by hand, I thought of adding starting G-code to do that for me but I've hit a snag. I have an Ender 3 and use Slic3r.

The sequence of events I would like is as follows:

1. G28 - home axis
2. G0 X150 Y130 Z5 - Moves to X150 Y130 Z5
3. G30 S1 - Performs a bed leveling probe at the current point. This raises the head 10 mm and stops when the probe is triggered. The current Z height this stops at is what I want for the next command.
4. M851 Z[insert Z height from prev command here]

I know Slic3r has these placeholder values for some commands like M109 S[temperature_0] in the square brackets. Is there one for the current Z height?

• Z value is the difference between sensing probe and nozzle height vs bed surface, for example M851 Z-2.0, for me since my probe is low sensitive vs glass thickness the value is -0.7. This value is inside the firmware instead setting each part I run G29. I'm using 3 bed glass same thickness – Fernando Baltazar Oct 31 '19 at 4:58

If you insist on using G-code (e.g. in your start G-code script), you can redefine the Z=0 level by adding a G-code G92. In case of a 3 mm glass plate, you should add after the homing (G28) and probing of the bed (G29) the following:
G1 Z0  ; This will move the nozzle to Z=0 as if there was a slate of glass,