Folder Structure for Macros?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 3192
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Folder Structure for Macros?
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?
-
- Posts: 328
- Joined: Tue May 28, 2019 10:51 am
Re: Folder Structure for Macros?
No, you can select another folder or sub-folder.edwilliams16 wrote: ↑Wed Apr 13, 2022 11:31 pm Am I stuck with a flat file system or is there a way around this?
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.
-
- Posts: 73
- Joined: Tue Feb 22, 2022 9:16 pm
Re: Folder Structure for Macros?
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,
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.
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"
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.
Re: Folder Structure for Macros?
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.
-
- Posts: 73
- Joined: Tue Feb 22, 2022 9:16 pm
Re: Folder Structure for Macros?
Hi Chris,
I just realized that the precedence order I proposed needed a tweak. It should have been
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.
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"
Re: Folder Structure for Macros?
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.
Re: Folder Structure for Macros?
I Found myself keep changing folder.it is very time consuming.at the end,I give up using macro almost.spanner888 wrote: ↑Thu Apr 14, 2022 10:50 am Limitation is you can only see content of one folder at a time.
Re: Folder Structure for Macros?
It is more easy just use the OS's open file dialogue box.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"
Re: Folder Structure for Macros?
Don't think it is a practical one. Wb shouldn't has Marco to work.
Re: Folder Structure for Macros?
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.