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

Having trouble installing or compiling FreeCAD? Get help here.
Smiling_user
Posts: 173
Joined: Tue Jul 28, 2020 7:31 am

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

Post by Smiling_user » Tue Jul 28, 2020 8:28 am

This post is obsolete and preserved for historical reasons.
DEFINITION: Portable - Means ALL program data are stored inside single directory.
Test your FreeCAD settings: use in Py Console:

Code: Select all

FreeCAD.ConfigGet("UserHomePath")
FreeCAD.ConfigGet("UserAppData")
FreeCAD.ConfigGet("UserParameter")
FreeCAD.ConfigGet("SystemParameter")
When this is needed:
1. Run different versions of FC on the same machine
2. Have a completely portable version on a USB Disk

// NOT YET IMPLEMENTED 3. Have the same Addons and Plugins repository for multiple compatible versions of FreeCad on the same machine / USB-disk


Solution by wmayer and sgorgan:

FreeCad.bat

Code: Select all

set CURRENTDIR=%cd%
set FREECAD_USER_HOME=%CURRENTDIR%
start bin\FreeCAD.exe -u FreeCAD/user1.cfg -s FreeCAD/system1.cfg --write-log 
Place this file next to the "bin" folder.
There will be made a folder "FreeCAD", containing
AddonManager (folder)
Macro (folder)
Mod (folder)
user.cfg
system.cfg

For testing purpose it is possible to modify this file in parameters -u and -s :
if the name is changed - it is possible to have multiple files of settings and use the with several versions of the bat file.
example:
FreeCAD1.bat -> start bin\FreeCAD.exe -u FreeCAD/user1.cfg -s FreeCAD/system1.cfg --write-log
FreeCAD2.bat -> start bin\FreeCAD.exe -u FreeCAD/user2.cfg -s FreeCAD/system2.cfg --write-log
...............
FreeCAD_N.bat -> start bin\FreeCAD.exe -u FreeCAD/user_N.cfg -s FreeCAD/system_N.cfg --write-log
And by putting several versions of FC in the same folder
%currentDir%/FC_0.18
%currentDir%/FC_0.19_pre
etc. - it is possible to start different versions of FC making use of the same Macro, Mod, and parts Library folders.

Besides! From the parts_library macro - possible to use only the macro and make your own parts for it.

#########
The "TODO:" left over and being actually a feature request is to optionally include a partsLibrary folder into current project folder.
The reuse of some details from the library - seems to be easier, then copying them again and again by use of conventional copy-paste.

With respect.
Attachments
FreeCAD.bat.txt
(135 Bytes) Downloaded 7 times
Last edited by Smiling_user on Sun Sep 13, 2020 9:06 pm, edited 17 times in total.
Smiling_user
Posts: 173
Joined: Tue Jul 28, 2020 7:31 am

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by Smiling_user » Tue Jul 28, 2020 5:10 pm

