[SOLVED] Portable FreeCAD(user.cfg, system.cfg and Addon Manager)

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

Great!! Very nice of you!
The only small question: is it possible to check out FC0.16 with this improvement?

And still, how difficult would it be to set up the environment for coding for FC ? (All freeware indeed :) )



One more thing: How difficult is it to store backup files in a separate [bckp] folder?
when there are lots of files in the project - becomes awkward to scroll through all the files again and again.
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

wmayer wrote: Wed Aug 05, 2020 1:51 pm With git commit 9c3f9b72a it's now possible to run a portable version of FreeCAD. All what you have to do is setting the environment variable FREECAD_USER_HOME pointing to a new home directory. The files user.cfg and system.cfg will be read/written there automatically.
Exuse me if this is not the right point for you...

The portable version seems to be "too portable" - after exit it removes all downloaded AddOns, Macros and settings from user's PC (on Windows).
So it is not really not portable, since portability includes saving your settings for use on another machine.

## Is it possible to implement a checkbox like "remove all data on exit" [y/n]? I would uncheck it.

In addition,
1. what is the point of having libraries downloaded to %UserAppData%, if FC normally actually allows to run only a single version of program
2. wouldn't it be easier to implement/store/centralize all path configuration in user/system.cfg ? So that user can Edit/Copy/Paste values up to his choice? And also store the config file near the FreeCAD.exe?
Then for example, would be possible to make there multiple values like
<AddonDir id=1 path =" Path1">
<AddonDir id=2 path =" Path2">
<AddonDir id=3 path =" Path3">

Or
<AddonDir path =" Path1; Path2; Path3">

Then possible to specify:

FC0.17 (Python2) - AddonsCommon, AddonsPy2
FC0.19 (Python3) - AddonsCommon, AddonsPy3

And use two versions of FC (if needed)

Not sure, but this might become useful: some day not all addons remain maintained, and with the change of underlying technology might become unusable. Then having an old and a new versions in parallel - would save functionality.
And IS useful already: Py2 workbenches that are not superseeded: Reconstruction, Timber, GeoData support, FreeCAD-GDT, Animation,
Are there some undocumented options, which are accessible though "Edit Parameters"
And in general, what is the relation between Parameters Editor and the rest of settings?
// Intuitively - Parameters editor is a RAW access to parameters....
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by wmayer »

Smiling_user wrote: Sat Aug 08, 2020 12:52 pm The portable version seems to be "too portable" - after exit it removes all downloaded AddOns, Macros and settings from user's PC (on Windows).
No, it doesn't. Are you sure you looked at the right directory? FREECAD_USER_HOME serves as root directory and the files are still created in sub-directories.
1. what is the point of having libraries downloaded to %UserAppData%, if FC normally actually allows to run only a single version of program
What libraries do you talk about?
2. And also store the config file near the FreeCAD.exe?
No. In general the user has no write permission to the directory where FreeCAD.exe is located. The config files must be saved to a location where it's guaranteed that the user has write permission. Also for a standard installation this would make it impossible to be correctly used on a multi-user system.
Then for example, would be possible to make there multiple values like
<AddonDir id=1 path =" Path1">
<AddonDir id=2 path =" Path2">
<AddonDir id=3 path =" Path3">
Really? That would be a PITA for the user to adjust the config file each time he installs a new add-on. And if he by accident deletes his config file but has installed already dozes of add-on it would be a lot of fun to restore all these paths manually.

It has been discussed in the past to have different config files for different versions. A much simpler approach is to add the version number into the directory name.
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

Maybe someone in the development team could

A. split the settings file into:
startup.cfg
Path: near the FreeCAD.exe
content: places of the main files and directories:
-- <User_cfgPath path =" ">
-- <System_cfgPath path =" ">
-- <MainMod_DirPath path =" ">
-- <DownloadedMod_DirPath path =" ">
-- <MainMacro_DirPath path =" ">
-- <DownloadedMacto_DirPath path =" ">
-- <ClearSettingsOnExit value= {<true>|<false>}>
-- <ClearAddonsOnExit value= {<true>|<false>}>
-- <ClearMacrosOnExit value= {<true>|<false>}>
system.cfg - as usual
user.cfg - as usual

