Example program · 3D printing

Klipper PRINT_END Macro That Parks Safely at Any Height — G-Code Example

An end macro that reads the current height and the axis limits, so the park move never goes out of range.

By cnccode · Updated
On this page
  1. Macro for printer.cfg
  2. How it works
  3. Codes used in this program
  4. More 3D printing programs

An end macro that reads the current height and the axis limits, so the park move never goes out of range.

ItemValue
Machine3D printer (Klipper)
UnitsMetric
Lines15

Macro for printer.cfg

Klipper config
[gcode_macro PRINT_END]
description: Retract, park, cool down
gcode:
  {% set th = printer.toolhead %}
  {% set z_park = [th.position.z + 10, th.axis_maximum.z]|min %}
  M400
  G92 E0
  G1 E-2 F2700
  G90
  G1 Z{z_park} F600
  G1 X{th.axis_minimum.x + 5} Y{th.axis_maximum.y - 5} F6000
  M106 S0
  M104 S0
  M140 S0
  M84

▶ Check it in the 3D printer simulator

How it works

  • printer.toolhead gives the real limits from printer.cfg, so the macro works on any printer.
  • The [min] filter keeps the park height inside the Z travel.

Codes used in this program

Check bed size, temperatures, probe and macro names against your own printer before you use this code, and stay at the printer for the first run.

More 3D printing programs

Was this page helpful?