Good news:
In the MWAYNIE'S FreeCAD portable: https://github.com/2wayne/FreeCADPortable
Next to FreeCADPortable.exe It is possible to create FreeCADPortable.ini with content:
; (There is no need for an INI header in this file; if you have one, though, it won't damage anything.)
AdditionalParameters= <<command Line parameters>>
DisableSplashScreen=false
RunLocally=false

Who could figure out which keys and values should be to run the FC completely in the single directory?

With respect.
openBrain
Posts: 4605
Joined: Fri Nov 09, 2018 5:38 pm

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by openBrain » Tue Jul 28, 2020 5:19 pm

Hi, Welcome,

First, don't shout, don't write bold or red full sentences unless there is some emergency.
FreeCAD is free software. Source code is available. Feel free to fork and patch to make it portable.

Also there is the simple solution of running it from a batch file that tampers the environment variable => https://forum.freecadweb.org/viewtopic.php?t=38194
Smiling_user
Posts: 173
Joined: Tue Jul 28, 2020 7:31 am

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by Smiling_user » Tue Jul 28, 2020 5:29 pm

Else: what I did once:
AddonManager: in all files change getUserAppDataDir >> getHomePath
But what would be the commandline key to set UserAppDataDir := getHomePath ?

And proceeding....
(https://forum.freecadweb.org/viewtopic.php?t=210)
Top wmayer Re: Config / System+User.cfg Postby wmayer » Thu Dec 31, 2009 4:41 pm
In rev. 2775 I have added a couple of new command line options:
--user-cfg to specify an arbitrary file to load/save user settings
--system-cfg to specify an arbitrary file to load/save system settings
--log-file to log to an arbitrary file


And one more: https://forum.freecadweb.org/viewtopic.php?t=38194
Last edited by Smiling_user on Tue Jul 28, 2020 9:42 pm, edited 2 times in total.
openBrain
Posts: 4605
Joined: Fri Nov 09, 2018 5:38 pm

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by openBrain » Tue Jul 28, 2020 5:35 pm

Just tamper both APPDATA and HOME environment variables, no ?
Honestly, most of time I'm an happy non-Windows user. :lol:
Smiling_user
Posts: 173
Joined: Tue Jul 28, 2020 7:31 am

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by Smiling_user » Tue Jul 28, 2020 9:07 pm

Nice replies, OpenBRAIN.
And please, suggest any example of what you mean.

Maybe there is an option to edit/write config files from within FreeCAD?
Or maybe any suitable external tool exists?

With respect.
openBrain
Posts: 4605
Joined: Fri Nov 09, 2018 5:38 pm

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by openBrain » Tue Jul 28, 2020 9:32 pm

Smiling_user wrote:
Tue Jul 28, 2020 9:07 pm
Nice replies, OpenBRAIN.
And please, suggest any example of what you mean.
Did you read the thread I pointed above? Everything's there. You can temporarily alter the HOME environment variable in the same way.
User avatar
sgrogan
Posts: 6087
Joined: Wed Oct 22, 2014 5:02 pm

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by sgrogan » Tue Jul 28, 2020 9:55 pm

The .bat file is the way to go.
The .cfg files are XML so any text editor will do.
When using Edit > Preferences ... Any Paths are hard coded, like Path to OpenSCAD.exe
I think relative Paths will work, don't know if they get re-written at restart.

I don't know 2Wayne's work, I assume FreeCADPortable.exe is an NSIS installer? but I didn't download it.
"fight the good fight"
Smiling_user
Posts: 173
Joined: Tue Jul 28, 2020 7:31 am

Re: Again about portability: Portable FreeCAD/ paf.exe

Post by Smiling_user » Wed Jul 29, 2020 5:07 am

0.
When using Edit > Preferences ... Any Paths are hard coded, like Path to OpenSCAD.exe
I think relative Paths will work, don't know if they get re-written at restart.
- yes they are - in the first topic I mentioned, the way to change from Python console, but after restart it breakes.
1.
sgrogan wrote:
Tue Jul 28, 2020 9:55 pm
I don't know 2Wayne's work, I assume FreeCADPortable.exe is an NSIS installer? but I didn't download it.
FreeCadPortable.exe - is just an external program caller which has it's own *.ini files which are user- editable.
By now it achieves( python Consloe-> FreeCAD.ConfigDump() ):
'SystemParameter': 'F:\\FreeCADPortable_019_vc15\\Data\\system.cfg',
'UserAppData': 'C:\\Users\\worker\\AppData\\Roaming\\FreeCAD\\',
'UserHomePath': 'C:\\Users\\worker\\Documents',
'UserParameter': 'F:\\FreeCADPortable_019_vc15\\Data\\user.cfg',
[would be a solution]: what to write in the user.cfg and system cfg to override hardcoded UserAppData and UserHomePath ??

there is a line "Additional parameters=" which is supposed to keep command-line parameters to send to FreeSCAD.exe on start-up.
The same can be done by creating a shortcut (at least in Windows) with parameters.



2.
The .bat file is the way to go.

3.
The .cfg files are XML so any text editor will do.
4.
There are also:
--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

But I need exact instructions
) what to write in the command line
) where to put additional files
) what to write inside them

And it seems, that even user.cfg and system.cfg - do not have any major influence.

Any solution would do, but HOW? As for non-programmer it turned out for me too complicated to figure out the solution.
User avatar
yorik
Site Admin
Posts: 12032
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: Portability?: Portable FreeCAD Help with DirsPath coding

Post by yorik » Mon Aug 03, 2020 4:41 pm

I didn't understand very well what you need from me? indeed all these settings are specified in config files, they should be fairly easy to tweak i guess.. as for modules, you usually have two modules locations, an appspace one and a userspace one. I think you can ship all the modules you want in the appspace one, then it makes sense to let user use the addon managerethe normal way.. or am i getting it wrong?
Post Reply

Who is online

Users browsing this forum: kkremitzki and 4 guests