HACKNov 2024
G-Code Assembler — rebuilding a shape from printer instructions
I was too tired to do another hackathon project. Then I noticed Kinetic Vision had a 3D printer as the prize, and only one other three-person team was competing in the category. So I changed my mind.
I'd worked with inkjet-printer firmware before, so the problem felt a lot more familiar than most hackathon prompts did by then. The challenge was to reconstruct a 3D object from G-code.
A printer never needs the original CAD model. It only gets the instructions it needs to make the object: coordinates, extrusion, layer heights and travel moves. So the shape is in there, just backwards.
I treated the depositing moves as physical filament again, rebuilt the volumes, joined them, and exported the result as an STL. I did this one solo, so I have a lot of implementation detail if I ever want to get into it.
Here's the assembler running in the browser, with no server. I rebuilt it in 2026. Next to the hackathon's box mesh it now makes one closed solid out of the printed beads, within about 1% of the challenge's own CAD models, and it reads G-code from Bambu, Prusa, Cura and other slicers.
| G-Code Assembler flow |
|---|
| G-code file |
| ↓ |
| Command parser |
| ↓ |
| Motion + extrusion + layer state |
| ↓ |
| Depositing segments selected |
| ↓ |
| Path segments converted to filament volumes |
| ↓ |
| Boolean union / overlap handling |
| ↓ |
| Layer-transition smoothing |
| ↓ |
| Watertight mesh |
| ↓ |
| React / three.js preview |
| ↓ |
| STL export |


Flask handled G-code parsing and the mesh transformations. The parser pulled out movement coordinates, extrusion values and layer state.
Travel moves were left out of the geometry. Depositing moves were turned into volumetric filament segments.
Neighbouring segments were joined with boolean operations. Overlap correction accounted for filament volumes that intersect.
Additional geometry went in around layer transitions to smooth the rebuilt surface, with stronger correction around steeper slopes.
React and three.js rendered the preview, and the final mesh was exported as a watertight STL.
Large input files made meshes with millions of nodes. One hackathon example was big enough to use up all the memory on a 3090 Ti.123
I wanted the printer. I also felt pretty good about 1v3'ing the other team, because this happened to line up with things I'd already touched.
We won the Kinetic Vision challenge, and I got the printer.