Skip to content

Just some simple Python functions to provide an API to make extracting/comparing slicer config values (in gcode) easier.

Notifications You must be signed in to change notification settings

jhyland87/gcode_slicer_diff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gcode Slicer Config Parser

Just a simple Python API server for parsing Gcode files to retrieve the metadata and slicer config settings from the Gcode source. Can be used to just retrieve the meta data, or compared with other gcode files to assess any slicer changes made between prints.

This is intended to be installed on a RaspberryPi with Klipper. It currently only looks at local files, but the logic is implemented in such a way that gcode files retrieved via HTTP can easily be parsed as well (it's just not necessary right now).

Slicers

Right now it only parses out Prusa sliced Gcode files, though I am working on setting up a slicer base class to be used as an interface for slicer-specific classes, which will make comparing gcode files generated from different slicers possible (similar to how the metadata is handled in MoonRaker)

Run

uvicorn server:app --reload

Examples

Parse header via http://127.0.0.1:8000/gcode/prusa-sliced-2.gcode/header/parse Full parsed header output here Parse header

Parse footer via http://127.0.0.1:8000/gcode/prusa-sliced-2.gcode/footer/parse?cast=true Full parsed footer output here Parse footer

Compare two gcode configs via http://127.0.0.1:8000/gcode/compare/prusa-sliced.gcode/prusa-sliced-2.gcode?cast=true Full comparison output here Compare gcode configs

ToDo

  1. Properly setup a base class parser that can be inherited and used when creating parsers for other slicers, similar to how Moonraker handles the slicer parser classes (metadata.py)
  2. Modify the routes to use search/query params for the filenames (or POST data) instead of /gcode/compare/{left_filename}/{right_filename}, so gcode files nested in other directories won't throw any errors.
  3. Add a feature to allow diffing of more than 2 files.
  4. The functions used to read and parse the gcode files (gcode_utils.py) need to be updated to use generators. And for parsing the footer, it will see a great improvement if the file is just parsed in reverse order, instead of grabbing a specific amount of data from the end of the file to parse line by line. POC Of this improved method is here, with a screenshot of the comparison below: New footer parser comparison (Using a generator is more than 1.6 seconds faster with test files)

About

Just some simple Python functions to provide an API to make extracting/comparing slicer config values (in gcode) easier.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages