[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 »

NIce to hear from you, Yorik.
In your terms, I'd like to have an option to have the whole install at appspace, so I could have all settings, addons and macros - in a single folder.
Such a portable folder, that is self-contained.

Another additional option would be to have a tableGrid to control loaded addons - This would be needed to have two or more different FC versions, that use same Mod folder, but are select-able on which addons and macros to load. (Like checkboxes).

My very first question would be what is the anchoring of %UserPath%, %AppPath% etc. And where is it located in code. - Which modules actually read the settings. (also - how to create a correct resource file )
For example, a file executed at startup like config.py, containing multiple user edited ConfigSet("","") - would solve many things.

Would you advise any start-n-go IDE for python? which would allow me to refactor and commit some code to GIT?
Another small queston would be - is it possible at python (UI ) level to change UI-BL bindings?
Is it possible in UI level to create operation of DataPlane <position> "through line", "Through 3 vertices" ?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by wmayer »

In order to have a fully portable FreeCAD installation you must use FreeCAD -u <Path_on_your_stick>/user.cfg -s <Path_on_your_stick>/system.cfg

When you have started FreeCAD this way open the function Macro > Macros and specify the new directory for your macros. What remains is to change the directory where to save the add-ons. At the moment you can change this path from Python but afaics there is no program option to specify it.

Code: Select all

App.getUserAppDataDir() # returns the default path
App.ConfigGet("UserAppData") # same as above
App.ConfigSet("UserAppData", "<Path_on_your_stick>")

App.getUserAppDataDir() # shows new path
App.ConfigGet("UserAppData") # shows new path
An (easier) alternative is to set the environment variable FREECAD_USER_DATA to point to the requested directory.

The suggestion to set $HOME doesn't work. It does not even work under Linux because internally we don't check what's set to HOME but use some system specific API function instead.
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,
Very useful responce.
And still some questions:
#### 1. ####
In the https://wiki.freecadweb.org/index.php?t ... figuration
There is mentioned:
--response-file arg Can be specified with '@name', too
-u [ --user-cfg ] arg User config file to load/save user settings
-s [ --system-cfg ] arg System config file to load/save system settings
-t [ --run-test ] arg Test case - or 0 for all
-M [ --module-path ] arg Additional module paths
-P [ --python-path ] arg Additional python paths

But I'd like to automate this process:
For example to st the command so, that FreeCAD.exe looks for config files in the same folder.

#### 2. ####
How can I use response-file ?
What if I specify the command-line as:
-u ../user.cfg -s ../system.cfg --response-file response.txt

Will the FreeCAD read these files from the installation folder?
#### 3. ####
And if yes - what would be the response-file format? What to write inside?

// From python console I managed to set all arguments as I like (FreeCAD.ConfigSet("Name","Value")),
BUT:
1. setting them becomes available only after the whole initialisation of FreeCAD.
2. And these settings work until restart.
3. So initialization of workbenches through these setting is impossible.

#### 4. ####
Is it possible to use Properties Editor for this purpose?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by wmayer »

Obviously you are on Windows and I strongly recommend to use a batch file. You can name it FreeCAD.bat and put it into the same directory as FreeCAD.exe. Inside the file write (but not yet tested)

Code: Select all

set CURRENTDIR="%cd%"
set FREECAD_USER_DATA=%CURRENTDIR%/..
start FreeCAD.exe -u %FREECAD_USER_DATA%/user.cfg -s %FREECAD_USER_DATA%/system.cfg
Now double-click the batch file to start FreeCAD.
How can I use response-file ?
To be honest I don't know how the content is supposed to look. This feature is provided by the "program-options" component of the boost library but there is nowhere an example shown. But when using a batch file you don't need the response file anyway.
// From python console I managed to set all arguments as I like (FreeCAD.ConfigSet("Name","Value")),
BUT:
1. setting them becomes available only after the whole initialisation of FreeCAD.
2. And these settings work until restart.
3. So initialization of workbenches through these setting is impossible.
What else do you want to customize?
Is it possible to use Properties Editor for this purpose?
Property editor? For sure not. You maybe meant the parameter editor. This can be used to customize all the paths of 3rd party utilities
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

I want to customize

Code: Select all

FreeCAD.ConfigSet("SystemParameter","..\\FreeCAD\\system.cfg")
FreeCAD.ConfigSet("UserAppData","..\\FreeCAD")
FreeCAD.ConfigSet("UserHomePath","..\\Sys_FreeCadDocs")
FreeCAD.ConfigSet("UserParameter","..\\FreeCAD\\user.cfg")
And also Path to Addons, path to macros,
// Actually - all path tha will make FreeCAD Self-contained in a single folder, so, that if I want / need - would be possible to:
Move around with a USB, having all in it.
Have multiple versions of FC running on the same system without interfering - at least at different time.

Would appreciate your help to find the particular file - responsible for path locations, so I could try to modify it and give back for commit.

In my feeling (as a windows user) FC lacks settings customization intuitivity.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by wmayer »

FreeCAD.ConfigSet("SystemParameter","..\\FreeCAD\\system.cfg")
Use the program option -s
FreeCAD.ConfigSet("UserParameter","..\\FreeCAD\\user.cfg")
Use the program option -u
FreeCAD.ConfigSet("UserAppData","..\\FreeCAD")
Set the environment variable FREECAD_USER_DATA
FreeCAD.ConfigSet("UserHomePath","..\\Sys_FreeCadDocs")
Yes, this one is missing.
Smiling_user
Posts: 196
Joined: Tue Jul 28, 2020 7:31 am

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by Smiling_user »

Is it possible to manually install all addons and macros in the Mod folder inside FreeCAD folder?

And again, if you could point how to step-by-step organize developing environment on my PC may be I could make a valuable commit?

There are already several things I noticed, which seem remarkable to implement.
Maybe even could implement some planned functions for A2Plus... ? ( hopefully)

Besides after working with Assembly 4 and A2Plus - the feeling is:
Assembly4 is robust, but the concept is way too long for production usage. (except m.b. dinamic modeling)
A2Plus - result is not steady enough, but the approach is production-efficient. And by adding some small functionality to A2Plus - it would win the Assembly 4.
More of this - A2Plus - is mostly about interface, Assembly 4 - mostly about logics.

Hopefully - having a programming environment I could make some job. But setting the environment was way too complicated for me.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by wmayer »

I just have realized that the environment variable FREECAD_USER_DATA is only used under Linux. So, from the program options you cannot alter UserAppData or UserHomePath.
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,
aside ProgramOptions there is also PyConsole.
Did you see the ['code] in the head of this topic?

And more: I'd like to alter the UI (fonts, distances) and especially Spreadsheet - it lacks visibility due to the minimal size of columns and rows.
As using it quite often - it frustrates to go resizing each time or using the previousely made template.
I'd like to make possible to set default width /height of rows in Spreadsheet. At least "onCreate".
And also - to change font. M.b. this UI question regards Mr. Yorik more?

FC - is a GREAT program but at the moment it lacks production usability in some tiny moments - but this destroys all the thing.
Today made another Gates. considering these are the third model, and that I already new all the approach - i took me 5-6 hours to do, what a colleague made in Fs360 in 40*2 min.

Is there a serious interest for making FC one level better based on workflow speed-up - by the optimisation of existing tools?
Or my effort is not in the right time/place ?

Again the scope: FC has a vast amount of tools and overall - of the professional CAD level. But in production - the Fs360 is more efficient and reliable.
Added stability(not of my competence) and usability (who knows what is possible?) - FC would be a widely required tool.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by wmayer »

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.

So, the above batch file may look like

Code: Select all

set CURRENTDIR=%cd%
set FREECAD_USER_HOME=%CURRENTDIR%\..
start FreeCAD.exe --write-log
Post Reply