Macro Introduction
Print Start Macro
- Set
PRINT_START
as the macro for starting printing, customize actions before printing - Note that the macro name can be customized as long as it is referenced in the start g-code script
[gcode_macro PRINT_START]
gcode:
G92 E0 # Reset extruder
BED_MESH_CLEAR # Unload mesh bed
G28 # Home all axes
#Z_TILT_ADJUST # Gantries leveling
#quad_gantry_level # Gantries leveling
#G28 # Home all axes
G1 Z20 F3000 # Move nozzle away from the heat bed
BED_MESH_PROFILE LOAD=default # Load mesh bed
Leveling and Bed Mesh Configuration Guide
1. Leveling Method Selection
Z_TILT_ADJUST
andquad_gantry_level
are mutually exclusive leveling options- Please choose one based on your equipment structure, do not use both
- If not applicable, please delete or comment out the corresponding configuration
- It is recommended to home the axes once after leveling
2. Bed Mesh Configuration Standards
BED_MESH_PROFILE LOAD=default
- Only a single bed mesh configuration can be loaded; multiple configurations cannot be enabled simultaneously
- In
BED_MESH_PROFILE LOAD=default
,default
is the preset configuration name - If no mesh bed has been created or the mesh bed is named differently, errors may occur
3. Standard Bed Mesh Calibration Command
BED_MESH_CALIBRATE horizontal_move_z=2 METHOD=rapid_scan
horizontal_move_z=2
: Nozzle lift height during calibration (unit: mm)METHOD=rapid_scan
: Use fast scanning calibration method
4. Adaptive Calibration Command
BED_MESH_CALIBRATE adaptive=1
- Simplified command specifically designed for auto-leveling sensors
- Applicable to sensor systems such as
TAP
,klicky
,PL08
- The calibration height and movement method are automatically controlled by the sensor, no manual parameters required
Print End Macro
- Set
PRINT_END
as the macro for ending printing, customize actions after printing - Note that the macro name can be customized as long as it is referenced in the end g-code script
[gcode_macro PRINT_END]
gcode:
# Get Boundaries
{% 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 %}
# Check end position to determine safe directions to move
{% 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
G1 E-10.0 F3600 # Retract filament
G91 # Relative positioning
G0 Z{z_safe} F3600 # Raise gantry
G0 X{x_safe} Y{y_safe} F20000 # Move nozzle to remove stringing
M104 S0 # Turn off extruder
M140 S0 # Turn off bed
M106 S0 # Turn off model fan
G90 # Set absolute coordinate system
G0 X{max_x / 2} Y{max_y} F3600 # Park nozzle at the back
BED_MESH_CLEAR # Unload mesh bed
Loading...