Skip to content

Instantly share code, notes, and snippets.

@ChainsDD
Created April 30, 2022 19:48
Show Gist options
  • Save ChainsDD/d058df354377815b157fd3ed585b525f to your computer and use it in GitHub Desktop.
Save ChainsDD/d058df354377815b157fd3ed585b525f to your computer and use it in GitHub Desktop.
END_PRINT
[gcode_macro END_PRINT]
gcode:
{% set th = printer.toolhead %}
{% set x_safe = th.position.x + 20 * (1 if th.axis_maximum.x - th.position.x > 20 else -1) %}
{% set y_safe = th.position.y + 20 * (1 if th.axis_maximum.y - th.position.y > 20 else -1) %}
{% set z_safe = [th.position.z + 2, th.axis_maximum.z]|min %}
SAVE_GCODE_STATE NAME=STATE_PRINT_END
M400
G92 E0
G1 E-5.0 F1800
TURN_OFF_HEATERS
G90 ; absolute positioning
G0 X{x_safe} Y{y_safe} Z{z_safe} F20000 ; move nozzle to remove stringing
G0 X{th.axis_maximum.x//2} Y{th.axis_maximum.y - 2} F3600 ; park nozzle at rear
M107 ; turn off fan
RESTORE_GCODE_STATE NAME=STATE_PRINT_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment