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.
An end macro that reads the current height and the axis limits, so the park move never goes out of range.
| Item | Value |
|---|---|
| Machine | 3D printer (Klipper) |
| Units | Metric |
| Lines | 15 |
Macro for printer.cfg
[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
- M400 — Finish moves
- G92 — Set position (G92 E0)
- M106 — Fan on (part cooling)
- M104 — Set hotend temperature (no wait)
- M140 — Set bed temperature (no wait)
- M84 — Disable motors (M84 / M18)
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
- Marlin Start G-code with Mesh, Prime Line and Safe Heating
- Marlin End G-code: Retract, Park and Cool Down
- Klipper PRINT_START Macro with Adaptive Mesh and Purge
- Klipper M600 Filament Change Macro
- E-steps Calibration Sequence (Marlin)
Was this page helpful?