How to properly pause Octoprint to change filament manualy

How to properly pause Octoprint to change filament manualy

Clicking on Pause in Octoprint  stops the 3d print.  The printing head remains on the last position. If you want to change a filament you need to move the print head on a better position. In standard settings, you don’t have a chance to resume the print successfully. The print head doesn’t return to the last position automatically.

To be able to resume printing successfully,  you have enter some commands which will printer execute immediately after a click on Pause button and before the printer continues printing after a click on Resume button.

Go to the Octoprint settings  (wrench icon) -> GCODE Scripts. Into the input field “After print job is paused” enter  following code:

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

; retract filament of 0.8 mm up, move Z slightly upwards and 
G1 Z+5 E-0.8 F4500

; absolute XYZE

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

And into the “Before print job is resumed” input field

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

; prime nozzle
G1 E-0.8 F4500
G1 E0.8 F4500
G1 E0.8 F4500

; absolute E

; absolute XYZ

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

; WARNING!!! - use M83 or M82(exruder absolute mode) according what your slicer generates
M83 ; extruder relative mode

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

Credits: code above is modified code from this Octoprint documetation  page. To find the page, go to Octoprint Documentation, then Features -> GCODE scripts ->Examples


Update:  September 21st 2018 11:20

This code was successfully tested on

  • Prusa MK2S
  • Prusa MK3
  • Octoprint Version 1.3.9
  •  Slic3r Prusa Edition 1.4.0 + win64

I am not able to test other 3d printers.

Bi-color cube printed via octoprint  by  pause/resume controls.

Share this post

