Script to move Z at end of print if model isn't taller?

It would be handy to make some space between the print head and the just completed print to simplify getting the print off the bed, but if I just make a script that does something like "G0 Z50" at the end of the print, it could be very bad when the model I just printed was taller than 50mm. I see the dashboard knows the height it printed, so it ought to be possible to move Z to max(50,height printed). Any way at all to do that? Could a plugin manage it? Can octoprint already do that and I haven't found the right magic yet?

You should be able to use relative mode to make the printer move 'up by 10' or something, so it will always be higher than the final height.

Try:

G91
G0 Z10
G90

Trouble is that could be just as catastrophic if I printed a really tall model and there is not that much room left :-). When I used RepetierHost it had a "park position" and the Z park would work as I described. It was really useful.

The printer firmware should prevent this, because it can not lift the z-axis higher than it is set in the firmware.

Sorry, small correction to the script, I got G91/92/90 mixed up. Thanks @PrintedWeezl!

The printer should stop itself being moved too far, hopefully.

1 Like

My solution is specific to Prusaslicer. In End GCode I have

{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+30, max_print_height)}{endif}

Which equates to raise head by 30 unless head is at or near max then raise to max.

Is that Marlin version specific?

I assume it should work with all versions.

If only I could figure out how to enable that in the old version of Marlin I'm using on the solidoodle 2. The comments in the firmware are not not described in multiple double negatives, so I've never figured out exactly how to turn it :-). I suppose I should ignore the comments and just read the code, but have never gotten around to it.