Folder Structure for Macros?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
edwilliams16
Veteran
Posts: 3179
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Folder Structure for Macros?

Post by edwilliams16 »

My .../Macro folder is getting very disorganized. But if I create a subdirectory in the directory, it isn't visible when I go to Macro|Macros|User Macros. Am I stuck with a flat file system or is there a way around this?
spanner888
Posts: 326
Joined: Tue May 28, 2019 10:51 am

Re: Folder Structure for Macros?

Post by spanner888 »

edwilliams16 wrote: Wed Apr 13, 2022 11:31 pm Am I stuck with a flat file system or is there a way around this?
No, you can select another folder or sub-folder.

To do this, open the macros dialog, then at the bottom on right side of the "User macro location", click on the three dots. This allows you to select another folder, but it can be a little confusing as this browse dialog only shows folder and it can appear your files are missing.

Once you click on "Select Folder" to choose your new folder then the original macros dialog will show the content of the newly selected folder.

Limitation is you can only see content of one folder at a time.
eajmarceau
Posts: 73
Joined: Tue Feb 22, 2022 9:16 pm

Re: Folder Structure for Macros?

Post by eajmarceau »

Couldn't the FreeCAD macro be set up to operate like the OS environment, with a "MacroPATH" which provides a precedence list directories, with defaults, but user-modifiable to include other directories?

I would propose an initial breakdown as follows,

Code: Select all

MacroPATH = "${FreeCAD_HOME}/MACROS__User:\
    ${FreeCAD_HOME}/MACROS__Test:\
    ${FreeCAD_HOME}/MACROS__Installed:\
    ${FreeCAD_HOME}/MACROS__System"
I see User as a shared "contrib" library, Test for the obvious trial codes, Installed for the code shared by all users and "promoted" and "frozen" by the user admin, and System for code that is imported as-is from external source for shared use.

As for the GUI, my vision of it would be to present all scripts, from all the folders in a single selections list, but segregated in that same precedence hierarchy, with User items at the top, System items at the bottom, alphabetical sort within each grouping and with the basename of the script presented in the first column ... and the path to each presented in the second column, which is then used by the click action to locate the specified script for execution.

I believe that approach would be of benefit to all.

Being a newbie here, and not knowing Python yet, I can only propose concepts on approaches to meet a need. :)
User avatar
chennes
Veteran
Posts: 3905
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Folder Structure for Macros?

Post by chennes »

I have plans to work on this in the 0.21 dev cycle, so we can improve macros installed as part of a larger addon package.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
eajmarceau
Posts: 73
Joined: Tue Feb 22, 2022 9:16 pm

Re: Folder Structure for Macros?

Post by eajmarceau »

Hi Chris,

I just realized that the precedence order I proposed needed a tweak. It should have been

Code: Select all

MacroPATH = "${FreeCAD_HOME}/MACROS__Test:\
    ${FreeCAD_HOME}/MACROS__User:\
    ${FreeCAD_HOME}/MACROS__Installed:\
    ${FreeCAD_HOME}/MACROS__System"
since you want test versions to come up before production and those would "drop" out of "Test" and into one of the others when "promoted". Also, would it sound reasonable to have such a directory tree precedence established for each WorkBench, so that it would be easy for general users to "drop-in" test code when try-outs are solicited ... and to remove those after doing the testing, thereby making less risky and effort for general users to be willing to come forward for testing ? Just a thought. :)
User avatar
chennes
Veteran
Posts: 3905
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Folder Structure for Macros?

Post by chennes »

The per-workbench idea is what I have planned for the next dev cycle: I want to be able to find macros in each installed mod's directory, rather than having to copy them all to a central directory. Once we have arbitrary directory support you can choose to structure your macros however you like, with various test and production directories.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Folder Structure for Macros?

Post by johnwang »

spanner888 wrote: Thu Apr 14, 2022 10:50 am Limitation is you can only see content of one folder at a time.
I Found myself keep changing folder.it is very time consuming.at the end,I give up using macro almost.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Folder Structure for Macros?

Post by johnwang »

eajmarceau wrote: Sat Apr 23, 2022 2:29 am Couldn't the FreeCAD macro be set up to operate like the OS environment, with a "MacroPATH"
It is more easy just use the OS's open file dialogue box.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Folder Structure for Macros?

Post by johnwang »

chennes wrote: Thu May 12, 2022 3:06 pm The per-workbench idea
Don't think it is a practical one. Wb shouldn't has Marco to work.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
chennes
Veteran
Posts: 3905
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Folder Structure for Macros?

Post by chennes »

johnwang wrote: Fri May 13, 2022 1:06 pm Don't think it is a practical one. Wb shouldn't has Marco to work.
I’m glossing details here: the critical change that enables all of this is support for finding macros in multiple locations. That won’t be limited to workbenches.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply