Resources directory/folder for FC Macros?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Resources directory/folder for FC Macros?

Post by melwynfranciscarlo »

I was wondering, why isn't there a temporary folder/directory like the "tmp" or "pycache" folder for the Macros?

Wouldn't it be cool to have predefined src, temp and UI folders to store all the core data, temporary data and UI files respectively?

So like within each of the above mentioned folders, those who want to store data in them could create sub-directories named according to their Macro titles. This would make the Macros directory look more neat and organized.


Like this :

Code: Select all

FreeCAD
     -> Macros
          -> src
               -> abc
                    -> main_function.py
                    -> sub_functions.py
          -> tmp
               -> abc
                    -> upload_cache.tmp
                    -> computation_dump.tmp
               -> xyz
                    -> temp_proc.tmp
          -> ui
               -> xyz
                    -> dialog_1.ui
                    -> dialog_2.ui
          -> abc.FCMacro
          -> xyz.FCMacro
8-) MFC Boy: the one and only! 8-)
User avatar
onekk
Veteran
Posts: 6199
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Resources directory/folder for FC Macros?

Post by onekk »

Good Idea, and strange that the Macro command will not traverse the directory.

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/
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Resources directory/folder for FC Macros?

Post by melwynfranciscarlo »

onekk wrote: Sat Mar 13, 2021 11:08 am Good Idea, and strange that the Macro command will not traverse the directory.

Regards

Carlo D.

Thank you, Carlo D. What macro command are you talking about?
If you're talking about FreeCAD not downloading the macro directories, then check out this discussion.
8-) MFC Boy: the one and only! 8-)
User avatar
onekk
Veteran
Posts: 6199
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Resources directory/folder for FC Macros?

Post by onekk »

No I speak of the internal command that is issued when you type the Macro command in the menu.

related to the way it compose the content of the Macro windows when the user macro are listed if found in the user/Macro directory.

Probably it read the directory and show in the list only the files.

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/
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Resources directory/folder for FC Macros?

Post by melwynfranciscarlo »

Oh! No, I meant the external structure of organising the file and folders within the Macro directory; you know, like a convention or a system.
8-) MFC Boy: the one and only! 8-)
galou_breizh
Posts: 436
Joined: Wed Sep 15, 2010 9:38 am

Re: Resources directory/folder for FC Macros?

Post by galou_breizh »

The "convention" for macros is

Code: Select all

- ~/.FreeCAD/Macro/
  | - Macro1.FCMacro
  | - Macro1.svg
  | - macro1/
       | - resource
           | - dialog.ui
       | - macro1.py
       | - module1.py
       | - module2.py
  | Macro2.FCMacro
The core algorithm should be in macro1/macro1.py, or any other Python file in the macro1 folder. The advantage of this is that the macro functionalities are callable from FreeCAD's Python console or other macros. The FCMacro file should be just a wrapper, possibly with a UI, to the core algorithms.
Post Reply