Cancel Print Action GCODE?

When I cancel a print in the Octoprint interface, the printer just stops where it's at. Where can I add GCODE so that cancelling a print does the following:

  1. Retract the filament
  2. Send a position command, for example, X0 Y180 Z180 (move printhead up and out of the way, move printbed forward)

Octoprint 1.1.0, Octopi 0.17.0, running on Raspberry Pi 3 Model B Plus Rev 1.3

Hello @rcsez!

You can put it here:

You get to the Settings via the wrench icon on the top right.

1 Like

Perfect! Thank you.

1 Like

Great! Could you please: PSA: Please mark the solutions to your topics as such

I found this thread when I was looking for how to do this very thing. So I've added this under "After a job is cancelled:"

;Move Z to the top
G90
G210 Z

; disable motors
M84

;disable all heaters
{% snippet 'disable_hotends' %}
{% snippet 'disable_bed' %}
;disable fan
M106 S0

I'm using a Prusa Mk3.5, but I'm not sure the model matters. I'm seeing no results at all. I can't remember, but I think the last 7 lines of code (from ";disable motors") on were already there and that all I did was add the code to move the print head all the way up. I'm seeing no movement at all.

Is this from me using problematic GCode commands or could it be that I need to enable something else? is there something I can add to be sure the code is being executed, such as a way to print a message to the printer display or display a message on the OctoPrint page?

Second line "G210 Z" makes no sense. Try "G1 Z210 F3000". Try different F values to go faster or slower.

Ah - works. I'm still learning GCode, and I must have misread some commands I was trying to emulate.

Thanks!