Is it possible to use ParameterGrp from Python?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Is it possible to use ParameterGrp from Python?
Hi
Is it possible to use ParameterGrp from python to load a FreeCAD config File? I saw that there is a ParameterPy.cpp file (https://github.com/FreeCAD/FreeCAD/blob ... eterPy.cpp) that contains the parameter Group and a Import method. But i couldn't figure out how to use it via python.
I ask because I want to add the possibility to merge settings into existing presets for my macro https://github.com/furti/FreeCAD-PreferencesPresets
Thanks in advance
Best Regards
Daniel
Is it possible to use ParameterGrp from python to load a FreeCAD config File? I saw that there is a ParameterPy.cpp file (https://github.com/FreeCAD/FreeCAD/blob ... eterPy.cpp) that contains the parameter Group and a Import method. But i couldn't figure out how to use it via python.
I ask because I want to add the possibility to merge settings into existing presets for my macro https://github.com/furti/FreeCAD-PreferencesPresets
Thanks in advance
Best Regards
Daniel
Re: Is it possible to use ParameterGrp from Python?
are you looking for:furti wrote: ↑Wed Sep 12, 2018 3:32 pm Hi
Is it possible to use ParameterGrp from python to load a FreeCAD config File? I saw that there is a ParameterPy.cpp file (https://github.com/FreeCAD/FreeCAD/blob ... eterPy.cpp) that contains the parameter Group and a Import method. But i couldn't figure out how to use it via python.
I ask because I want to add the possibility to merge settings into existing presets for my macro https://github.com/furti/FreeCAD-PreferencesPresets
Thanks in advance
Best Regards
Daniel
Code: Select all
pg = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
pg.GetString('constructiongroupname')
Re: Is it possible to use ParameterGrp from Python?
Code: Select all
pg = FreeCAD.ParamGet("User parameter:BaseApp")
pg.Import(myparameterfile)
Re: Is it possible to use ParameterGrp from Python?
Thank you for your answers. But this is not exactly what I am searching for. I want to load e.g. a user.cfg file that is stored in a different location than the default user.cfg file and compare it to the parameters of the running FreeCAD instance. Then i can compare this two groups and show the user a diff. The user selects the parameters to merge and i save the group back into the other user.cfg file.
As it seems to me, your examples use the parameter groups of the running FreeCAD instance and a "Import" will override the settings of FreeCAD.
But after trying this I realized that the "getContents" method does no list the ParameterGroups inside a ParameterGroup. So it is not possible to list all parameters inside a group without knowing the parameter names beforehand.
Do you think such functionality will likely be available via Python in the future?
Best Regards
Furti
Re: Is it possible to use ParameterGrp from Python?
In C++ the class ParameterGrp has the methods GetGroups() and GetGroupName() so that we can expose a function to Python access this information.Do you think such functionality will likely be available via Python in the future?
Re: Is it possible to use ParameterGrp from Python?
That sounds great.
Do you think it is also possible to get access to the ParameterGrp constructor from python? As it seems it is not available in the Base module right now.
Thank you for your help.
Re: Is it possible to use ParameterGrp from Python?
What for?Do you think it is also possible to get access to the ParameterGrp constructor from python?
Re: Is it possible to use ParameterGrp from Python?
Need a way to load different config files and compare them against each other for this macro i created https://forum.freecadweb.org/viewtopic.php?f=22&t=30795
Then the user can choose the settings to override and i can save the file back to the preset location without messing up the preferences of the current FreeCAD instance.
Re: Is it possible to use ParameterGrp from Python?
git commit 476a07ae2 exposes some more methods to Python.
If you want to create a new group then simply write the name of the new group which will be created on-the-fly if it doesn't exist.
Code: Select all
pg = FreeCAD.ParamGet("User parameter:BaseApp")
pg.GetGroups()
# returns ['Preferences', 'Macro', 'Workbench', 'MainWindow', 'History', 'Workbenches', 'LogLevels']
pg.GetGroup("Macro")
Code: Select all
pg.GetGroup("ThisCreatesANewGroup")