Macro store locations
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Macro store locations
Hi,
Just one simple questions: is it possible, as the GUI suggests, that we have a user and a system macro location?
If yes, where is this system macro location? I searched on google but was unable to find anything.
My team members and me are working on many geometries. We have macros that are "static" and everyone runs them in the same version. Then we have macros, which are specific for a certain geometry.
The static macros are attached to a toolbar in the GUI so we can quickly access them. Problem is, once we change the macro location in the settings to access the geometry-specific macros, the attached macros at the toolbar are no longer found.
Is there a way to have some macros in a static directory (system macros) and other in a user directory? How the GUI is designed, tells me that someone intended it that way, but I dont know how it works.
Thanks for any hints.
Just one simple questions: is it possible, as the GUI suggests, that we have a user and a system macro location?
If yes, where is this system macro location? I searched on google but was unable to find anything.
My team members and me are working on many geometries. We have macros that are "static" and everyone runs them in the same version. Then we have macros, which are specific for a certain geometry.
The static macros are attached to a toolbar in the GUI so we can quickly access them. Problem is, once we change the macro location in the settings to access the geometry-specific macros, the attached macros at the toolbar are no longer found.
Is there a way to have some macros in a static directory (system macros) and other in a user directory? How the GUI is designed, tells me that someone intended it that way, but I dont know how it works.
Thanks for any hints.
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Macro store locations
Enter into the python console:
Navigate to that folder and create a new folder in it called 'Macro'. Place a few macros into there. Now when you open the Macros dialog and click the system tab you will see these macros in that HomePath/Macro folder.
I put one in my folder named search.FCMacro:
Once you execute it you can run it again via the Recent Macros menu.
You can also add it to a toolbar. The system macros will appear at the bottom (actually the top) of the list in the customize dialog. This will enable you to have 2 folders for macros. Another use for this could be to have some commonly used macros in that tab if you have a lot of macros that require a lot of scrolling to find.
But there is a down side. For me (on windows) the folder is in the folder that 7-zip creates when extracting a new weekly build. I update to a new weekly build by deleting the old folder after extracting the new .7z file into the new one. The new folder then becomes the new home folder. I would need to take care not to also delete that macro folder when updating to a newer weekly build, and I would also need to move the Macro folder into the new home folder.
Code: Select all
App.getHomePath()
I put one in my folder named search.FCMacro:
Once you execute it you can run it again via the Recent Macros menu.
You can also add it to a toolbar. The system macros will appear at the bottom (actually the top) of the list in the customize dialog. This will enable you to have 2 folders for macros. Another use for this could be to have some commonly used macros in that tab if you have a lot of macros that require a lot of scrolling to find.
But there is a down side. For me (on windows) the folder is in the folder that 7-zip creates when extracting a new weekly build. I update to a new weekly build by deleting the old folder after extracting the new .7z file into the new one. The new folder then becomes the new home folder. I would need to take care not to also delete that macro folder when updating to a newer weekly build, and I would also need to move the Macro folder into the new home folder.
Re: Macro store locations
Sorry I didnt mention my os, I am on Windows.
Thanks alot for your answer TheMarkster, this is exactly what I was looking for. I tested it, and it works nicely.
I can see the downside, but its not so important for me. We tend to use a constant version as long as possible and don't regularly update to newer builds. In case we do, I will keep in mind to look for the macros.
So, thank you again!
To me it seems to be a bug, that macros that are attached to a toolbar shortcut are dependent on the setting of the macro folder, but "recent macros" are not. Should I open a bug report for that?
Thanks alot for your answer TheMarkster, this is exactly what I was looking for. I tested it, and it works nicely.
I can see the downside, but its not so important for me. We tend to use a constant version as long as possible and don't regularly update to newer builds. In case we do, I will keep in mind to look for the macros.
So, thank you again!
To me it seems to be a bug, that macros that are attached to a toolbar shortcut are dependent on the setting of the macro folder, but "recent macros" are not. Should I open a bug report for that?
Re: Macro store locations
What type of installation are you using in Windows "Portable Builds" or "Installer", even this thing should be known by developers or "power users".
As example there are some "SYSTEM VARIABLES" that could be set to modify user directory and maybe places where FreeCAD is searching for things.
But they are managed differently as in Windows you have the "Registry" that when using a "Portable Build" is not touched, so answer could differ based on installation methods.
On Linux I use three version of FreeCAD with three user directory that not interfere between them, but i could use symlinks to place Macro in a common directory where they effectively reside, but Macros are Spread across different installation. Windows as a similar mechanism, so so maybe you could place some symlinks to "net mounted" directories, if you don't have problem to properly set access permission.
Regards
Carlo D.
As example there are some "SYSTEM VARIABLES" that could be set to modify user directory and maybe places where FreeCAD is searching for things.
But they are managed differently as in Windows you have the "Registry" that when using a "Portable Build" is not touched, so answer could differ based on installation methods.
On Linux I use three version of FreeCAD with three user directory that not interfere between them, but i could use symlinks to place Macro in a common directory where they effectively reside, but Macros are Spread across different installation. Windows as a similar mechanism, so so maybe you could place some symlinks to "net mounted" directories, if you don't have problem to properly set access permission.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Macro store locations
Hi
tested in "C:/Temp/Testéééèèçç/CloneConvert.FCMacro" and other directory and run well
open run and close the macroEditor totally hidden for the user
just cretate the bouton
(inspired by the Triplus idea GUI improvement request : Save & Run Button)
mario
tested in "C:/Temp/Testéééèèçç/CloneConvert.FCMacro" and other directory and run well
open run and close the macroEditor totally hidden for the user
just cretate the bouton
Code: Select all
import FreeCADGui
FreeCADGui.open(u"Complete_Path_of_The_Macro/MacroYouUse.FCMacro")
Gui.SendMsgToActiveView("Run")
Gui.runCommand('Std_CloseActiveWindow',0)
(inspired by the Triplus idea GUI improvement request : Save & Run Button)
mario
Last edited by mario52 on Fri Dec 10, 2021 1:09 pm, edited 1 time in total.
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: Macro store locations
I have long wondered about the Macro dialog and how it displays the macro directory.
If, for example, you have multiple versions running out the <build directory>/bin, then
returns the <build directory>
But,
the return is (on Linux) ~/.local/share/FreeCAD/Macro/
But, if Parameters Macro>MacroPath is set then the dialog shows the macros there. (In my case set to a network drive, which is not represented by any of the directories returned by the above Python methods) so all my machines access a single source for Python/macro files.)
Since the dialog apparently looks only the specified directory and not subdirectories it doesn't allow for much organization of the user macros. They all must reside in a single level and become a huge list. (I suppose this is not to much of a problem for the typical user who only has a limited number of macros/Python files...)
If, for example, you have multiple versions running out the <build directory>/bin, then
Code: Select all
App.getHomePath()
But,
Code: Select all
App.getUserMacroDir()
But, if Parameters Macro>MacroPath is set then the dialog shows the macros there. (In my case set to a network drive, which is not represented by any of the directories returned by the above Python methods) so all my machines access a single source for Python/macro files.)
Since the dialog apparently looks only the specified directory and not subdirectories it doesn't allow for much organization of the user macros. They all must reside in a single level and become a huge list. (I suppose this is not to much of a problem for the typical user who only has a limited number of macros/Python files...)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Macro store locations
Code: Select all
App.getUserMacroDir()
Instead, use:
Code: Select all
App.ParamGet("User parameter:BaseApp/Preferences/Macro").GetString("MacroPath", App.getUserMacroDir())
Re: Macro store locations
You are correct, IMHO the correct syntax is:TheMarkster wrote: ↑Fri Dec 10, 2021 4:48 pmdoes not return the correct directory for me. It gives the default directory instead, but I changed it in the dialog to put them in my documents folder.Code: Select all
App.getUserMacroDir()
Code: Select all
App.getUserMacroDir(True)
-
- Veteran
- Posts: 5513
- Joined: Thu Apr 05, 2018 1:53 am
Re: Macro store locations
Thanks for this. I did not think to check the documentation.
Code: Select all
help(App.getUserMacroDir)
Help on built-in function getUserMacroDir in module FreeCAD:
getUserMacroDir(...)
getUserMacroDir(bool=False) -> stringGet the directory of the user's macro directory
If parameter is False (the default) it returns the standard path in theuser's home directory, otherwise it returns the user-defined path.