Posted on

Wipe & Prime Towers for Slic3r


Printing with dual extruders can be somewhat of a tedious task. Fortunately or unfortunately, there are many different aproaches all aiming to easing up dual extrusion or multicolor or multimaterial printing. I tried almost all of the half assed solutions out there, but ended up writing my own gcode post processor, here it is.

The setup

For all tests, smartABS was printed at 255 °C with a bed temperature of 100 °C while the first layer temperatures are slightly higher at 275 °C for the hotends and 110 °C for the bed.

I am using two E3Dv6 on my SuperMount hotend holder, which sets the hotends quite far (68mm) from each other. I prefer this setup, because with 68mm between the nozzles, I can print at least 68×180 mm objects in two colors without the idle extruder travelling over the currently printed layer, which is something that you won’t get with i.e. an E3D Chimera hotend.

I like the idea of the color switching hotends like the E3D Cyclops or the Diamont Hotend, which I already ordered and will review as soon as it’s set up. For now, dual nozzle extrusion works great for me and there is no need to take compromises. After all, using two E3Dv6 Lite on a SuperMount would be darn cheap dual extrusion, wouldn’t it?

Slic3r #1

First off, I tried Slic3rs ooze prevention feature and I must say, the idea of letting one nozzle cool down is defenitely smart. Cold nozzles don’t ooze, and my E3Dv6 cools down quick enough to keep the initial ooze to a minimum. Unfortunately, it still takes quite some time to cool down, and since Slic3r will always print the ooze prevention wall with Extruder #0, I just had way too many tool changes to be happy with this solution. Also, the ooze prevention wall, which is basically a brim at full object height, pops off my PEI build platform just after a few laysers due to its own thermal bananaing. In addition to that, the ooze prevention wall keeps to much heat on the inside, causing deformation to the actually printed object.


After getting nowhere with Slic3rs dual extrusion features as described above, I went over to challenge Cura with that. Cura’s Wipe & Prime towers are simply amazing. Or better: Simple and amazing, and therefore follow the whole philosophy of Cura. Using Cura’s Wipe & Prime towers you get the usual Cura awesomeness, almost spotless dual color prints and a pretty ugly wipe tower. But, had I tried Slic3r before if I would not prefer Slic3r? Probably not, I still prefer Slic3r for it’s overall performance, and I already have finely dialed in settings for Slic3r that simply outperform Cura and it’s limited configurability.

Slic3r #2 custom G-code sections

Turn’s out Slic3r is still better then Cura (for me), just not for dual extrusion. So let’s fix that. My first thought was, adding Cura-style wipe towers to Slic3r is as easy as adding a bit of G-code to the layer change textbox in the Slic3r settings.

However, I quickly found out that each extruder has to drop some material onto the wipe tower at least every layer in order to avoid excessive oozing during longer idle phases, and even though cycling through all the extruders with Tn in the layer change gcode is possible, one would not be able to switch back to the acutally active extruder, since there is no such thing as an [active_extruder] [current_extruder] variable. So guess what Alessandro added in record-breaking 24h after my request. Thanks man, thats awsome! So now we can have wipe towers within the layer change G-code sections and wipes in the tool change G-code sections. Paradise. Yay!

Slic3r #3 Perl G-code postprocessor

Click here to get the current version of my wipe tower postprocessor for Slic3r on GitHub

What I found in the above adventures is, that Slic3r is awesome, Alessandro is also awesome, Cura is awesome in terms of wipe towers, and wipe towers are also awesome, and that wipe towers could be even more awesome if I implemented them a bit smarter than what’s possible with the static custom G-code sections. Like, the wipe tower layers should have varying starting points in every layer for avoiding the oozed material to accumulate in one corner.

Perl helps a lot getting nice wipe towers.

Also the wipes should happen from different angles at every wipe procedure, for avoiding the collection of the previously wiped off material. So I went translating my original Processing Java sketch that generated crude G-code lines into a nice little Perl script to post process Slic3r’s G-code as it comes during the export. And that I must say, really was it. From the first print on with those towers and wipings I see prints coming out perfectly spotless.

