fieldOfView / Cura-MaterialSettingsPlugin

A Cura plugin that lets the user select which print settings are available on the Materials pane of the preferences.
GNU Affero General Public License v3.0
13 stars 5 forks source link

Formula support #20

Closed qwertymodo closed 2 years ago

qwertymodo commented 2 years ago

Several built-in settings are defined as formulas calculated from other settings, it would be nice to use formulas in the materials settings as well. Ideally, it would be nice to be able to somehow look up the correct key value for a setting based on its display name, or a search function.

qwertymodo commented 2 years ago

Unfortunately, I can't find any examples of formulas being used in any of the built-in *.xml.fdm_material files, so I'm not sure what the syntax would be there.

In *.def.json files, the syntax is:

"setting_key_name": { "value": "referenced_key_name_or_formula" }

e.g.
"line_width" : { "value": "machine_nozzle_size" }
"support_z_distance": { "value": "min(2 * layer_height, machine_nozzle_size * 0.75)" }

In *.inst.cfg files, on the other hand, it looks like this:

setting_key_name = =referenced_key_name_or_formula

e.g.
wall_thickness = =line_width*4

If I had to guess, I'd say the .xml.fdm_material syntax probably doesn't include the leading '=', but without any existing examples, it's hard to say.

fieldOfView commented 2 years ago

I don't think the xml format supports using the = syntax, only literals.

fieldOfView commented 2 years ago

On a general note, I think a formula-editor should be part of Cura (for the sidebar), not this plugin.

qwertymodo commented 2 years ago

Regardless of what data format the xml file supports, the plugin doesn't allow anything other than numbers to be typed into the UI. Not sure if that's a restriction of Cura itself, or if it's something you can get around. As for the formula editor upstream vs in the plugin, I agree there. If I remember tomorrow I'll file an upstream feature request for that.

fieldOfView commented 2 years ago

the plugin doesn't allow anything other than numbers to be typed into the UI

The plugin (deliberately) uses the input elements that the rest of Cura uses, for consistency.

If I remember tomorrow I'll file an upstream feature request for that.

No need: https://github.com/Ultimaker/Cura/issues/3856