Skip to content

martinfrances107/gcode-nom

Repository files navigation

gcode-nom

Rust 2021 Edition.

A library containing a full set of nom parsers for decoding gcode files.

Based on this library the workspace contains a series of visualization tools

  • gcode2obj - Generates "WaveFront Obj" files.
  • gcode2svg - Generates SVG files.
  • gcodeExtractThumbs - Extracts the images embedded in a binary-gcode file.
  • bgcodeViewer - Generates a report by turning on all the logging and them attempts to parse the file.

I intend the parsers to be as strictly compliant as possible. This is under-going rapid development. Please create issues here, or send me gcode files which expose unimplemented sections.

For "binary gcode files" ['.bgcode' extension] the parser are streaming parsers.

See nom - "A byte-oriented, zero-copy, parser combinators library"

Tools

gcode2obj

Generates obj files.

Pass the gcode file into StdIn - the obj file is sent to StdOut :-

cd gcode2obj
cargo run --release -- < ./assets/bency.gcode > bench.obj

Which for example can be imported into blender for visualization.

Benchy in Blender Lego bricks Within blender :-

  1. This obj has been "Imported".
  2. Converted into a "Curve".
  3. Finally a circular bevel object has been applied to make the object solid [ A circle to represent a 0.1mm fibre].

gcode2svg

Generate svg files

Benchy in Blender

How to use

Pass the gcode file into StdIn - the SVG file is sent to StdOut :-

cd gcode2svg
cargo run --release -- < ./assets/benchy.gcode > benchy.svg

gcodeExtractThumbs

Extracts

bgcodeViewer

Strict checking of binaries. validates blocks checksums, ensures 'block' parameters values are within valid ranges.

Pass the gcode file into StdIn - A summary file is written to StdOut

cd bgcodeViewer
cargo run --release  < ../assets/both\ parts.bgcode > summary.txt

Future work

see TODO

A Bevy app?