Cancel gcode specific to the printer / slicer

Hi,

I am wondering if it could be possible : today I am using PrusaSlicer ; but I think it is almost the same in all slicers : you define any custom gcode for end job, just like retracting filaments, etc.
I know Octoprint also supports that but it will not depend on any parameters set up during slicing ; I explain : PrusaSlicer comes with this end gcode sequence :

{if has_wipe_tower}
G1 E-15.0000 F3000
{else}
G1 X0 Y210 F7200
G1 E2 F5000
G1 E2 F5500
G1 E2 F6000
G1 E-15.0000 F5800
G1 E-20.0000 F5500
G1 E10.0000 F3000
G1 E-10.0000 F3100
G1 E10.0000 F3150
G1 E-10.0000 F3250
G1 E10.0000 F3300
{endif}

; Unload filament
M702 C

G4 ; wait
M104 S0 ; turn off temperature
M140 S0 ; turn off heatbed
M107 ; turn off fan
; Lift print head a bit
{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+30, max_print_height)}{endif} ; Move print head up
G1 X0 Y200 F3000 ; home X axis
M84 ; disable motors

Here the {if has_wipe_tower} is a gcode that will be substituted according to the parameters of the slicing job. It will end up with pure GCODE. (there will be no {if ...} in the final file.)

I am not sure it is possible to replicate this in Octoprint, as it depends on the printer and will be difficult to support everything.

But it would be interesting to setup a label in gcode that would indicate post print gcode that should be invoked if job is cancelled.

What do you think ?

Afaik it's not possible to transfer the script tokens of PrusaSlicer to OctoPrint.

I would recommend an universal cancel gcode script.
Maybe like this:

G1 X0 Y210 F7200
G1 E2 F5000
G1 E2 F5500
G1 E2 F6000
G1 E-15.0000 F5800
G1 E-20.0000 F5500
G1 E10.0000 F3000
G1 E-10.0000 F3100
G1 E10.0000 F3150
G1 E-10.0000 F3250
G1 E10.0000 F3300

; Unload filament
M702 C

G4 ; wait
M104 S0 ; turn off temperature - maybe you leave the heaters on to start a new print asap
M140 S0 ; turn off heatbed
M107 ; turn off fan
; Move print head up
G1 Z5 F200    ; in 99% of all cases, the print is quite lower then the max print height.
G1 X0 Y200 F3000 ; home X axis
M84 ; disable motors

Ok
But what about putting a label I to the Goode and then jumping directly to this label when the job is cancelled ?
Isn’t it possible ?

1 Like

No, I don't think so, because gcode files are not meant to have jumps.

I have a universal cancel gcode for both of my printers (a MK2.5S + MMU2S and a T-Rex 3) and they are quite convenient. Simple and effective.