Selecting the layer for the color change
The above image is what the CuteOcto.gcode file looks like. In the upper right corner, we can see that there are 85 layers. (Yes, the upper left says 86 layers, but it's incorrect. YAGV counts the pre-print movements as a "0th" layer.) This makes sense, because we can do the math with the part height and find the approximate number of layers.
16.75 mm * (1 layer / 0.2 mm) = 83.75 layers
Our guess is pretty close to the real deal.
Here's what the footprint of the CuteOcto looks like. Pretty much what you'd expect.
I think 30 layers up (see upper right corner) is a pretty good spot for the color change to occur. Here is what the 30th layer looks like- it's right below the eyes and will make for an interesting print.
Here's the filler_cube.gcode file. It's significantly closer to the green line (the X-axis) than the CuteOcto.gcode file, which makes sense, because we put it there to be out of the way.
And here's the footprint of the filler_cube.gcode file. As expected, there's no loop around the print and it is just a square.
Merging the files
Let's open the CuteOcto.gcode file (I'm using gedit, Ubuntu 15.04) and get ready to merge the two g-code files. First, let's search for the "LAYER CHANGE" comment that we put in when generating the g-code. It appears 86 times, or one more time than the number of layers that are in the file. This is because it appears in the comments section at the bottom of the print: Slic3r records the end-gcode in the bottom of the print as part of its normal operation. We want to get rid of this instance of "LAYER CHANGE", because it's confusing. So we'll delete it.
Now let's navigate to the 30th of the 85 instances of "LAYER CHANGE" that exist in the document (we want to switch print types at the 30th layer).
Let's change "; LAYER CHANGE" to "; LAYER CHANGE 30" on this line to make it easier to find later. Adding some space above it is also a good idea.
Now, let's take a peek at the filler_cube.gcode document. We're going to remove everything that would be included in a pre-print setup, such as nozzle cleaning, temperature settings, and axis homing, from the file- this way the insertion of the filler gcode won't affect the rest of the print.
This means deleting the first line all the way through the line before the first X-Y movement, which would be "G1 X36.678 Y64.000 F3000.000". So delete everything before this line.
Now insert the line "G1 Z50.000 F3000.000 ; lift nozzle to avoid main part" as the very first command. This will raise the Z-axis 50 mm, which is enough to avoid the 30 layer part that we printed out. (30 layers * 0.2 mm / 1 layer = 6 mm) It's only 6 mm tall, but the moving around won't hurt.
Now trim off the entire end of filler_cube.gcode after the last "G1 Zxxxxx Fxxxxx" command (in this case, "G1 Z6.250 F3000.000").
You must add "G92 E0" at the end. (This is an extruder measurement reset which occurs after each layer.)
After it, you can add "M107" - "fan off" - if you want.
It's mandatory, however, that you put in the same line from earlier at the very end-
"G1 Z50.000 F3000.000 ; lift nozzle to avoid main part" - so that the extruder lifts up and avoids any parts that have been printed as it moves back to the main CuteOcto form.
Now copy (control-c) the entire filler_cube.gcode file that you just modified.
Let's go back to CuteOcto.gcode. Go to the lines above the comment with "; LAYER CHANGE 30", and put your text cursor there.
Paste the clipboard (which has the filler_cube.gcode file contents in it) above the "; LAYER CHANGE 30" line. Save CuteOcto.gcode.
That should be it. Let's open the updated CuteOcto file with YAGV and see what it looks like. It's always a good idea to view hand-modified g-code before you print it, in case something strange happens.
Looks good! Layer 11 is on the CuteOcto part...
...and the lower part of the CuteOcto print is still printed all the way up through layer 29. At layer 29, though, the printer moves up 50 mm (the extruder tip follows the red line) and over to the filler_cube print...
Now we're seeing the filler_cube part get printed. At this point in the actual print, we would switch the filaments.
The filler_cube part continues to be printed...
The filler_cube part continues to print until the 59th layer, at which point the extruder has changed filaments completely. Now it lifts up 50 mm and moves back to the CuteOcto print.
Colors changed, the CuteOcto print continues.
And soon, it will have finished- a bicolor print.
Tune in next week for a real-life print test of this design!