#parser-combinator #gcode #obj

app gcode2obj

[Wavefront obj] Visualization tool for inspecting a g-code file

7 releases (4 breaking)

new 0.5.1 Apr 13, 2025
0.5.0 Apr 1, 2025
0.4.0 Mar 26, 2025
0.3.0 Mar 17, 2025
0.1.1 Dec 27, 2024

#116 in Visualization

Download history 288/week @ 2024-12-25 51/week @ 2025-01-01 32/week @ 2025-01-08 127/week @ 2025-02-12 11/week @ 2025-02-19 11/week @ 2025-02-26 91/week @ 2025-03-12 30/week @ 2025-03-19 182/week @ 2025-03-26 89/week @ 2025-04-02

392 downloads per month

MIT license

3.5MB
2.5K SLoC

gcodeToObj

Rust 2021 Edition.

crates.io Documentation

A G-code visualization tool written in rust

A nom based parser, outputs a "Wavefront Obj" file which can be imported into blender for visualization.

Both .gcode files and binary .bgcode files are accepted.

Performance

Currently 9.9MByte bgcode file can be processed into a 16MBytes obj file in 1.5secs.

[ See the git repository associated with this project... assets/gear-holder-print-in-place_04n_022mm_pla_mk4_6h49m.bgcode ]

How to use

Pass the gcode file in as 'StdIn' and the program will send the obj file to 'StdOut' :-

cargo run --release -- < ../assets/benchy.gcode > benchy.obj

Binary ".bgcode" files must be passed in by filename :-

## Binary bgcoode files must be passed in as an argument because they are not utf-8 encoded
cargo run --release --  ../assets/both\ parts.bgcode > both.obj

Here the obj files are imported in to blender and processed.

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].

Future work

  • Make this nom-parser a "streaming / zero copy" parser. So only a small fragment of the large files is memory.

  • I have only tested against gcode files that use absolute positioning.

  • I must test with code than uses relative positioning.

  • Convert "G5 - Bézier Cubic Spline" commands into the equivalent "obj" spline by defining a basis matrix. Support is not universal I could fall back to a series of line segments.

Dependencies