Latest update to blog 6th Jan – multi colour printing without wipe and prime towers.

Before I launch into this, it occurs to me that people not familiar with mixing hot ends might be confused when I talk about tool changes. I explain how to define tools in another post, so I won’t go into it again here. Just be aware that a tool change and a colour change are one and the same thing, so I apologise if might use the terms interchangeably.  Also of course, “colour” and “color” are the same thing but I’m English so to me it’s “colour”.

As I reported earlier, I found an issue with the original script when tool (colour) changes were close together. Having looked again at my feeble attempt to write code, I did find the problem – in fact I found a few.

The main issue was that the script would not move a tool change to a position earlier than the previous tool change. On the face of it, that seems logical. However, the script didn’t “remember” that the previous tool change itself had been moved to an earlier position in the file. One way to think about it is a stream of commands with tool changes at various points and we need to move all these tool changes forward in the file by an amount equivalent to, (for the sake of argument) 2.5mm of extruded filament. It shouldn’t matter if there is only 1.0mm of filament between some of these tool changes as they will all be shifted by the same amount.

That was the main thing I needed to fix but while I was looking at the code, I found a couple of other problems. The first was that the way I segmented the moves was incorrect. That is to say that the new tool position is almost invariably somewhere in an existing “XYE” move so that move has to be split, the tool change inserted and then the rest of the move completed. So one line is replaced by two lines with a tool chnage command inserted between them. The amount of filament extruded (the “E” number) was correctly apportioned to each line but the corresponding X and Y amounts were not correctly apportioned.

The other thing I found was that the new lines could be inserted in the wrong place in certain circumstances. As an example, my machine is set to do very fast “non-print” moves so it might have a line something like “G1 X170.329 Y165.990 F21000.000” (a feed rate of 21,000 mm/min or 350mm/sec) followed by “G1 F4800” which sets the speed back down, in this case to 4,800 mm/min or 80mm/sec for normal printing. I discovered that in some instances, the script would put the new segmented moves and tool  change command after the fast non-print move but before the speed change back to normal command. This would have resulted in those two print moves being executed at 350mm/sec which would have been interesting to watch!

So I have deleted the link in the original post to the Python script and here is my latest feeble attempt. It does actually get the job done but I know any professional code writer will probably burst into tears if they see it.

To save a lot of copying, pasting and formatting of text, I’ve take a number of screen “snips” of the code. The comments should make it clear as to what I’m trying to do.









I haven’t included a link to the script this time but I’ll make it available if anyone is interested. Just leave a comment if you want me to do this.




8 thoughts on “Latest update to blog 6th Jan – multi colour printing without wipe and prime towers.

  1. I believe I’m following your logic well enough to understand the flow of things Ian….of course I’m lost in the programming but that will come with time. Thanks for taking the time to explain this all out in detail. How well did your changes effect the quality of your test prints?


    1. Hi Terry. That’s actually prompted my to do something. I thought that the test prints that I posted pictures of in my earlier post would not have been affected by the previous problems with the script. That is to say they had no tool changes that were close together and no issues with tool changes following fast non-print moves – just because of the nature of the printed object. However, it is possible that they may have been affected by the bug I found in the segmented moves so I’ll print a few more of those pieces with the new script and see if there are any differences. Ian


    1. Hi th0mpy. Things have moved on quite a bit since I wrote that post but I’ve been too busy to update my blog. The good news is that I’ve finally ironed out all the bugs so the script itself works well. The bad news is that since I’ve been playing around with the 5 colour Diamond, I’ve discovered a few things that mean it may not really be a viable thing to do. I plan on doing a write up about the 5 colour Diamond once the TCT show is out if the way, which will explain more fully.
      BTW, I checked your blog and ecigs work for me. Ian


  2. Dear Ian,

    I left a message to you on Duet3d Forum and leave same here for your help.
    Thanks for the suggestion of brake motor for my steep helix ball screw. M’time I just realized that you are the person who gave me idea of multiple colour print with Diamond hotend and Duetwifi and I’m now carefully reading your articles on your website with much thanks but something difficult to understand for me as I’m new at multiple colour and python.

    I guess it needed 3 gcode files of (“test.gcode” for source file, “output.gcode” for destination file, “temp.gcode” for temp file) in order to print Julia vase etc. But It’s hard for me to divide the code on your articles of your website to 3files above and not sure where to set those 3 files on Slic3r.

    I just guess these 3files save on my desktop and set the path(s) on “Print setting – Output options – Post-processing scripts” but not sure what to put on “Print setting – Output options – Output file – Output filename format”.

    I feel it’s quite genius idea using script but it’s hard for me to setting, so I’d like to ask something about that as follows.

    1. Could you e-mail for those 3 files, or advise divisions of 3 files on your article?
    my e-mail :

    2. Could you advise correct setting of Slic3r to apply those 3 gcode files?


    Thanks a lot.


  3. Very fascinating. I’d definitely love the opportunity to play with the code mostly to learn from it.. I just ordered my 7th Printer this one has a quad extrusion setup and uses the duet maestro


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