How to make the file tab to remember the WB used

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
dxp.dev
Posts: 280
Joined: Tue Dec 11, 2018 12:57 pm

How to make the file tab to remember the WB used

Post by dxp.dev »

Hi,

OS: macOS Mojave (10.14)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19541 (Git)
Build type: Release
Branch: master
Hash: a797a4172709b82c6cd08dcf6df86cb789aaa3ce
Python version: 3.8.1
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)


I often have multiple files open in FreeCAD, and I use different WB for each (for instance, one with FEM WB, one with Part Design WB, one with A2plus or another Assembly WB).

When I switch from file to file, I'd like the toolbar to "remember" what WB was open with that file. i.e. that when I'm on my Assembly file and I go to my file with Part Design, the toolbar changes automatically from the Assembly toolbar to Part Design toolbar. For now, I'm forced to click on the drop down menu to choose the WB again and again.

How to do that ? Is it possible ?

Thanks
Find your user.cfg and system.cfg files : Macro_findConfigFiles

Imperial system makes no sense, go metric ! ! !
chrisb
Veteran
Posts: 54313
Joined: Tue Mar 17, 2015 9:14 am

Re: How to make the file tab to remember the WB used

Post by chrisb »

I don't think this is possible at the moment, at least not without some Python programming. But it sounds like a reasonable extension. As my workflow is different, I would like to see it configurable.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Re: How to make the file tab to remember the WB used

Post by dcapeletti »

It would also be desirable that when you save and close the file, you save which workbench was used last. That way, when you open the file, you can load that workbench, but if the workbench is not installed, it will show an alert. That's just an idea I had.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to make the file tab to remember the WB used

Post by openBrain »

dxp.dev wrote: Wed Feb 12, 2020 7:25 pm How to do that ? Is it possible ?
You can just open several FC instances so each will have its own instance. ;)
User avatar
dcapeletti
Posts: 504
Joined: Wed Jul 23, 2014 2:27 pm

Re: How to make the file tab to remember the WB used

Post by dcapeletti »

You could write a macro that observes the changes between document tabs and for each document, create a tuple of the last used bank. When the document is changed, the macro calls the last bank used in that document.

I have no idea how to detect changes between different document tabs.
dxp.dev
Posts: 280
Joined: Tue Dec 11, 2018 12:57 pm

Re: How to make the file tab to remember the WB used

Post by dxp.dev »

openBrain wrote: Wed Feb 12, 2020 9:06 pm
You can just open several FC instances so each will have its own instance. ;)
Given that FC already handles tabs, that seems overkill no ?

And will that be compatible with the necessity of the assembly WBs to have the external part file to be open to insert it /update the part in the assembly file ?
Find your user.cfg and system.cfg files : Macro_findConfigFiles

Imperial system makes no sense, go metric ! ! !
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to make the file tab to remember the WB used

Post by openBrain »

dxp.dev wrote: Thu Feb 13, 2020 10:13 am Given that FC already handles tabs, that seems overkill no ?
Attached a macro that tries to solve the problem. ;)
Features are :
  • Stores for each MDI window what is the active workbench (and of course recall it when the window has been left then reentered)
  • Stores the current workbench as own one for all opened windows when launching the macro (of course can be changed afterward)
  • Stores the current workbench as own one for newly created window (of course can be changed afterward)
Notice that this is stored in the UI so not saved to file. However the good thing is that you can have 2 different workbenches for 2 different views of the same document (eg. PartDesign in the 3D view and Spreadsheet in a spreadsheet view of the same model). I think this is a correct approach but I may fail.

If this is of interest, next steps could be (not exclusive) :
  • Make the macro available through addon manager
  • Provide the macro as a package so that it can be run at automatically at startup / Make this package available through the addon manager
  • Hardcode this behavior in FreeCAD "core" and add an option to enable it
Feedback welcome.

Macro file deleted => can be found on dedicated thread
Last edited by openBrain on Sat Feb 15, 2020 12:09 pm, edited 1 time in total.
dxp.dev
Posts: 280
Joined: Tue Dec 11, 2018 12:57 pm

Re: How to make the file tab to remember the WB used

Post by dxp.dev »

Thanks, it seems to work .

I will open a feature request with a link to here.
Find your user.cfg and system.cfg files : Macro_findConfigFiles

Imperial system makes no sense, go metric ! ! !
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to make the file tab to remember the WB used

Post by openBrain »

dxp.dev wrote: Thu Feb 13, 2020 3:45 pm Thanks, it seems to work .

I will open a feature request with a link to here.
No need to do so if we can manage it here. ;) Let's do it only if we can't find a consensus and get an implementation in some weeks. ;)
dxp.dev
Posts: 280
Joined: Tue Dec 11, 2018 12:57 pm

Re: How to make the file tab to remember the WB used

Post by dxp.dev »

Oops, I just did it...

But, I think your macro deserves to be integrated, not just be a macro lost in the macro pool.
Find your user.cfg and system.cfg files : Macro_findConfigFiles

Imperial system makes no sense, go metric ! ! !
Post Reply