Public: anyone can read this; the crew can change it.

A sliced .gcode file shows its toolpath one layer at a time, drawn on the server #10893

shipped production is serving it opened this has it
opened this

Before printing, the owner wants to see what the printer will do, with no JavaScript needed.

Done when:

  • [x] .gcode is a text kind in src/web/render/kinds.ts with a 50 MB cap. Over the cap, the page shows the facts and Download.
  • [x] A new src/web/render/gcode.ts parses G0/G1 moves (G90/G91, M82/M83, G92), groups the moves that extrude into layers by Z, and returns the facts: layer count, bounding box in mm, filament used in mm, and the slicer's estimated time when a comment states it (;TIME:, ; estimated printing time).
  • [x] The page draws one layer as server-rendered SVG, with extrusion as lines and travel moves faint. Previous/next links use ?layer=N, and a GET form takes a layer number, so it all works without script. Source and Download stay.
  • [x] Each blob is parsed once (cached by blob id), and a 10 MB file stays inside the blob page's budget.
  • [x] test/gcode.test.ts: a hand-written 3-layer square gives 3 layers, a 20×20 box and the right filament length. Relative and absolute extrusion agree. The SVG carries nothing from the file except numbers.

Files: src/web/render/kinds.ts, src/web/render/gcode.ts (new), src/web/render/renderers.ts, test/gcode.test.ts. It waits for the 3MF issue only because both edit kinds.ts.

commented

Reviewed pull #10915 at its head: ticked .gcode is a text kind in src/web/render/kinds.ts with a 50 MB cap. Over the cap, the page shows the facts and Download.; A new src/web/render/gcode.ts parses G0/G1 moves (G90/G91, M82/M83, G92), groups the moves that extrude into layers by Z, and returns the facts: layer count, bounding box in mm, filament used in mm, and the slicer's estimated time when a comment states it (;TIME:, ; estimated printing time).; The page draws one layer as server-rendered SVG, with extrusion as lines and travel moves faint. Previous/next links use ?layer=N, and a GET form takes a layer number, so it all works without script. Source and Download stay.; Each blob is parsed once (cached by blob id), and a 10 MB file stays inside the blob page's budget.; test/gcode.test.ts: a hand-written 3-layer square gives 3 layers, a 20×20 box and the right filament length. Relative and absolute extrusion agree. The SVG carries nothing from the file except numbers..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs