G-code Export
Turn a plan and a profile into a .gcode file
- plan
- profile
- gcode_text
- output_path
- summary
Every generated toolpath eventually needs to become a file your printer can read. That's MKRGCodeExport: it takes an MKR_GCODE_PLAN and an MKR_GCODE_PROFILE, renders the whole thing into printable G-code, and saves it to disk. It's the terminal node of the G-code lane - the thing every spiral vase, heightmap plate, and sliced mesh eventually flows into.
How it works
Given a plan (the move list with extruding/travel segments, roles, and layer tags) and a profile (geometry, speeds, temps, start/end G-code), it assembles the file: your profile's start_gcode block at the top, then every move as G1/G0 lines with feed rates and extrusion amounts derived from line width, layer height, and the extrusion multiplier, then end_gcode at the bottom. The object is placed on the bed according to the profile's origin mode (center vs. lower-left), and if the profile's start/end blocks are blank, it falls back to a generic startup sequence.
The include_comments toggle (default on) adds ; LAYER: and role comments into the output. Those look like noise, but they're load-bearing: MKRGCodeConditionalInjector needs the layer markers to fire layer-change rules, and MKRGCodePreview/the analyzer use role comments to classify moves. The README is explicit - keep include_comments on if you plan to inject calibration or conditional macros later in the graph.
Inputs that matter
planandprofile- both required. No plan, no export.filename_prefix(defaultMKR_gcode) andsubfolder- where the file lands, relative to ComfyUI's output directory.save_file- defaulttrue; flip it off to just get the text without writing anything.overwrite- defaultfalse; when off, the node picks a non-colliding filename rather than clobbering an existing one.filename_label- an optional override that takes priority overfilename_prefixfor the actual name.
Outputs
gcode_text- the full generated G-code as a string, so you can route it into a post-processor likeMKRGCodeConditionalInjectoror a text saver without ever writing a file.output_path- the absolute path of the saved file, whensave_fileis on.summary- a JSON string with the output path, plan mode, line count, total extrusion in mm, and estimated print time in minutes. That last number is your "how long is this print" answer, computed from path lengths and speeds.
Installing it
Part of the pack:
# ComfyUI Manager: search "MKRShift Nodes", install, restart.
# or:
cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes
# restart ComfyUI
No extra dependencies. This node is pure text generation - no ffmpeg, no slicer, no models.
The flow, end to end
A complete graph looks like:
MKRGCodePrinterProfile ──┐
├──→ MKRGCodeExport → MKRGCodeConditionalInjector → save
MKRGCodeSpiralVase ──────┘
Run it, check the summary for estimated time and extrusion, glance at output_path, and that's a printable file. Two habits save filament: preview the plan before exporting (MKRGCodePreview), and run MKRGCodePlanAnalyzer on it for flow and bed-fit warnings. The export node happily writes whatever you give it - it's the last line of defense, and it assumes you already did the checking upstream.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| plan | MKR_GCODE_PLAN | — | |
| profile | MKR_GCODE_PROFILE | — | |
| filename_prefix | STRING | MKR_gcode | — |
| subfolder | STRING | — | |
| save_file | BOOLEAN | true | — |
| overwrite | BOOLEAN | false | — |
| include_comments | BOOLEAN | true | — |
| filename_labelopt | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| gcode_text | STRING | — |
| output_path | STRING | — |
| summary | STRING | — |