Can a specific X-offset be applied to a layer? I don’t want to have to manually offset each color layer.
Can the snapmaker controller send g-code commands to anything other than the programmed toolheads? That is, could a g-code command to change pens be sent over the CAN bus without changing the snapmaker firmware? Alternatively, is the stepper wire connection available without changing the firmware? It has been about 20 years since I’ve programmed in C++ so I’m trying to avoid firmware changes.
I guess without firmware changes you’ll have a hard time getting this running “out of the box” - at least I do not see an immediate solution with no changes. Aside from that, if you allow for firmware changes, basically everything is possible: The CAN bus can accomodate multiple participants, so you could create a “toolchanger” and integrate it into the system.
That said, there might be a much simpler solution: Do it like with CNC milling tool changes. Devide your picture into the individual colors, create G-Code for each color (like deriving tool pathes for different milling bits), Insert Pen 1, define (and mark) work origin, run job for Pen 1, insert Pen 2, align Pen 2 to exactly the same work origin as Pen 1, run job for Pen 2, repeat for Pen 3…n until done.
This is one of the biggest issues that I have with the firmware - if only they enabled the community to use the CAN bus. So many cool things could have been created.
In regards to your specific issue - look at other single extruders implementation of MMU. They control filament change with a additional switch mount on one of the axis + clever g-code for tool change using this switch.