Skip to main content

Macro Introduction

This page provides commonly used start and end macros, as well as examples of where to call macros in slicer software. Macro names can be customized but must match the start/end G-code in the slicer software.

Start Macro

PRINT_START is used to define actions before printing begins, such as homing, leveling, nozzle lifting, and loading the bed mesh.

printer.cfg
[gcode_macro PRINT_START]
gcode:
G92 E0 # Reset extrusion
BED_MESH_CLEAR # Unload bed mesh
G28 # Home all axes
# Z_TILT_ADJUST # Gantry leveling
# QUAD_GANTRY_LEVEL # Gantry leveling
# G28 # Recommended to home again after leveling
G1 Z20 F3000 # Move nozzle away from bed
BED_MESH_PROFILE LOAD=default # Load bed mesh

Leveling and Bed Mesh Configuration Guide

I. Leveling Method Selection

  • Z_TILT_ADJUST and QUAD_GANTRY_LEVEL are mutually exclusive leveling methods.
  • Choose one based on your device architecture; do not use both simultaneously.
  • If the machine does not have a corresponding leveling method, delete or comment out the relevant configuration.
  • It is recommended to home again after performing leveling.

II. Bed Mesh Configuration Specification

BED_MESH_PROFILE LOAD=default
  • Only one bed mesh configuration can be loaded at a time.
  • default is the preset configuration name; if the bed mesh name is different, it needs to be modified accordingly.
  • If no bed mesh has been saved in advance, executing this command may result in an error.

III. Standard Bed Mesh Probing Command

BED_MESH_CALIBRATE horizontal_move_z=2 METHOD=rapid_scan
  • horizontal_move_z=2: Nozzle lift height during probing, in mm.
  • METHOD=rapid_scan: Uses the rapid scan probing method.

IV. Adaptive Probing Command

BED_MESH_CALIBRATE adaptive=1
  • Applicable to configurations supporting adaptive bed mesh.
  • Commonly found in sensor systems such as TAP, Klicky, PL08, etc.
  • The probing range and movement method are determined by the configuration; ensure probe offset and bed mesh range are correct before use.

End Macro

PRINT_END is used to define actions after printing ends, such as retraction, Z-axis lift, heater shutdown, fan shutdown, and moving to a parking position.

printer.cfg
[gcode_macro PRINT_END]
gcode:
{% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
{% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
{% set max_z = printer.configfile.config["stepper_z"]["position_max"]|float %}

{% if printer.toolhead.position.x < (max_x - 20) %}
{% set x_safe = 20.0 %}
{% else %}
{% set x_safe = -20.0 %}
{% endif %}

{% if printer.toolhead.position.y < (max_y - 20) %}
{% set y_safe = 20.0 %}
{% else %}
{% set y_safe = -20.0 %}
{% endif %}

{% if printer.toolhead.position.z < (max_z - 2) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - printer.toolhead.position.z %}
{% endif %}

M400 # Wait for buffer to clear
G92 E0 # Reset extruder position
G1 E-10.0 F3600 # Retract filament
G91 # Relative positioning
G0 Z{z_safe} F3600 # Lift Z axis
G0 X{x_safe} Y{y_safe} F20000 # Move nozzle to remove ooze
M104 S0 # Turn off extruder heater
M140 S0 # Turn off bed heater
M106 S0 # Turn off part cooling fan
G90 # Absolute positioning
G0 X{max_x / 2} Y{max_y} F3600 # Park nozzle at rear
BED_MESH_CLEAR # Unload bed mesh

Slicer Macro Settings

  • Select Printer.
  • Switch from Beginner mode to Expert mode in the upper right corner.
  • Select Custom G-code.
Loading...
  • After Start G-code appears, you can fill in the start macro call.
Loading...
Loading...