Custom G-code Editor
The Custom G-code module lets you import, edit, analyze, and debug real G-code inside 3dSynth. Whether you need to tweak slicer output, hand-author toolpaths, or understand exactly what a G-code file does before printing, this module gives you professional-grade tools without leaving the app.
Core philosophy
Three principles guide the Custom G-code Editor:
- G-code is the single source of truth. The editor always works directly on the G-code text. There is no hidden intermediate format. What you see is what the printer receives.
- Bidirectional editing. Select lines in the editor and see them highlighted in the 3D viewer. Click a toolpath in 3D and the editor scrolls to that line. Text and visualization are always in sync.
- Motion-first thinking. The system understands movement, extrusion, temperature, and time -- not meshes or slicer intent. This makes it useful for any G-code, regardless of which slicer generated it.
What you can do
- Import G-code files from any slicer (
.gcode,.gco,.g,.nc), Prusa binary G-code (.bgcode), ZIP containers (.3mf,.ufp,.zip), and thin mesh contours (.stl,.obj) - Edit with syntax highlighting, autocomplete, and hover documentation
- Analyze structure (layers, perimeters, infill), metrics (time, filament, flow), and warnings
- Visualize toolpaths with color modes (speed, flow, temperature, fan, layer, bead)
- Debug by stepping through commands line-by-line and inspecting full machine state
- Modify with precision tools (change speed, flow, temperature on any selection)
- Reorder sections safely with dependency analysis and automatic transition generation
- Snapshot versions of your edits and compare them with a built-in diff viewer
Supported firmware dialects
The editor auto-detects the firmware dialect from file headers and command patterns:
| Dialect | Detection | Notes |
|---|---|---|
| Marlin | Slicer headers, M900/M205 commands | Most common. Full support. |
| Klipper | printer.cfg references, {expression} syntax | Macro string parameters parsed; macros are never rewritten. |
| RepRap/Duet | RRF headers, M552/M586 commands | RepRapFirmware conventions. |
| Bambu | Profile name / dialect | Pause uses M400 U1, never M600. |
If the dialect can't be determined, the editor defaults to Marlin-compatible parsing. Unknown commands are flagged but never modified -- nothing is silently rewritten.
Supported file formats
| Extension | Description |
|---|---|
.gcode | Standard G-code (most slicers) |
.gco | Shortened G-code extension |
.g | RepRapFirmware convention |
.nc | Numerical control (CNC/legacy) |
.3mf / .ufp / .zip | Container — G-code entry extracted; original bytes are not stored |
.bgcode | Prusa binary G-code (deflate / heatshrink decode; encode uncompressed or deflate) |
.stl / .obj | Thin mesh → planar contours (no supports) |
Interface layout
When you select Custom G-code from the module picker, the left dock shows:
- Toolbar -- import, read-only, color mode (including fan, acceleration, extrusion rate, bead), travels/retractions/Z-hops, warning count, startup/end toggle
- Outline sidebar -- hierarchical section tree (startup, objects when present, layers, regions, shutdown)
- Monaco editor -- the same source the tools edit (
displaySource); drag-and-drop.gcode/.bgcode/.3mfonto the tab - Dock tools -- metrics (with charts), snapshots (diff), precision tools, diagnostics, resume-from-Z
The 3D viewer is overlay-only for this module: click/hover a segment, isolate a range, measure two hits, and use the action HUD. Playback clips the overlay with setDrawRange (it does not rebuild geometry every tick).
Getting started
New to the G-code editor? Start with the Tutorial for a guided walkthrough, or jump to any of these pages:
- Editor features -- syntax highlighting, autocomplete, selection, themes
- Analysis and visualization -- outline, metrics, color modes, playback
- Tools and debugging -- precision editing, batch operations, reordering, debugger
- Warnings reference -- warning codes explained with examples
- G-code command reference -- every G/M command the editor recognizes