These changes would make it easier to find out the cause of folt (by interchanging different preconfigured settings).


B. point me the place where config files are explained, so that it is a step-by-step reference to edit them.
// If not - any data to fine-tune the UI, for example -
-- set fonts to 8px
-- set icon size (10 px),
-- decrease text-to-text line space.
-- change UI colors

C. Could anyone give an advise which of freeware programs (MSVS, Eclipse or other ) are advised to go refactoring of the whole FC project? Under Windows or Linux.
I'm not going to go so wide, but strong refactoring function is the key-tool for digging in the unknown code.
I would appreciate some direct links/instructions for setting up the programming environment (C++ and Python).
I'd prefer contributing then asking for help, but not so proficient to set up without help.

Also, there would be a need for data about the placement of main initialization settings in the code.
And how to code windows specific functions to avoid interfering with linux-code.
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

Small addition to portability:
See attachment: some changes made in the AddonManager, which make it work / install new workbenches to the main Mod directory.

Problem: Portability of FC at present depends on two basis:
1. settings of the FC itself: [solution under windows]: Before the first start - make a shortcut with
Target:= D:\FreeCAD-0.19.22039-Win-Conda-vc14.x-x86-64\bin\freecad.exe -s system.cfg -u user.cfg
2. settings of AddonManager: AddonManager in present version has a a hard-coded path to user Mod-Folder (Addons)
So some changes made in *.py files of AddonManager - allowed to redirect this to different local folder.

And the problem itself is: settings are not separated from the program, so after unpacking the new version of FC_0.19_pre I have to reapply all the settings by making file changes.

Maybe this is not any problem for those who make no changes to default "portable" installation. But it is not actually "portable" - it depends on system disk ->AppData//Roaming//FreeCAD//Mod

The question is: would the developers be so kind to extract portability settings to a separate config file, or maybe even make a new directory in the FreeCAD_version//config - near the bin directory? And make the FC to read settings from there by default?

This would allow to make the FC really portable, and to easily "upgrade"=unpack the new version of FC on top of older version, by just removing all dirs others than Macro and Mod and unpacking new version near. Than just remove the new "config" dir and paste the user's config dir.

Otherwise I need to update the portable 0.19 pre as rare as possible.

// The actual question: CENTRALIZE the settings of FC. In my opinion - this is both: needed in the future, and would make the coding easier.

// Case example: found that my well-tuned "portable" version under windows - works crazy with applying Draft-Wire to sketh. But at the same time the daily version under ubuntu works fine. Wanted to upgrade to the last FC_0.19_pre_vc14_x64 for Windows - and lost all my settings.
Before - worked under both switching between to "combine" usability(Win) and stability+features (Lin).
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by chrisb »

As discussed above it would be good to have a commandline option for the Mod directory or to have it configurable in the preferences or both, and of course the AddonManager should respect these too.
Your problem that your local changes are lost seems to be self made. You seem to store the clocal stuff in the program tree, and of course it gets removed if you update to another version.
Smiling_user wrote: Tue Sep 01, 2020 8:09 am // The actual question: CENTRALIZE the settings of FC. In my opinion - this is both: needed in the future, and would make the coding easier.
This is the opposite of your previous post, where you wanted to split the config files :?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

No, crisb,
Splitting an centralization - belong to a hierarchy-dependant categories.
Centralisation - regards path to access.
Splitting - regards number of files.
The settings might be centralized (in a single path) but contained in different files or in a single file.

My vision is to have a master config file, where the rest of config files are routed.
// GetAppDir() //
../config/master.cfg
<Name = "GUISettings" FilePath="GUISettings_1.cfg">
<Name = "PartDesignSettings" FilePath="PartDesign_1.cfg">

