OctoPrint "After Print Job is Cancelled" GCODE Script

[Closed] OctoPrint "After Print Job is Cancelled" GCODE Script  

New Member

Posting this here in the hopes that it will help someone in the future. I am using OctoPrint v1.3.4, with a Original Prusa i3 MK2 running FW 3.0.11. Hre is my problem; when I cancel a print from the OctoPrint interface, it just does a dead stop, and shuts things down. This has lead to a bunch of extra cleanup getting bad prints off of the print head. :/ I wanted OctoPrint to behave like a cancel from the LCD, here is what I came up with;

In OctoPrint go to Settings (the wrench), then GCODE Scripts. In the "After Print Job is Cancelled" area enter the following;

G91; Set to Relative position
G1 E-1 F300; retract the filament a bit before lifting the nozzle
G0 Z15; move z axis up 15
G28 X; home X axis
G1 Y150 F5000; move part out for inspection
G90; Set to Absolute position
M104 S0 ; turn off extruder heat
M140 S0 ; turn off heated bed
M106 S0 ; Turn off fan
M18; Move Freely

Save and test. A "Cancel" from OctoPrint should behave much more like a cancel form the LCD.

Hope this helps,

Posted : 12/06/2017 12:40 am
Estimable Member

Thanks for the code.

I gave it a try and it works great so far. Much better than the standard cancel action of Octopi.

3D printing newbie - wanting to learn 😀 - 1st "printer" TIKO 3D
- 2nd PRUSA i3 MK2S with MMU v1
- 3rd PRUSA i3 MK2S
- 4th PRUSA i3 MK3 with MMU v2 on order...
Posted : 16/06/2017 4:19 am
Estimable Member

I will try it also.

One thing: the GCode Reprap Wiki says that Marlin (based) FWs should call M84 instead of M18?


My Things: http://www.thingiverse.com/calli/designs
My Book: http://blenderbuch.de
My Make Blog: https://plus.google.com/b/113205824564673616795/113205824564673616795...
Posted : 25/06/2017 1:41 pm
Eminent Member

Thank you for this post! You posted last year and it helped me today!

I changed your code slightly since you moved the extruder using relative positioning. I changed it to absolute positioning. In addition, there was default code in this section already so I used the existing code. Here is my updated code:

G91 ; set to Relative position
G1 E-1 F300 ; retract filament a bit before lifting nozzle
G0 Z15 ; move z axis up 15mm
G90 ; set to Absolute position
G1 Y190 F5000 ; move part out for inspection
G1 X190 F5000 ; move nozzle out of the way

M84 ; disable motors

;disable all heaters
{% snippet 'disable_hotends' %}
{% snippet 'disable_bed' %}

M106 S0 ; disable fan

Posted : 11/06/2018 7:57 pm
Woody liked

Please Login or Register