Skip to content

Instantly share code, notes, and snippets.

@cr45hmurphy
Forked from lhns/afterPrintCancelled
Created January 29, 2021 17:40
Show Gist options
  • Save cr45hmurphy/f6d76458d1afc4b37a74c5a15a125c49 to your computer and use it in GitHub Desktop.
Save cr45hmurphy/f6d76458d1afc4b37a74c5a15a125c49 to your computer and use it in GitHub Desktop.
OctoPrint GCODE Scripts
; disable motors
M84
; disable all heaters
{% snippet 'disable_hotends' %}
{% snippet 'disable_bed' %}
;disable fan
M106 S0
; relative XYZE
G91
M83
; retract filament, move Z slightly upwards
G1 E-1 F1000
G1 Z+5 F4500
; absolute XYZE
M82
G90
; move to a safe rest position, adjust as necessary
G1 X0 Y200
M150 R255 U B ; disable lights
M150 R255 U B ; disable lights
;M601 ; pause print
{% if pause_position.x is not none %}
; relative XYZE
G91
M83
; retract filament, move Z slightly upwards
G1 E-1 F1000
G1 Z+5 F4500
; absolute XYZE
M82
G90
; move to a safe rest position, adjust as necessary
G1 X0 Y200
; disable all heaters
{% snippet 'disable_hotends' %}
{% snippet 'disable_bed' %}
{% endif %}
M150 R255 U B ; disable lights
;M602 ; resume print
;G4 P5000 ; dwell
M150 R0 U B ; enable lights
{% if pause_position.x is not none %}
; resume all heaters
{% snippet 'resume_heaters' %}
; relative extruder
M83
; prime nozzle
G1 E-1 F1000
G1 E+1 F1000
G1 E+1 F1000
; absolute XYZE
M82
G90
; reset E
G92 E{{ pause_position.e }}
; relative extruder
M83
; move back to pause position XYZ
G1 X{{ pause_position.x }} Y{{ pause_position.y }} Z{{ pause_position.z }} F4500
; reset to feed rate before pause if available
{% if pause_position.f is not none %}G1 F{{ pause_position.f }}{% endif %}
{% endif %}
M150 R0 U B ; enable lights
; enable bed
{% if printer_profile.heatedBed %}
{% if pause_temperature['b'] and pause_temperature['b']['target'] is not none %}
M140 S{{ pause_temperature['b']['target'] }}
{% else %}
M140 S0
{% endif %}
{% endif %}
; enable hotends
{% for tool in range(printer_profile.extruder.count) %}
{% if pause_temperature[tool] and pause_temperature[tool]['target'] is not none %}
M109 T{{ tool }} S{{ pause_temperature[tool]['target'] }}
{% else %}
M104 T{{ tool }} S0
{% endif %}
{% endfor %}
; wait for bed
{% if printer_profile.heatedBed %}
{% if pause_temperature['b'] and pause_temperature['b']['target'] is not none %}
M190 S{{ pause_temperature['b']['target'] }}
{% endif %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment