OctoPrint-SlicerSettingsParser

I have been trying to get this plugin to work with Cura.

The README have a solution to add all the data in the start/end code but I found a way to use the code that Cura adds by default.

Talked to the dev but he/she don't have time to get it to work.
Was told the plugin only support one regexp
I checked the code but I couldn't make heads or tail of it.

This regexp need to be run to get the values.

;End of Gcode[\s\S]+            # To select the data efter the gcode ( optional ) 
\n?;SETTING_3                   # To remove the end of line and SETTING_3
(?P<key>\w+) = (?P<val>[^\\]+)  # To get the settings and it's values 

So the plugin need to be able to do the remove data and select data.
Wounder if someone could help me out ?

I think Cura only attaches settings that have changed from the defaults. You won't get all of the settings this way. Also, regex will be VERY difficult to craft for those values.

If I'm not reading you right, maybe you can clarify a bit?

The original poster would probably like a JSON string as parsed out of the blurb at the end of a Cura-sliced file. I've thought about this before.

Example, in situ

;End of Gcode
;SETTING_3 {"global_quality": "[general]\\nversion = 3\\nname = Draft Quality #2
;SETTING_3 \\ndefinition = fdmprinter\\n\\n[metadata]\\nsetting_version = 4\\nty
;SETTING_3 pe = quality_changes\\nquality_type = draft\\n\\n[values]\\nadhesion_
;SETTING_3 type = skirt\\nrelative_extrusion = True\\nspeed_slowdown_layers = 3\
;SETTING_3 \n\\n", "extruder_quality": ["[general]\\nversion = 3\\nname = Draft 
;SETTING_3 Quality #2\\ndefinition = fdmprinter\\n\\n[metadata]\\nsetting_versio
;SETTING_3 n = 4\\nposition = 0\\ntype = quality_changes\\nquality_type = draft\
;SETTING_3 \n\\n[values]\\nbrim_line_count = 0\\ninfill_pattern = tetrahedral\\n
;SETTING_3 infill_sparse_density = 100\\nspeed_print_layer_0 = 10.0\\nspeed_trav
;SETTING_3 el_layer_0 = 30.0\\ntop_layers = 5\\n\\n", "[general]\\nversion = 3\\
;SETTING_3 nname = Draft Quality #2\\ndefinition = fdmprinter\\n\\n[metadata]\\n
;SETTING_3 setting_version = 4\\nposition = 1\\ntype = quality_changes\\nquality
;SETTING_3 _type = draft\\n\\n[values]\\n\\n", "[general]\\nversion = 3\\nname =
;SETTING_3  Draft Quality #2\\ndefinition = fdmprinter\\n\\n[metadata]\\nsetting
;SETTING_3 _version = 4\\nposition = 2\\ntype = quality_changes\\nquality_type =
;SETTING_3  draft\\n\\n[values]\\n\\n", "[general]\\nversion = 3\\nname = Draft 
;SETTING_3 Quality #2\\ndefinition = fdmprinter\\n\\n[metadata]\\nsetting_versio
;SETTING_3 n = 4\\nposition = 3\\ntype = quality_changes\\nquality_type = draft\
;SETTING_3 \n\\n[values]\\n\\n", "[general]\\nversion = 3\\nname = Draft Quality
;SETTING_3  #2\\ndefinition = fdmprinter\\n\\n[metadata]\\nsetting_version = 4\\
;SETTING_3 nposition = 4\\ntype = quality_changes\\nquality_type = draft\\n\\n[v
;SETTING_3 alues]\\n\\n", "[general]\\nversion = 3\\nname = Draft Quality #2\\nd
;SETTING_3 efinition = fdmprinter\\n\\n[metadata]\\nsetting_version = 4\\npositi
;SETTING_3 on = 5\\ntype = quality_changes\\nquality_type = draft\\n\\n[values]\
;SETTING_3 \n\\n", "[general]\\nversion = 3\\nname = Draft Quality #2\\ndefiniti
;SETTING_3 on = fdmprinter\\n\\n[metadata]\\nsetting_version = 4\\nposition = 6\
;SETTING_3 \ntype = quality_changes\\nquality_type = draft\\n\\n[values]\\n\\n",
;SETTING_3  "[general]\\nversion = 3\\nname = Draft Quality #2\\ndefinition = fd
;SETTING_3 mprinter\\n\\n[metadata]\\nsetting_version = 4\\nposition = 7\\ntype 
;SETTING_3 = quality_changes\\nquality_type = draft\\n\\n[values]\\n\\n"]}

Replace:

  1. ;SETTING_3 with `` (empty string, nothing)
  2. ;End of Gcode\n with ``
  3. \\ with \

And then things get tricky because it looks more like an INI file than JSON. Whoever coded this was being silly or pre-dated JSON.

{"global_quality": "[general]
version = 3
name = Draft Quality #2
definition = fdmprinter

[metadata]
setting_version = 4
type = quality_changes
quality_type = draft

[values]
adhesion_type = skirt
relative_extrusion = True
speed_slowdown_layers = 3
[I stopped manually replacing at this point]
", "extruder_quality": ["[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 0\ntype = quality_changes\nquality_type = draft\n\n[values]\nbrim_line_count = 0\ninfill_pattern = tetrahedral\ninfill_sparse_density = 100\nspeed_print_layer_0 = 10.0\nspeed_travel_layer_0 = 30.0\ntop_layers = 5\n\n", "[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 1\ntype = quality_changes\nquality
_type = draft\n\n[values]\n\n", "[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 2\ntype = quality_changes\nquality_type = draft\n\n[values]\n\n", "[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 3\ntype = quality_changes\nquality_type = draft\n\n[values]\n\n", "[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 4\ntype = quality_changes\nquality_type = draft\n\n[values]\n\n", "[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 5\ntype = quality_changes\nquality_type = draft\n\n[values]\n\n", "[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 6\
\ntype = quality_changes\nquality_type = draft\n\n[values]\n\n", "[general]\nversion = 3\nname = Draft Quality #2\ndefinition = fdmprinter\n\n[metadata]\nsetting_version = 4\nposition = 7\ntype = quality_changes\nquality_type = draft\n\n[values]\n\n"]}

Didn't say but the plugin replaces the \n with end of line before it run the custom added regexp
It's why my regexp works just fine as you can see here


Could be that it only do that. it's bummer if so.

The plugin replaces \n with EOL before it applies the custom regexp.

So in order

  1. plugin replace \n with EOL
  2. https://regex101.com/r/aEAIv8/11 ( get only the data need to work with )
  3. https://regex101.com/r/aEAIv8/9 ( to remove ;SETTING_3 and the EOL )
  4. https://regex101.com/r/aEAIv8/8 ( to get the values )

I believe I've verified this behavior (including only changes from default). Change something simple like retraction length and watch it appear in that ... ini? file. Then change it back to the default and watch it vanish. I tried to do the same thing a few months back :frowning:

1 Like