25 thoughts on “Wipe & Prime Towers for Slic3r

  1. Hi,

    I tried your scripts, but I can’t find any wipe towers on Repetier print preview. I used, copied it to a folder named test dual(D:\test dual) and followed everything as per instruction on GitHub
    1. in post processing scripts, given the directory name D:\test dual
    2. Edited start ,end gcodes, after layer change, and tool change gcode

    Can you tell me what’s wrong?
    Here’s the screen shots

    1. Hi Athul!

      To run a Perl postprocessing script on Windows, you need to install Perl (ideally Strawberry Perl) and set the $PATH variables correctly (Strawberry comes with a script for that). Then, you need to specify the full path to the script including the file name (in your case D:\test dual\ in Slic3r.

      If it still doesn’t work, especially on Windows 8+, there seems to be a bug in Slic3r that makes it hang when running the script (script runs forever). In that case, you can easily workaround the issue by calling the script manually from the command line à la “perl path/to/ path/to/printfile.gcode”. Hope that helps.

      All the best,

      1. H,
        Thnx for the reply. I don’t know how to do the following
        “set the $PATH variables correctly (Strawberry comes with a script for that)”
        ” In that case, you can easily workaround the issue by calling the script manually from the command line à la “perl path/to/ path/to/printfile.gcode””

  2. Hi Moritz,
    i tried to make that run with my Cyclops.
    Perl is installed (Strawberry) and i’m using Slic3r 1.2.9 on Windows 10 64 Bit.

    The Start G-Code suggested from you is inserted and also the other Things.

    But no Tower is there.

    A piece of the generated G-Code:

    [Edit: lengthy G-Code removed]

    By generating the G-Code a Pop-up Windows ask me to execute Perl. Therefore i think it’s well installed.
    Any sugestion from you?

    Best regards

    1. Hiya Siggi,

      Your G-Code snippet (I just removed that to avoid clutter) suggests that your code isn’t running through the script at all since the script adds its own header comment section. I’m afraid I can’t really support Windows installations at the moment, but an alternative could be leaving the custom start- and end-gcodes in place, exporting the G-code from Slic3r, and then manually running it through the postprocessor. This can be done by opening the command line tool and typing perl /path/to/ /path/to/gcodefile.gcode. Hope that helps!


      1. Moin Moritz,
        thanks for your help, but what is now wrong?
        Argument “” isn’t numeric in multiplication (*) at R:\Downloads\Primetower\Multi-Master\ line 759, line 21.
        Argument “” isn’t numeric in multiplication (*) at R:\Downloads\Primetower\Multi-Master\ line 762, line 22.

        G-Code Line 21+22:
        ; bedWidth=[bed_size_X]
        ; bedDepth=[bed_size_Y]

        Script v2 Line 21+22:
        my $bedWidth=160;
        my $bedDepth=165;

        Any suggestion?

        1. Hi Siggy,

          try replacing

          ; bedWidth=[bed_size_X]
          ; bedDepth=[bed_size_Y]

          with your actual bed size, e.g.

          ; bedWidth=200
          ; bedDepth=200

          in the start-gcode.


          1. It can be so simple 😀
            I tried changing that into the Script but not in Start G-Code.
            No Errors now.
            Big thx again, great work

          2. Glad you could make it work! Happy printing!

  3. Moritz, appreciate your hard work. This is a sorely missed feature in slic3r!

    I am having similar issues to those reported. I have carefully followed the included instructions, and thus far have not been able to generate a tower. I am using a test dual material print from thingiverse.

    When I attempt the instructions using the v2.0 Perl script, nothing happens. If I manually execute in Terminal (using Mac OSX), I get the error pasted below. If I manually execute the v1.0 script, it appears to parse through the entire gcode file and create instructions for the towers, but leaves the original gcode unchanged – how can I get these instructions to my printer?

    Bareword found where operator expected at /Users/jamesshin/Documents/Slic3r_scripts/ line 6, near “”en” class”
    (Missing operator before class?)
    Bareword found where operator expected at /Users/jamesshin/Documents/Slic3r_scripts/ line 26, near “Multi”
    (Missing operator before Multi?)
    Can’t modify numeric lt (<) in scalar assignment at /Users/jamesshin/Documents/Slic3r_scripts/ line 6, near ""en" class"
    syntax error at /Users/jamesshin/Documents/Slic3r_scripts/ line 6, near ""en" class"
    Unrecognized character \xC2; marked by <– HERE after at master <– HERE near column 92 at /Users/jamesshin/Documents/Slic3r_scripts/ line 26.

    1. Hey James,

      You accidentally downloaded an HTML file from GitHub. Please clone the repository and use the script from there.


      1. re-downloaded and re-configured according to the instructions – thanks for the n00b pointer.

        first test slice appears to be a success! slic3r doesn’t display the towers in preview, but the instructions are in the gcode and viewable through dedicated gcode viewer (

        very excited to start testing this on some complex multi prints!

  4. Hello Moritz,

    Appreciate your help! I am getting this error:
    21:01:53.025 : Can’t do inplace edit without backup at C:\Users\Garrett\Desktop\Multi-Extrusion-post-processing-scripts-for-Slic3r-master\ line 98.
    Could you please advise?


    1. Hi Garret,
      you have to insert this:
      $^I = ‘.bak’;
      into the Script.
      So it looks like that:
      # MAIN LOOP
      $^I = ‘.bak’;
      while () {

      1. Yes, exactly! Thanks!

  5. Hello

    Do you think it is possible to adapt you system to a printer with dual extruder & only one nozzle (with this part :

    Thanks for any help

    1. Yes! Also any other “Do you think it’s possible to..”. Yes!

      But it’s not as easy as it looks. Have a look at the work Prusa Research has done to get multi extrusion to work on a single nozzle.

    2. Hi Stephane,
      it will be much easier to buy a Cyclops. No hassle with large Retracts and only one Heater needed.
      So you can add an automatic Cooler on RAMPS 🙂
      They are cheap on Aliexpress.

  6. Halp!!! for some reason running this script stops each extruder from retracting when said extruder becomes inactive!!! I had it set up to do that before and now every print I try with these towers gets ruined due to ooze from whichever extruder is inactive. Possible bug?

    1. Not sure what’s causing this. Could you provide more information on your system and settings?

  7. I’ve been trying to get this script working with my printer, but it doesn’t support relative extrusion distances, is there a post processing script that can convert relative extrusion distances to absolute, or would it be possible for you to add that feature into your script?

  8. Hello Moritz,

    While trying this scripts I have some problems:

    wipe_towers_v2.pI: 09:24:26.367 : Can’t do inplace edit without backup at E:\3D_Druck\Software\Slic3r\WipeTower\Multi-Extrusion-post-processing-scripts-for-Slic3r-master\ line 98.

    wipe_towers_v1.pI runs in the commandtool and produces a lot of output, but no changes in the gcode-file. Also if I run Slic3r via Repetier Host, there are no changes concerning wipe towers in the produced gcode.

    I double checked custom gcodes and path.

    Do you have any hints to me?

  9. perl is new for me, get error messages with following statement:

    $^I = ‘.bak’;
    $I = ‘.bak’;


  10. Hmm, I get error –
    Argument “” isn’t numeric in multiplication (*) at line 759, line 106.
    Argument “” isn’t numeric in multiplication (*) at line 762, line 107.

    File is created but only 1/10 the size of the original.
    A lot of data is lost.

  11. Moritz,
    I fully agree with you that printing with two nozzles at the same high is normally impossible if you want quality.
    But printing on the way you do, with a big distance between the nozzles, is not necessary. I changed my dual head, a block with two nozzles and separate temperatures, in a system with movable heads, controlled by a servo. They move up and down about 2 mm, so they don’t affect each other. Both nozzles you can calibrate separate in high to the plater. The distance is 16 mm and I can make it even smaller. Now I can print different materials with different temperatures if I like. The signal for the servo comes from the board with a pwm AUX (ZRIB V3.2 > XS3).
    The problem is now how to tell the program to choose for 0 or 1 and give the command (ie. M340 P0 S720; set nozzle 0). In programs they choose the extruder (colors), but I need there the command as well. And of course put some filament like you do.
    I use Slic3r but I thought I could do that in the “Tool change G-code”.

Leave a Reply to Franz Maier Cancel reply

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