Query current z_offset

Is there a way to query the current z_offset? I had a look at the objects provided in the status reference document, but couldn’t find anything. The reason I ask is that I reset the z_offset using relative_reference_index (my printer uses a z-endstop switch, and a Euclid probe), and then apply an adjustment to cater for thermal expansion, and I would like to be able to display what the final value ends up as.

Try using {printer.gcode_move.homing_origin.z} in a macro.

-Kevin

1 Like

Thank you Kevin, that’s exactly what I was looking for.

EDIT: That didn’t work for me unfortunately, not sure if I am doing something wrong or what is going on.

I put the following line at several places in my START_PRINT macro:

M118 Z_OFFSET value: {printer.gcode_move.homing_origin.z}

And it always responded with

Z_OFFSET value: 0.0

Any Hints?

I did a little more investigation into this. Firstly. whenever I query {printer.gcode_move.homing_origin.z}, it always returns 0.0. Secondly, I can query other values from gcode_move, such as position, gcode_position, and speed, but once I make the initial query, all subsequent queries return the same value as the first query, as if the values are being cached. Is this expected behaviour?

I still haven’t found a solution to this, does anyone have any suggestions on how I can query the current z_offset please?

It’s the method described above. It sounds like you’ve tried to evaluate {printer.gcode_move.homing_origin.z} in the same macro that issues the G28, but macros are evaluated in entirety before any commands are run. To get the value after a G28 you need to run another macro that evaluates the value - see Commands templates - Klipper documentation

-Kevin

1 Like

That makes perfect sense Kevin, thanks very much. I’ll try it again