My Pause / Resume scripts


I’ve only recently (OK, so it’s been eight weeks) tinkered with the pause/unpause gcode scripts, and these are the ones that do serve the purpose on my TronXY X5S. Just throwing this out here, maybe someone has use for it or some suggestions how to improve / modify …

Begin Pause:

G91 ; Relative movement
G1 Z5 ; Move head away vertically
G1 E-6 F1000; Retraction move, take away filament pressure
G90 ; Absolute position ON
G1 X0 F2500 ; Move to left edge of print bed
G1 Y0 ; Move to front position (two moves to avoid risk of running into bed clamps)
G91; Relative movement
G1 E-80 F1000; retract filament into bowden for easier swap
G90; Absolute position ON

After this, the print head is at its 0/0 position, the filament can be pulled back easily and is out of the hotend.

Now the "before resume" script:

G91 ; Relative movement
G1 E80 F300; Reposition filament (or purge if new filament has been pushed in by hand)
G90 ; Absolute position
G1 Y50 F3000; Move past the front left clamp to be safe

As the gcode contains absolute values, the print head will return to the next position on the object and continue printing. There'll be a little cleanup involved at the stop/start, and there's the risk of losing one linear motion track, e.g. pausing a cube might cause one line of filament to go "missing" because the printer will continue from the next position in the GCode and not the one where it left off, I guess?

Like I said, just throwing it out there. I’ve tried it with this gear cube stand:


I suppose I like it. My own printer needs about 120mm to retract, 120mm to re-extrude and perhaps another 30mm to completely change colors safely.

Not all times that I'm pausing are associated with a filament change. Sometimes I'm just getting in there and fixing a wonky first layer, for example.


I like it! but how does it deal with absolute stepper movements? Say, for example, the slicer software had the extruder at 90mm when paused, when resumed, the next extruder move would be (for example) 91mm. After the above pause script (if I read it correctly), the first thing the printer will do is spew out 91mm of filament. (I have experienced it!)

Would really like to use this script in combination with a filament sensor, as the memory on the Melzi board (Ender-3 and 5) is too low to include it in Marlin (unless dropping SD support)


It should work with absolute stepper movements just fine – the GCode I get from Slic3r has the extruder positions in absolute mm too. My pause script does switch to relative distances and moves the position by the same amount back/forth before returning to absolute at the pause-end, which (in theory and at least on the hardware I use also in practice) should leave the absolute position unchanged after the pause.

I have not had the opportunity to test it elsewhere, so it may cause different reactions on other boards.


well, your reply gives me confidence to just go do it and see what happens. Not expecting many filament runouts, but miscalculated today resulting in a failed print.

Thank you!!!


You'll easily know if it's wrong.

  • In one case, it will dump 90mm worth of filament, for example, in place and then continue.
  • In the other case, it will take a 90mm "holiday" from extruding as it ghost-prints after the resume.