G-code in the browser

Technical · November 2024

MakeUC 2024

Kinetic Vision ran the 3D printing challenge at MakeUC 2024, and I did this one solo. G-code is the language printers actually execute, and editing it by hand means scrolling a text file with thousands of coordinate lines and guessing what they draw. I wanted assembly and preview in the same place.

G-Code-Assembler is a web tool where you compose G-code, watch the toolpath render in real time, and export a watertight STL when you're done. There's also a notebook path for people who'd rather script the whole thing. It won the Kinetic Vision challenge, my second of their prizes after the robot arm the year before.

G-Code-Assembler

Watertight was the hard requirement. A mesh with holes looks fine on screen and then a slicer refuses it, so the export path got most of the weekend.

Technical

Flask handles parsing and the mesh transforms, React with three.js draws the toolpath as you edit, and the STL exporter is careful about manifold geometry so the output survives a slicer. Setup is one script. The demo is on YouTube.

A seven layer square spiral toolpath parsed and drawn per layer

Per layer extrusion length profile of the toy toolpath