Example program · 3D printing

Klipper PRINT_START Macro with Adaptive Mesh and Purge — G-Code Example

A PRINT_START macro for printer.cfg that takes the temperatures from the slicer, heats in the right order, probes only the print area and purges. One slicer line calls it.

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

A PRINT_START macro for printer.cfg that takes the temperatures from the slicer, heats in the right order, probes only the print area and purges. One slicer line calls it.

ItemValue
Machine3D printer (Klipper)
UnitsMetric
Lines22

Macro for printer.cfg

Klipper config
[gcode_macro PRINT_START]
description: Heat, home, mesh and purge
gcode:
  {% set BED = params.BED|default(60)|float %}
  {% set EXTRUDER = params.EXTRUDER|default(210)|float %}
  M140 S{BED}                    ; bed: start heating
  M104 S150                      ; nozzle: warm, no ooze
  G28
  M190 S{BED}                    ; wait for bed
  BED_MESH_CALIBRATE ADAPTIVE=1  ; mesh only where the part is
  M109 S{EXTRUDER}               ; wait for nozzle
  G92 E0
  G90
  M83
  G1 X5 Y20 Z0.3 F6000
  G1 Y120 E12 F1200              ; purge
  G1 X5.4 F3000
  G1 Y20 E12 F1200
  G1 Z1 F600

; slicer start G-code (PrusaSlicer):
; PRINT_START BED=[first_layer_bed_temperature] EXTRUDER=[first_layer_temperature]

▶ Check it in the 3D printer simulator

How it works

  • ADAPTIVE=1 needs [exclude_object] in printer.cfg and "label objects" in the slicer.
  • Printers with Z_TILT_ADJUST or QUAD_GANTRY_LEVEL run it after G28 and home Z again.
  • Adjust the purge position to your bed.

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?