Comments (34)

  • Kris Reply

    I believe, thta in “Before print job is resumed” after “reset E” should be M82 instead of M83.

    2018-08-16 at 19:29
    • Rick Reply

      Thank you so much, that mistake completely mess up my extruder. 😉 Thanks to the author nonetheless. 😀

      2018-09-20 at 21:22
      • yirco Reply

        Hello Rick,
        I am sorry you have problems with the code I posted. I wouldn’t post something which I didn’t tested. Nevertheless, I did it again. I copied the code from the webpage into the Octoprint.
        Then I run a print. Paused the print. Changed the filament. Resumed. And again – pause, changed the filament, resume. Everything worked fine for me.
        Current test configuration:
        – Prusa MK2S with Firmware 3.1.0
        – Octoprint Version 1.3.9
        – Raspberry Pi 3
        – Slic3r Prusa Edition 1.4.0 + win64
        What is your configuration?
        Did you move the extruder during the pause manually?

        there is a switching from relative to absolute mode and back. It is possible that some switching is obsolete.
        Why do you recommend M82 instead of M83?

        2018-09-21 at 11:08
        • Murphy Reply

          Hey yirco – I just printed benchy with 2 layers using your pause G-code and it worked perfectly with the latest versions of everything.
          – Prusa i3 MK3 Firmware 3.4.0
          – Octoprint Version 1.3.9
          – Rapsberry Pi B+
          – Slic3r Prusa Edition 1.41.0+linux64
          Unloading and loading filament was simple using the standard menu on the MK3. After a slight lag when pause is selected (probably due to cached commands) the print head rose up, went to a safe position and awaited manual filament change. It resumed printing right where it left off when the resume button was selected. Thanks for the great G-code!

          2018-09-23 at 4:14
          • yirco

            Hi Murphy,
            thanks for sharing the positive experience.
            You are right about the lag after pressing/clicking the Pause. The printer has to finish movements which are already cached. Otherwise, it wouldn’t be possible to determine exactly the position where to continue.
            best regards

            2018-09-24 at 12:19
    • Simon Barter Reply

      Thank you Yirco for the code!

      Thank you Kris, after changing it to M82 instead of M83 it worked on my FLSUN QQ too!!!!

      2018-10-13 at 18:49
    • Andre Leduc Reply

      On my Wanhao D9 300 it does work too with your solution to change to M82 instead of M83. Thanks.

      2018-12-29 at 12:43
  • noneya Reply

    Thanks for the code, but reset E still has M83. Please update the snippet.

    2018-10-27 at 1:29
  • Steve Reply

    Worked great on an Ender 3 with stock firmware. Thanks!

    2018-11-02 at 5:05
  • nigew Reply

    I tried it, with M83, on an Anycubic i3 MEGA, Octoprint 1.3.9, Pi 3 B, Cura 3.6 without success. The position movements are excellent. Unfortunately the feed did not restart, even though the position and movement did. Happy to try again, and report back, if you want to suggest an alternative resume script.

    2018-12-07 at 9:58
    • yirco Reply

      Hi nigew
      thanks for sharing.
      I am still not very sure why it on some printers work and not on others. I do believe that it depends on the slicer. I use Prusa printers and Sli3r Prusa Edition which sets extruder to relative mode on the beginning.

      Recently I’ve found this article about relative/absolute extruder mode. Look at the beginning of your GCODE generated by Cura. Is there M83 or M82 on the beginning? Before the printing continues you have to set it back to the mode of your slicer. I will appreciate if you try this and let us know about the result.
      best regards

      2018-12-07 at 12:04
  • yirco Reply

    Hello guys,

    thank you all for sharing your experience. I suppose whether to use M83 or M82 in “before the print is resumed” depends on how the GCODE is generated. Each slicer can do it differently.
    Please let me know which slicer are you using and which M83/M82 works for you.
    If confirmed I will update the code with the comment.

    2018-12-07 at 12:19
    • tj Reply

      please let me answer this,
      Cura uses M82 actually,
      I change M83 to M82 and works properly.

      you are correct, this depends on the slicer and need to adapt M82 or M83. Default cura is M82 (absolute).

      mine is ender 3 and cura for slicer.

      2018-12-31 at 0:03
      • richard Reply

        hi tj

        can you help me out…
        i tried the code above and the hotend moves out of the way so i can change filament.
        but after resuming the print my hotend plunges into the print and keeps extruding.

        2019-02-24 at 15:37
    • Chris Reply

      M83 drove my extruder at hyperspeed 🙁
      I was using slic3r and my printer is using Marlin if that matters (Anycubic Kossel Plus)

      2018-12-31 at 0:09
  • Robert Reply

    Simplify3D, Ender 3, Octopi worked after switching to M82 per above… M83 resulted in over-extrusion. Thanks for the code! Once fixed, I was even able to turn off the printer for a long pause, leaving the Raspberry Pi powered, turn it back on and Octopi had the temp settings already on… after letting the temps ramp back to target, I was able to resume the print.

    I had been struggling with how to emulate the really useful resume print feature on the Ender firmware with Octopi. I think this handles most planned pauses, other than a surprise power outage.

    2018-12-28 at 23:41
    • Nacho Reply

      Hi! How? When I try this (I turn off the Ender leaving Raspberry on), Octoprint loses the conection and the file in progress dissapear, no options to resume when I turn on the Ender and reconnect.

      2019-05-21 at 15:58
      • Kris Reply

        It only looses connection if the PI cannot power the printer
        Make sure you are using a 2.1A power supply for your Pi

        2019-08-04 at 17:59
  • Carsten Reply

    copy pasted the code while doing a job, this should work though.

    did a pause, and the head didn’t move, changed filament and resumed.
    Now that it’s still printing, it’s really slow.. approx 10 times slower.

    Using Anet A8, with latest marlin firmware, slice job is using sli3r.

    2018-12-31 at 23:14
  • Frode Reply

    FLSUN cube, Cura, Octoprint 1.3.9 – Modifying to M82 worked like a charm.
    Thanks all

    2019-01-06 at 13:18
    • Carl Hilinski Reply

      M82 is correct for a MP Maker Ultimate. With M83, the extruder doesn’t feed.

      2019-02-01 at 4:00
  • zaped212 Reply

    The M82 vs M83 debate is not about the printer, its about the slicer.
    If your slicer generates absolute extruder moves, then it should be:
    ; absolute E
    ; absolute XYZ
    Note I do not recommend the M82 after the G92 as some firmware may reset E to 0 when this happens.

    If your slicer genreate relative extruder modes then it sould be:

    ; absolute XYZ
    M83 ; extruder relative mode

    Once I tracked that down it started working for me.

    2019-02-14 at 5:00
  • richard Reply

    can you help me out…
    i tried the code above and the hotend moves out of the way so i can change filament.
    but after resuming the print my hotend plunges into the print and keeps extruding.

    2019-02-24 at 15:38
    • yirco Reply

      hi Richard

      what’s your printer and slicer?

      2019-02-24 at 15:42
  • Michael Scholz Reply

    I’ve found that setting the park position of the extruded to something like 5,5 instead of 0,0 gives better results on printers with mechanical endstops because of the slight variation on triggering. If it’s relying on the stops to park at 0,0 then there can be some layer shift on resume. Parking with a software stop slightly away from the actual stops have given me perfect restarts on my ender 3 pro

    2019-03-28 at 4:42
    • Andy Reply

      Thank you for this!

      2019-08-09 at 21:22
  • Filipe Reply

    thanks. worked fine on my ender 3 using cura. just changed to M82 on the Warning part.

    2019-04-17 at 20:53
  • Digdogger Reply

    works for me on Alfawise U20 and Simplify3D but warning with M82 because with M83 the motor will suddenly race and the filament goes out withe a crazy speed… Be carrefull!

    2019-05-08 at 19:02
  • da4throux Reply

    That sounds really great, I need to test this 😀 Thanks a bunch.
    I was wondering: what kind of issue could I expect if I use this for a long pause (8 hours to allow quiet time during the night) ?
    Am I right assuming, that Octopi might lose connection or reset, and then nothing can be recovered ?
    Any advice on that would be great.

    2019-05-22 at 23:31
  • Anton Reply

    I used M82 and it works like a charm! Genius! Thanks a lot for this piece of code! I injected the two code snippets during a running print on my Anycubic i3 Mega, with no test upfront, and it worked just perfect. Used it a couple of times more in further prints, I am really glad with this.
    Gives me a chance for some kind of basic multi color prints, and when running out of filament, I can now change.

    Just one little question. Would it be possible to tweak the code a little bit, so it pauses >>at the next z layer change<< ? That would make it even better and just perfect.
    Just asking, just in case. I find it very useful already.

    2019-06-12 at 17:51
  • Josh Reply

    So how do you actually set it to pause at a given height, which would then run the “after pause” script and allow me to change the filament? Or, do I have to pause manually?

    2019-07-21 at 23:43
    • yirco Reply

      Hi Josh,

      you have to stop it manually using Octoprint. Not on the printer itself! To pause automatically at a given height, try to find Octoprint plugin or prepare .gcode before print to stop at given height. I know Prusa has a description on their web pages. May be the newest Slicer Prusa Edition supports it too.


      2019-07-23 at 11:25
  • Stefan Foulis Reply

    Awesome, thanks! This worked great. This saved a 10h print I was running. I was relieved to find out that it was possible to add the scripts in octoprint even though the print was already in progress.
    As mentioned in the snippet I checked if my slicer produces GCODE with M83 or M82 and adjusted the value.

    2019-09-23 at 8:58
  • phil Reply

    you just saved 5h print
    gotta love that code for color change too thanks

    2019-10-13 at 23:15

Leave a Reply

Your email address will not be published. Required fields are marked *