Printing multiple colours or materials using a single extruder

Printed logo

If you’re looking to change colour or materials part way through your prints, the best way to do it is with an M600 command placed in your G-Code.

If you’re not using z-hop in your slicing software and you’d just like to change colour, you can easily insert the M600 command wherever you’d like in your print using Prusa’s ColorPrint website. This way you don’t need to open up the file in a text editor or anything, it’s all done behind the scenes. Just upload the G-Code and select the z height at which you would like the change to occur.

The issue with ColorPrint and using z-hop in your gcode is that ColorPrint works by detecting the z movement commands and enters the M600 every time the printer goes to the specified z height. This can be multiple times when you’re using z-hop as the print head is moving up and down a number of times on a single layer (depending on how many retracts that layer has).

If you’re wanting to switch to a different material with a different temperature requirement or your file does include z-hop, then you’re going to need to open up your .gcode file in a text editor and insert the M600 command (and temperature change if needed) manually.

Before you slice – Slic3r only

If you’re using slic3r, you’ll need to insert a custom layer change G-Code so that later on when we look through the code, you’ll be able to spot the layer where you want to insert the M600. Without this, it will be a lot harder to tell the difference between a z movement that is used for z-hop, and a z movement that is used for a layer change. In slic3r, navigate to Printer Settings > Custom G-Code. In the “After layer change G-Code” text box, paste in the following line:

; LAYER: [layer_num], Z HEIGHT: [layer_z]

This tells slic3r to put a comment into the code every time there is a layer change, showing what layer number it is and what the z height of that layer is. If you’re using Cura or Simplify 3D you won’t need to do this as comments like these are automatically inserted.

Finding where to insert the change

To find where to insert your filament change in your file, you’ll need to know the layer number that you want to switch at, or the z height of that layer. Open up your .gcode file in your favourite text editor (or just notepad if you don’t have anything else), and open up the search command. The search terms to use for each slicing software to search for a particular layer number or z height are as follows, where [layer number] and is your desired layer number and [z height] is your desired z height.

Layer number: “LAYER: [layer number]”
Z height: “Z HEIGHT: [z height]”

Simplify 3D
Layer number: “layer [layer number]”
Z height: “Z = [z height]”

Layer number: “LAYER:[layer number]”
Z height: Search for “Z[z height]”. It should also be right below a line stating the layer number. If not, it’s not a layer change and it’s z-hop instead. Keep searching until you find the one that is below the layer number line.

Inserting the filament change code

Now that you’ve found where you want to change your filament, we need to insert the M600 command. M600 is a G-Code command that tells the printer to move the nozzle away from the print and retract the filament, ready for us to load a different filament in. Right after the line in the G-Code that tells you what layer it is up to, create a new line and type M600. It’s as simple as that.

If you want to be really perfect about it, you can also remove the extruder priming code which can usually be found a few lines further down. It’ll look something like G1 E2.0000 F1800, with the number after E being your retraction distance and the number after F being your retraction speed in mm/min. This is usually used to feed filament back into the hot end after the retraction that it does before a layer change, but since our nozzle will already be primed after loading the filament in, it’ll just make a little blob on the print instead. Since Cura doesn’t retract on layer changes, this isn’t needed if you’re using Cura.

Inserting temperature change for different materials

If you’re wanting to use different materials with different temperature requirements, then that’s definitely still possible. Using the command M104 S[extruder temperature] where [extruder temperature] is the required temperature for the material that you’re switching to. The bed temperature should remain the same, as the bottom layers are already printed – and they’re the ones that are touching the bed.

Insert the M104 command on the line before the M600, so that the hot end is rising/falling to that temperature as you change the filament. It’s worth noting here that there is no enforcement to make sure that the hot end actually reaches that temperature before it returns printing again. So you can leave it for a few minutes when it’s asking you insert the new filament, just to make sure it gets there before you resume if it’s a large temperature change.

Here’s a snippet showing what a filament and temperature change (and the surrounding code) looks like with G-Code generated with Simplify 3D

G1 E-2.0000 F1800
G1 Z10.200 F1080
; layer 50, Z = 10
M104 S255
; tool H0.200 W0.450
; inner perimeter
M204 S1200
G1 X92.966 Y77.869 F12000
G1 Z10.000 F1080


Once you’ve got the G-Code all set up, you can save it and start printing it. When the printer stops for a filament change, you can just load the new filament and then resume the print. The print shown in the picture at the top of the page was printed with white PLA, and blue and black PETG. The temperature change worked flawlessly and it just continued printing like normal. If you’ve got any questions or run into any problems, leave a comment and I’ll do my best to help you out!

15 thoughts on “Printing multiple colours or materials using a single extruder

  1. Hi Matt, I know this is a pretty old post but would you have any idea why a print would shift the layer when it resumes after a color change. I used Prusa’s ColorPrint and this is the code generated:

    G1 X119.645 Y110.355
    G1 Z77.800
    G1 E0.80000 F2100.00000
    M204 S1250
    G1 F900
    G1 X130.355 Y99.645 E0.51268
    M204 S1000
    G92 E0.0
    G1 F8640
    G1 X128.028 Y101.972 E-0.76000
    G1 E-0.04000 F2100.00000
    G1 Z78.400 F10800.000
    G1 X130.405 Y99.590
    G1 Z78.000
    G1 E0.80000 F2100.00000
    M204 S800
    G1 F900
    G1 X130.946 Y100.185 E0.02721
    G1 X131.379 Y100.776 E0.02481
    G1 X131.784 Y101.463 E0.02698

    but the layer shifts slightly right and is not in line with the print.

    I actually have 2 color changes on this print and the second change lines up perfectly. I tried different sized prints and different position of the layer change and still the same. It is only for this specific print that it happens and I cannot figure out why. Any ideas?


  2. Hello Matt~
    Is it possible to get the print to stop after the very first layer outline? I want to lay the first outline in a certain color, stop for a color change, and then continue printing the infill a new color. Will the M600 command work after an outline or does it only work for a layer change? Thanks!


    1. Hi there! Yes it is indeed possible to do this. The M600 command will work exactly the same no matter where you place it, but the main issue is finding where in the gcode to place it. To do this, I use the website Navigate through the layer that you want to edit with the horizontal slider, and stop at the point where you would like the colour to change. Then click on the gcode view tab and it will have skipped to that line in the gcode for you.

      Then it is just a matter of opening your gcode file in a text editor, skipping to that line, and inserting the M600 command. I might make another blog post about doing this soon


  3. This is possibly covered in your piece, but I didn’t see it. How does one resume the print after the filament change. I successfully found the correct layer, added the M600 line, moved the printhead, paused the print, changed the filament, but found no way to resume the print. Is there a gcode command or something that says “go back to where you were and continue”?


  4. G1 X38.825 Y117.549 E12.40260
    LAYER: 14, Z HEIGHT: 2.35
    G1 E10.40260 F2400.00000
    G92 E0
    G1 Z2.350 F7800.000
    LAYER: 14, Z HEIGHT: 2.35
    G1 X35.178 Y113.195 F7800.000
    G1 E2.00000 F2400.00000
    G1 F3600
    G1 X35.178 Y127.957 E2.42369

    Hi Matt, yes it was unchecked. where would i put the M600 command exactly, in my example?


    1. Hi Melvin. That’s odd that it’s showing the layer 14 comment twice.. Did you only put it in the “after layer change gcode” text box? Anyway, in this case the M600 command would be located after the second line that reads “LAYER: 14” etc.

      Another important note is that you’re missing the semicolon “;” before the lines that say the layer number and layer height. The gcode won’t work properly without that in it


      1. Hi Matt

        thanks again it works perfectly now.
        some thing interesting i see in the code from
        they put the M600 before the ; LAYER: 1 ect command.

        G1 E84.05427 F2400.00000
        G92 E0
        G1 Z0.950 F7800.000
        ; LAYER: 1, Z HEIGHT: 0.95
        M104 S200 ; set temperature
        G1 X134.047 Y144.047 F7800.000
        G1 E2.00000 F2400.00000
        G1 F3600
        G1 X115.953 Y144.047 E2.95474


  5. Thank you Matt,
    Great tutorial. I can’t seem to find the following code you mentioned. G1 E2.0000 F1800
    I am using Slic3r 1.36.1 to slice my objects, then Repetier-Host V2.0.5 to edit my G-Code. where would I find it?


      1. G1 X38.825 Y117.549 E12.40260
        LAYER: 14, Z HEIGHT: 2.35
        G1 Z2.350 F7800.000
        LAYER: 14, Z HEIGHT: 2.35
        G1 E10.40260 F2400.00000
        G92 E0
        G1 X35.178 Y113.195 F7800.000
        G1 E2.00000 F2400.00000
        G1 F3600
        G1 X35.178 Y127.957 E2.42369


    1. You may also have retract on layer change switched off (visible in printer settings > extruder 1). If retract on layer change is off, then this line won’t be there at all


  6. instead of the M104 S255, you could use a M109 S255… This way it will wait for the temperature to be reached before it moves away from the print and unloads the filament.


    1. That’s true, but then the nozzle will remain idle over the print and ooze plastic. The idea is to get it away from the print as soon as possible so that it doesn’t leave any marks


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s