shoogen wrote:but the normal way would be to define your default value in a globally visible variable
Code: Select all
RandomDefault = 5.0
grp = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/TEST")
grp.GetFloat("RANDOM",RANDOMDefault)
For the record, this all applies to the
curaengine macro that I have been working on.
All of the default settings (approx 58 of them) are stored in a dictionary with methods similar to what you posted for reading the variables. Basically, the settings are all read from the dictionary until the user changes them in the gui. Then they are written internally....
Long story short, I needed a way to
import and export the settings from the macro. For this I decided to use grp.Export and grp.Import, which works perfectly except for the fact that unless the user has manually changed a setting in the gui, the setting is not written to system.cfg and therefore is not included in the exported settings file. So basically I needed a way to make sure that every setting in the macro is written to internally to freecad so they can all be exported. I added a routine
here which uses your original method to check if the setting is exists internally. If not it writes the default value (from dictionary) to system.cfg.
There may be a better way but so far its working good. I hope my explanation makes sense.