Resources directory/folder for FC Macros?

Need help, or want to share a macro? Post here!
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Resources directory/folder for FC Macros?

Postby melwynfranciscarlo » Thu Mar 11, 2021 6:46 am

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
Posts: 816
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Resources directory/folder for FC Macros?

Postby onekk » Sat Mar 13, 2021 11:08 am

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

Regards

Carlo D.
Introduzione a FreeCAD in Italiano: https://github.com/onekk/freecad-doc
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Resources directory/folder for FC Macros?

Postby melwynfranciscarlo » Sat Mar 13, 2021 4:14 pm

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
Posts: 816
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Resources directory/folder for FC Macros?

Postby onekk » Sat Mar 13, 2021 4:18 pm

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.
Introduzione a FreeCAD in Italiano: https://github.com/onekk/freecad-doc
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Resources directory/folder for FC Macros?

Postby melwynfranciscarlo » Wed Mar 17, 2021 4:53 pm

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: 354
Joined: Wed Sep 15, 2010 9:38 am

Re: Resources directory/folder for FC Macros?

Postby galou_breizh » Fri Mar 19, 2021 9:25 pm

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.