Started to manually add the M163 codes I use to control filament weight values into some gcode.
Found a suitably hackable python based gcode viewer called yagv and adapted it to speed this process up for more complicated objects. It lets me visualize the resulting mixed filament, and quickly find the next location in the gcode file I need.
I assigned each filament an RGB value in config.cfg
- [255,0,0] - red
- [255,255,0] - yellow
- [0,0,255] - blue
- [0,0,0] - black
- [255,255,255] - white
The viewer reads the gcode file tracking the changing filament weight values, combines them with the defined filament colors, and renders the resulting mix per segment.
Setting a weight of 50/50 for a red/white filament would end up being [255,123,123] and render pink in the interface. Close enough.
Right mouse button + drag moves forward/back in time simulating the extrusion, or you can use a wealth of keyboard shortcuts.
An interactive gvim session is kept in sync with extrusion playback so you can go directly to the line being rendered with a mouse-click.
Pressing R, saves your changes in gvim, and re-draws the object calculating the new mixing for the object.
So I'm still modifying the gcode in a text editor and adding my color weight information manually at this point, but this just got a whole lot faster.
I've added everything I've needed as keyboard shortcuts. You now can edit the entire file in the one interface, without your fingers leaving the keyboard. (provided you setup your colors as macros in config.cfg)
The cool thing about this approach, is I could load up 4 different shades of blue and a pink, and still get an accurate estimate of what it would look like because the filaments slots aren't tied to a specific color. The interface just shows the weighted sums of the result.
My code is now up on Github for all experienced python programmers to scoff at. :)