How to make user settings in AddOns surviving upgrades?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Palmstroem
Posts: 133
Joined: Wed Jan 27, 2021 5:34 pm

How to make user settings in AddOns surviving upgrades?

Post by Palmstroem »

If users make settings inside an AddOn, variables can be stored within the parameters.
Will these parameters survive an upgrade of FreeCAD? Like from v0.21 to v0.22.
How would I have to program my AddOn for the parameters to survive? I don't want the users to make all their settings manually again after an update. How does this upgrade work? Does the FreeCAD/Mod folder within the userspace remain untouched by an upgrade? Is it better to save parameters and retrieve them from there on startup?
I couldn't find any information about that in the docu. Maybe someone can point me to the right place. :?
Last edited by Palmstroem on Mon Feb 12, 2024 9:22 am, edited 1 time in total.
chrisb
Veteran
Posts: 53471
Joined: Tue Mar 17, 2015 9:14 am

Re: How to make user settings in AddOns to survive upgrades?

Post by chrisb »

Palmstroem wrote: Mon Feb 12, 2024 8:14 am If users make settings inside an AddOn, variables can be stored within the parameters.
Will these parameters survive an upgrade of FreeCAD?
Yes.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Palmstroem
Posts: 133
Joined: Wed Jan 27, 2021 5:34 pm

Re: How to make user settings in AddOns surviving upgrades?

Post by Palmstroem »

Thanks!
User avatar
onekk
Veteran
Posts: 6013
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: How to make user settings in AddOns surviving upgrades?

Post by onekk »

The most safe way is to store parameters in the Mod/Add-on directory as example as a JSON file as a backup and when the addon detect a change in FC version try to reapply them to the runnin FC version (probably the new version).

There is some work to be done, as many times even today you are advised in case of problems to renane your user dir and try to restart FreeCAD.


but in this userdir there is also the Mod directory.

I usually start FreeCAD setting a specific user dir (it is feasible using a sh file or a bat file on Windows, so to start with a fresh install is a matter of creating a directory and change this name in the "start file" that usually involve duplicating a line commenting out one of them and modify the other to reflect the change.

But your settings are not lost so this is not harmful.

Kind Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply