Printing Multi-Colors with Any FDM 3D Printer Using Ultimaker Cura

Belal Krad
7 min readDec 31, 2020

One of the first questions that I had when I started my 3D printing journey was how can I print with multiple colors using a common typical FDM 3D printer with a single extruder? There are several methods that can be used to accomplish this. I intend to present here a simple method using Ulitmaker Cura along with slight modifications to the G-code. At first glance it may seem difficult however, once you go through the process and attempt it yourself, you will realize how simple it really is.

For the purposes of this demonstration, the printer I will be using is the Anycubic Mega X which runs with the open source Marlin firmware. Ideally any type single extruder FDM 3D printer can work with this approach. Depending on the type of firmware that is used, the coding of the g-code files may slightly differ but the concept will still remain the same.

After you have imported your .stl file into Cura and have sliced the model and made it ready for printing, click on the preview button to preview the layer layout:

Figure 1.0 — Click Preview after Slicing the Model

In this example, I plan on making the background plate of the letter A one color and then the letter A itself a different color. Next step is to look at how many total layers your sliced model has:

Figure 2.0 — See the Top Right Corner for Total Layer Count

Next, go through the different layers until you identify which layer number is the last layer of the plate (or first color) before starting the layers of just the letter A (or second color of your print).

Figure 3.0 — Layer 15 is the Last Layer Before Layers of Just the Letter A
Figure 4.0 — Layer 16 is the First Layer of Just the Letter A

It is important to identify which layer the filament color will be changed as we will need to update the G-code files accordingly. Next, click “Save to File” and save two versions of the G-code (copies 1 and 2). The plan will be to have one G-code file for the first print and the other for the second print.

Figure 5.0 — Click Save to File and Save Two Copies of the G-code
Figure 6.0 — Two Copies of the Exported G-Code Files

Next, it is best to have a good notepad editing tool in order to update the G-code files. I recommend Notepad++ as it is free and able to do what we need to do quickly. Open both files in Notepad++.

Figure 7.0 — Open Both Files with Notepad++

You should now see both G-code files as tabs opened with Notepad++.

Figure 8.0 — G-code Files Opened in Notepad++

The next step will be to divide the two G-code files between the first plate and the second which is just the letter A. The first step in this process will be to press Cntrl+F and find “layer:16” in the first G-code file(which is the first layer that the letter A is being worked in this example. It will vary depending upon what you will be printing).

Figure 9.0 — Locate Location of Layer 16 in the First G-code File

Once that has been located, highlight that row and then click at the top of the toolbar, Edit >> Begin/End Select.

Figure 10.0 — Select Begin/End Select for the Row Containing Layer 16

Next, scroll down to the very bottom of the G-code file. We need to select the row that begins the coding of completing the print. Look for the M140 command line with a printer running with the Marlin Firmware. Highlight that row containing the M140 command line.

Figure 11.0 — Highlight the Line Containing the M140 Command

Next, go back to Edit >> Begin/End Select and click it again. You should now see everything from Layer 16 all the way until the M140 command line highlighted. Delete all of these lines.

Figure 12.0 — Delete all of the Text Between Layer 16 and the M140 Command

We need to do two final things here with this first G-code file. First, we want to tell the 3D printer to not turn of the bed. Turning off the bed between both prints will cause warping on the bottom of the print as it will be going from heating to cooling and back to heating again rapidly. The second thing we need to do is to tell the 3D printer to keep the bed at the printing temperature. In my case for this example, it will be 60°C which is set for printing standard PLA.

With the M140 Command line, change S0 to S60 which will set the bed temperature to remain at 60°C. Also, delete the following M140 command line which is telling the bed to turn off. Save the file.

Figure 13.0 — Change the Bed Temperature to 60°C and Delete the Second M140 Command Line

Now for the Second G-Code file, we will need to do just two things. First, we will need to delete the earlier layers that have already been printed (in my case, layers 1–15). Second, we will need to tell the 3D Printer at which layer height to begin printing.

At the top of the G-code file, look for “Layer:0” (again assuming you are running with Marlin firmware). Select Edit>>Begin/End Select for the entire row.

Figure 14.0 — Begin/End Select for the Row Containing Layer:0

Next, Contrl+F to find Layer 16 again. This time we want to select everything before Layer 16 as opposed to after. After highlighting the entire row containing Layer 16 and clicking Begin/End Select, you can proceed to deleting all of the text.

Figure 15.0 — Delete Text Containing Layers 0 to 16

Finally, at the top of the G-code file, look for the command line mentioning where the printer will start printing from (ie how much the platform will be brought down to begin printing). In this case the printer has a standard start height of 15mm (Z value) meaning that the printer head will start 15mm above the base plate and move into positions after that for printing. In our case, we want to tell the printer from which height to begin.

Figure 16 — Update the Hight (Z value) for Where to Move the Platform and Begin Printing

To determine the height at which we would like the 3D printer to begin printing the second color, first determine the total height of the print. Cura shows that in the lower left corner of the model:

Figure 17 .0— Determine Height of the Print

Next, divide that by the total number of layers in the model (see Figure 2.0 above). That value should give you roughly the printer layer height (in my case almost 0.2mm). Finally multiply that value by the layer at which you will begin printing with the second color (in my case layer 16). So (6mm/29layers*layer16=3.31mm) and I will round up to the next tenths so 3.4mm. We will go back to the G-code file and update that line to reflect a Z value of 3.4mm.

Figure 18.0 — Updating Z Value to 3.4mm For Layer Hight

Now the printer will start the “second” print at the correct layer height of 3.4mm. Save the file.

Interestingly, as Cura previews the layers, it shows the layer count from 1 to 29 (in my case for this example). The G-code files however reflect Layer count from 0 to 28 (still 29 layers but numbered differently). So technically in my case, the letter A will begin on layer 15 in the G-code and not Layer 16 as was shown on Cura. I do not think this matters much. If you stick with the layer count in Cura you will get and additional layer with the base first color but the remaining layers will be the new color. It is up to you which layer you would like to divide the two up. Just make sure you do not print the second color on an earlier layer as that may ruin the print.

One final point to mention. Cura does have options now for including commands directly with one G-code file for filament swap out and multi color printing etc. You can also pursue those avenues, however I was having some difficulty getting them to work with my printer. This is just another option to consider.

Figure 19.0 — Modify G-Code Options for Including Code for Filament Replacement

That is about it. The only other thing to keep in mind is that between the first print and the second print the bed will stay on and heated so you MUST be near by when the first file is complete and ready to change the filament out so that it does not remain like that for a long period of time. Once you do this once or twice it becomes very repetitive and easy to do. Let me know what you think! Happy Printing!

Figure 20.0 — Finished Print!

--

--