Skip to content
OllisGit edited this page Jun 1, 2020 · 2 revisions

How does it work?

The slicer settings were read out of the selected gcode-file after the print is done.

Settings were recognized by this pattern: ; key = value E.g.

; top infill extrusion width = 0.40mm
; first layer extrusion width = 0.42mm
; max_fan_speed = 100
...

Some slicers provide such comment-settings out of the box (e.g. PrusaSlicer), but others don't (e.g. CURA)

Handling special comments

Generated by

If a comment line includes the word enerated, it is also interpreted as a settings-value E.g.

; generated by PrusaSlicer 2.2.0+ on 2020-05-30 at 20:39:21 UTC

SETTINGS_

CURA create a settings-sections with json-fragments. The parser ignores this. The comment is started with ;SETTING_ E.g.

;SETTING_3 {"global_quality": "[general]\\nversion = 4\\nname = Fine #2\\ndefini
;SETTING_3 tion = custom\\n\\n[metadata]\\nquality_type = normal\\ntype = qualit
...

CURA configuration

To add slicer-settings to your gcode file, you can use a pre-processor or you use the Start-, End- G-code section of your printer settings. You need to add the variables you want to extract into the gcode. E.g.

; layer_height = {layer_height}
; line_width = {line_width}

A ready to use list could be found here An overview of all possible values with a description can be found here and here

Technical implementation

For performance reason the settings parser reads the file from the "top" and from the "bottom" (inspired by a discussion with @FormerLurker and @tjjfvi, see here for more details).

It starts with parsing from the top, after the parser detects a block of gcode commands (default block size 10 lines), it switch to the bottom. Here is the same behaviour implemented, parse until you reach a block of gcode-commands, then stop.

So, most of the file is not parsed only a few lines from the top and from the bottom. E.g.

; key1 = value1
; key2 = value2
; key3 = value3
M117...
; key4 = value4
G123
G321 
+ 10 other gcode lines in a row

Result: Slicer-Settings include 4 keys

Future features (only ideas)

  • Store only selected key-values
  • Query a job for keys
  • Compare job slicer-settings
  • ...