Matthew Harrison - Apr 25 2017

Printing multiple colours or materials using a single extruder

3D printed Matt's Hub logo using multiple colours

Update: As of Slic3r Prusa Edition version 1.42, the colour change feature is now built in to Prusa Slicer. I recommend using this for colour changes instead of manually editing the gcode, unless you need to change the hotend temperature.

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.

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 / prusa slicer only

If you're using slic3r, you'll need to insert a custom layer change G-Code command 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 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] is your desired layer number and [z height] is your desired z height.

Slic3r / Prusa Slicer

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 this 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!

More resources for you

E3D V6 Assembly Guide Poster

Jan 28, 2023 Matthew Harrison

How To Create a Voronoi Sphere in MeshLab

Jan 28, 2023 Matthew Harrison

Orientating Parts in Meshmixer

Jan 28, 2023 Matthew Harrison
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.