G-code Preview
See the toolpath before you print — plans, meshes, or raw G-code, all in one preview
- plan
- mesh
- profile
- preview
- preview_info_json
- summary
- plan
You wouldn't commit an image to film without previewing it, and you shouldn't commit a toolpath to plastic without previewing it either. MKRGCodePreview is the pack's eyeball stage: it renders a visual of a G-code plan, a loaded mesh, or even raw G-code text, so you can catch a broken spiral, an off-bed move, or a heightmap that came out inverted before the export node writes a file.
What it takes
Everything is optional except a small settings_json (with view_mode and preview_size), because this node is designed to accept whatever you have. Give it:
- a
plan(MKR_GCODE_PLAN) - fromMKRGCodeSpiralVase,MKRGCodeHeightmapPlate, or the parsed output ofMKRGCodeExternalSlicer; - a
mesh(MKR_GCODE_MESH) - fromMKRGCodeLoadMeshModel; - raw
gcode_textor agcode_path- G-code from anywhere, not just this pack; - a
profile- optional, used to interpret raw G-code when no plan is connected.
view_mode defaults to auto, which picks the best render from what's connected: a plan alone gets a top-down path view, a mesh alone gets an isometric wireframe, and a plan plus a mesh gets a split view (plan on the left, isometric mesh on the right). Force plan_top, mesh_top, mesh_isometric, or split if you want a specific one.
The neat part: it parses raw G-code
If you connect gcode_text (or point gcode_path at a .gcode file) with no plan, the node parses it into a plan on the fly - tracking X/Y/Z/E, G90/G91 modes, feed rates, and layer comments - and renders that. That means you can paste in G-code that a different slicer produced and still get a preview plus a usable plan output for the analyzer. This is the node's hidden superpower: it makes external G-code a first-class citizen of the lane.
Outputs
preview(IMAGE) - the rendered view.preview_info_json- which mode rendered, plan stats, mesh triangle count, whether G-code was loaded, and warnings.summary- one line about what you're looking at.plan- the pass-through or parsedMKR_GCODE_PLAN, so preview can sit inline and hand the plan onward.
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.
Gotchas
If nothing useful is connected, you get a blank placeholder and a warning in preview_info_json - it won't crash, it'll just show you an empty box. So if your preview looks like nothing, the first place to look is the warning field, not the renderer.
Two rendering facts worth knowing. The plan render is a top view, so it's great for catching XY problems (travels crossing the part, off-bed moves) but tells you nothing about Z - an inverted heightmap that prints as a valley instead of a relief looks identical from above. Check preview_info_json's plan stats for layer count to catch gross Z mistakes. And the split mode renders the original mesh beside the toolpath, so you can compare what you asked for against what the path actually does - the single most useful check in this whole lane, and the reason to keep both inputs connected when you can.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| settings_json | STRING | {"view_mode":"auto","preview_size":768} | — |
| planopt | MKR_GCODE_PLAN | — | |
| meshopt | MKR_GCODE_MESH | — | |
| profileopt | MKR_GCODE_PROFILE | — | |
| gcode_textopt | STRING | — | |
| gcode_pathopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| preview | IMAGE | — |
| preview_info_json | STRING | — |
| summary | STRING | — |
| plan | MKR_GCODE_PLAN | — |