../Config/user.cfg
../Config/system.cfg
../Config/GUISettings_1.cfg
../Config/PartDesign_1.cfg
../Config/View.cfg
../Config/Navigation.cfg
etc.
And each of config files for AddOns would first of all contain:
<AddonPathFolder = "" #Path to the addon folder>
<Dependancy folders = "" # here - diff folders the addon should take dependencies from.

This system would even allow to setap a local VCS/git for settings tuning / recovery
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

#ATTENTION - The supplyed file pack contains a bug. DO NOT USE IT
Changes to FreeCAD:
[SOLVED] Shortcut -> user.cfg and system .cfg will be located in the FreeCAD.HomePath
[NOT SOLVED]: these changes to AddonManager code - lead to normal install/update of addons, but user-addons are not seen in the workbenches list. ANY HELP?

The idea was:
To complete USB-portability of FreeCAD:
// At the moment of writing FreeCAD_0.19_pre
1. Take the latest *.zip release
2. Unpack FC, do not start, go to application folder/ModFolder: delete AddonManager directory
3. Extract AddonManager from the attached archive in place of the deleted
4. Extract the Shortcut with settings to the Home Directory of FreeCAD (is where folders bin, data, Ext, lib, Mod, etc.)
5. Start FreeCAD with that shortcut.

Remember to change the user macroDirectory Path before installing macros.

Any other suggestions ?

//// Would be nice if someone could make a globally set variable for UserModDirPath in the AddonManager and set this as an option in the user.cfg

CHANGES MADE in the AddonManager:
  • getUserAppDataDir -> FreeCAD.getHomePath
  • Mod -> ModM -> User-downloaded addons will be stored in the folder ModM

Code: Select all

###########addonmanager_workers.py#############
  97         basedir = FreeCAD.getUserAppDataDir()
  98         moddir = basedir + os.sep + "Mod"
113            addondir = moddir + os.sep + name
121         # querying custom addons
122        customaddons = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Addons").GetString("CustomRepositories","").split("\n")
128       addondir = moddir + os.sep + name
201        basedir = FreeCAD.getUserAppDataDir()
202        moddir = basedir + os.sep + "Mod"
405        clonedir = FreeCAD.getUserAppDataDir() + os.sep + "Mod" + os.sep + repo[0]
434                  # Let the user know the install path for this addon
435            message += '<br/>' + translate("AddonInstaller","Installed location")+": "+ FreeCAD.getUserAppDataDir() + os.sep + "Mod" + os.sep + self.repos[self.idx][0]
444 message += '<br/>' + translate("AddonInstaller","Installed location")+": "+ FreeCAD.getUserAppDataDir() + os.sep + "Mod" + os.sep + self.repos[self.idx][0]
616 basedir = FreeCAD.getUserAppDataDir()
617            moddir = basedir + os.sep + "Mod"

#######AddonManager.py#############

490           basedir = FreeCAD.getUserAppDataDir()
491           moddir = basedir + os.sep + "Mod"
530          moddir = FreeCAD.getUserAppDataDir() + os.sep + "Mod"
Attachments
AddonManager_getHomePath+ModM.zip
(567.62 KiB) Downloaded 56 times
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by chrisb »

As a workaround see it just like this: AddonManager is a convenience tool installing in the default directory. If you want something else, see Installing more workbenches for manual installation or copy/move them from their default directory.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Aleks
Posts: 309
Joined: Sun Mar 08, 2020 5:27 pm
Location: Bonn, Germany
Contact:

Re: [SOLVED]_Portability?: Portable FreeCAD Help with DirsPath coding

Post by Aleks »

Will this interfere with an installation of FreeCAD?
FreeCAD als Maschinenbauer in die Konstruktion und Fertigung integrieren. Schulung buchen: www.alsado.de/freecad-schulungen
Post Reply