[PR# 3616] add recent macros to macro menu

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
TheMarkster
Posts: 2049
Joined: Thu Apr 05, 2018 1:53 am

[PR# 3616] add recent macros to macro menu

Postby TheMarkster » Fri Jul 03, 2020 7:53 pm

https://github.com/FreeCAD/FreeCAD/pull/3616

This would add a new submenu to the Macro menu called Recent macros. It would work similarly to the Recent files item in the File menu except it would contain the list of most recently used macros.
Snip macro screenshot-fcd0ba.png
Snip macro screenshot-fcd0ba.png (88.09 KiB) Viewed 471 times
There is a settings option for the number of macros to keep track of in the recent macros list.
Snip macro screenshot-182cee.png
Snip macro screenshot-182cee.png (120.86 KiB) Viewed 471 times
Selecting a macro from the Recent macros list will run the macro, but if you Shift+Click it will instead open it in the macro editor.
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
chrisb
Posts: 29062
Joined: Tue Mar 17, 2015 9:14 am

Re: [PR# 3616] add recent macros to macro menu

Postby chrisb » Fri Jul 03, 2020 8:29 pm

Nice extension.
I usually use only the latest, so it would be nice, if the length of the list equals one if it could be lifted to the top level of the macro menu.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
openBrain
Posts: 4874
Joined: Fri Nov 09, 2018 5:38 pm

Re: [PR# 3616] add recent macros to macro menu

Postby openBrain » Fri Jul 03, 2020 9:14 pm

chrisb wrote:
Fri Jul 03, 2020 8:29 pm
Nice extension.
I usually use only the latest, so it would be nice, if the length of the list equals one if it could be lifted to the top level of the macro menu.
I almost agree. :)
Would prefer a simple extra menu entry (with a keyboard shortcut) that would just 'Reexecute last macro'.
chrisb
Posts: 29062
Joined: Tue Mar 17, 2015 9:14 am

Re: [PR# 3616] add recent macros to macro menu

Postby chrisb » Fri Jul 03, 2020 11:20 pm

openBrain wrote:
Fri Jul 03, 2020 9:14 pm
Would prefer a simple extra menu entry (with a keyboard shortcut) that would just 'Reexecute last macro'.
Even better!
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
TheMarkster
Posts: 2049
Joined: Thu Apr 05, 2018 1:53 am

Re: [PR# 3616] add recent macros to macro menu

Postby TheMarkster » Fri Jul 03, 2020 11:28 pm

Good ideas. I've added to the PR. Now a dynamic shortcut is created for the most recently used macros in the form Ctrl+Shift+1 (most recent), Ctrl+Shift+2 (2nd most recent), etc. up to Ctrl+Shift+9.
Snip macro screenshot-dab144.png
Snip macro screenshot-dab144.png (113.75 KiB) Viewed 430 times
I don't think this will conflict with any existing default keyboard shortcuts.
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
openBrain
Posts: 4874
Joined: Fri Nov 09, 2018 5:38 pm

Re: [PR# 3616] add recent macros to macro menu

Postby openBrain » Sat Jul 04, 2020 5:37 am

TheMarkster wrote:
Fri Jul 03, 2020 11:28 pm
Good ideas. I've added to the PR. Now a dynamic shortcut is created for the most recently used macros in the form Ctrl+Shift+1 (most recent), Ctrl+Shift+2 (2nd most recent), etc. up to Ctrl+Shift+9.

Snip macro screenshot-dab144.png

I don't think this will conflict with any existing default keyboard shortcuts.
I'm a bit doubtful. I prefer to have just a 'Reexecute last macro' with eg. 'Ctrl+Shift+F6' (macros already use 'F6' key) so it's clear to the user. I don't like dynamic shortcuts because it can trouble user. If you run the '6' macro once, then its shortcut becomes '1'. If you hit '3' several times, it actually runs a queue of 3 macros in a circular order. :?
And I don't think one will memorize the 9 last macros she/he ran. ;)
chrisb
Posts: 29062
Joined: Tue Mar 17, 2015 9:14 am

Re: [PR# 3616] add recent macros to macro menu

Postby chrisb » Sat Jul 04, 2020 6:59 am

TheMarkster wrote:
Fri Jul 03, 2020 11:28 pm
I've added to the PR.
I most probably use only the first one anyway. So ctrl+shift1 is okay for me.
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
TheMarkster
Posts: 2049
Joined: Thu Apr 05, 2018 1:53 am

Re: [PR# 3616] add recent macros to macro menu

Postby TheMarkster » Sat Jul 04, 2020 5:59 pm

If we are to have the submenu as I have it currently, then having a separate menu item for the last one used seems superfluous since you can always use Ctrl+Shift+1 to execute it. So, it's a question of either just the last macro /or the list of most recently used macros. I like having the recent macros list as a submenu because I have a very long list of macros in the Macro -> Macros menu. My use case isn't going to be typical, but I suspect at least some others will also have a long list of installed macros. And since it isn't an inconvenience for those with only 1 macro installed to have the submenu list, I say go with the submenu list.

Should we limit keyboard shortcuts only to the last 3 or 4 macros used and not for the last 9? I doubt anyone will be able to memorize them in the order of most recently used, and as openBrain points out, the shortcuts will change dynamically anyway. It might be sensible to limit to only the last 3 or 4, but here again, if there is no inconvenience to having the additional shortcuts, then might as well have them as not. There can also be the case where a user wants to run a certain macro at a later time. He can view the recent list to see which shortcut to use (for example, it might be Ctrl+Shift+7), then use that shortcut when ready to run the macro. Only downside I see to having all 9 is it increases potential for conflicting with other custom shortcuts (or possibly shortcuts used in workbenches I don't personally use).
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
mario52
Posts: 3235
Joined: Wed May 16, 2012 2:13 pm

Re: [PR# 3616] add recent macros to macro menu

Postby mario52 » Sun Jul 05, 2020 11:08 am

hi

recent macros list is good idea and without shortcuts

maybe include also in the Macro dialog (second window or tab)

thanks

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting, Dialog creation. My macros on Gist.github.
cadcam
Posts: 73
Joined: Thu Apr 02, 2020 10:39 am

Re: [PR# 3616] add recent macros to macro menu

Postby cadcam » Sun Jul 05, 2020 2:03 pm

Can I vote for including some sort of linking of shortcuts to recent macros. I can see the potential issue with a dynamic list, perhaps a toggle/pulldown menu (1->9, + release) to temporarily lock the standard shortcuts, Ctrl+Shift+1-9 or similar, to a specific macro might work

Feel free to ignore