Pause and Resume gcode script does not extrude properly using Prusaslicer

Slicer (name, version, operating system)
What is the problem?
I'm looking to make use of the pause and resume gcode scripting available through Octoprint to perform filament changes. Seems to work great for Cura but Prusaslicer seems to really dislike it. With Cura using absolute extrusion and Prusaslicer using relative I attempted to make some changes but seem to have the same problem. The position restarts as it should but it just seems to draw inconsistent filament in dots and shows large retracts as it returns to the print

What did you already try to solve it?

My start gcode

M104 S160 ; set extruder to a temporary high enough temp
M140 S[first_layer_bed_temperature] ; set bed temp
M190 S[first_layer_bed_temperature] ; wait for bed temp
M109 S160 ; wait for extruder temporary high enough temp

;Avoid mesed up BLtouch by resesting forced
M280 P0 S60 ; Test Mode 
G4 P500 
M280 P0 S90 ; Stow Probe 

G28 ; home all axes 
M420 S1 

G1 Y3 X0 Z2 F3000.0 ; intro line
G1 Y3 X0 Z0.28 F1000.0 ; intro line
M104 S[first_layer_temperature] ; set extruder actual required temp
M109 S[first_layer_temperature] ; wait for extruder actual required temp

G92 E0
G1 Y3 X10.0 E9.0 Z0.28 F1000.0 ; intro line
G1 Y3 X50.0 E12.5 Z0.28 F1000.0 ; intro line
G92 E0 ;Reset Extruder

Pause code

**;pause code**
{% if pause_position.x is not none %}
; relative XYZE

; retract filament, move Z slightly upwards
G1 Z+5 E-5 F4500

; absolute XYZE

; move to a safe rest position, adjust as necessary
G1 X0 Y0
{% endif %}

Resume code

**;resume code**
{% if pause_position.x is not none %}
; relative extruder

; prime nozzle
G1 E-5 F4500
G1 E5 F4500
G1 E5 F4500

; absolute E

; absolute XYZ

; reset E
G92 E{{ pause_position.e }}

; 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 %}

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware...)

Running Marlin 2.0.7 looking to avoid altering the firmware

I've tried quite a few different combinations playing with the absolute extrusions in the script etc but still its a no go it just sputters filament in dots when it resumes. The retract amounts are not too large as it works with Cura.

I also have this problem. After resuming, the extruder motor does not seem to do the thing. It will manually extrude when I tell it to via the octopi control, but once I restart the print, the extruder motor doesn't see to extrude.

I may start another thread if I find no other info.

I went though this today because I wanted to change color at a certain layer, M600 was not recognized and I didn't want to update the firmware since everything else had been running great, I was on Marlin 1.0.1 on a 4.2.2 board. So I tried using the PAUSE and RESUME feature in OctoPi (Version 0.17.0, running on Raspberry Pi 3 Model B Plus Rev 1.3) and upon resume the extruder motor seemed to actually run opposite what I should be. I thought this might be a firmware issue so I updated to Marlin Same results, so I edited the firmware build to enable the change filament codes. Works fine from Prusa Slicer now. I don't think it is a big deal since there is a right way to do it in the gcode now but I am sure there is a bug when the RESUME function is used in OctoPi.

Unlikely to be a bug - without knowing the contents of the scripts, I can't say for sure, but it's unlikely.

The problem you probably faced is relative vs. absolute commands, if the gcode is using absolute and then the script is using the other but you don't include the right commands to switch modes, this can happen.

The slicer was Prusa, no added script. The gcode file was not modified, the commands were sent via the PAUSE and RESUME buttons in OctoPi. The process was handled strictly in the user interface of OctoPi as follows.

Paused the print, retracted, lift on Z and homed on XY, then Extract for some mm until the filament was changed color then, RESUME and the extractor then ran in reverse.

Just the slicer name isn't enough to confirm or deny @Charlie_Powell's premise. Slice a small object (1x1x1mm cube) and post the gcode output here and we probably can give you a better answer.

1 Like

Any resolution to your problem? I'm having the same issue. Using Prusaslicer 2.3.1, no added script in Octoprint on an Ender 3 v2 printer.

Last night I was trying a two color print for the first time and came across this same issue. With some test prints and watching the terminal output I was able to figure out that it is a relative vs. absolute command issue like @Charlie_Powell suggested. As it turns out PrusaSlicer (2.3.1) outputs the extruder commands as relative, but the XYZ commands are absolute. From what I found OctoPrint does not track the current command state of the motors and just assumes all command states should be absolute for printing. In my testing I found if you just pause a print and restart without any motor movement there is no issue and the print resumes as normal, but if you move any motor the movement command is wrapped by commands to set the command mode to relative, do the move, then set the command mode to absolute for all motors. This method causes the extruder to be running in the incorrect command state for the remainder of the print.

In the OctoPrint Settings -> GCODE Scripts -> Before print job is resumed
make sure the end of the resume script ends with

; relative extruder

This will set the extruder back to relative and your print should resume as expected.

WARNING: If you happen to use multiple different slicer softwares and the other software uses absolute command mode for the extruder this could break prints sliced in that other software if there are pauses in the print.

1 Like

Hi John,

Thanks for your post. I actually tried your recommendation and it seems like it works however, I have another problem for some reason after the print head extrudes out the new filament and returns back to print, nothing comes out from the print head on the print. It extrudes out the new color just fine.

I don't understand what's going on.


Could you please enable the serial logging and share the serial.log of this event

1 Like

I agree with @Ewald_Ikemann that seeing the serial log will help to diagnose this further. It would also be good to include your entire pause and resume scripts.

1 Like

Here's my serial log using the Prusa Slicer pause. It pauses just fine and purges filament prior to resuming the print. Unfortunately, after it resumes nothing comes out of the hotend.

I appreciate the help!
serial.log (263.5 KB)

It seems the printer does the priming in absolute extrusion mode.

You may put a M83 in to this field in Settings -> Gcode scripts:


I already have M83 in the Before print job is resumed.

Somehow it does not appear in the serial log.

It shows up on line 198 and 592 in my serial log.

Yes, but not after the pause/resume sequence starting at 3281.

Line 198 is line 10 of the transmitted gcode file and
line 592 is line 33 of the transmitted gcode file, both very near to the start

That's weird! Not sure why.