Plugin Loader
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: Plugin Loader
It would be really cool if the Macros on the wiki could be dynamically linked with their twin entry in the Github repo... But I doubt it could be done. Keeping them up to date will be a hassle.
Re: Plugin Loader
Actually if the macros are hosted on a repo, I don't think one needs to see the whole code directly on the wiki... We could have a link instead...
Re: Plugin Loader
Of course you're right. Doh!
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Plugin Loader
Here my idea how to manage Macros. I have checked into the repo this example for test and discussion
https://github.com/FreeCAD/FreeCAD-macr ... fafb23abe5
Every Macro has its own directory (example myMacroDir)
with at least one python File myMacro.py and a __init__.py to control imports
If there is no __init__.py and only one python file in the directory it will be created automaticly, but for special effects the macro texter can write his one initfile.
The master file myMacro.py must have a main() function, which executes the macro.
It can have a test() function to check the success of the install process.
Example
In the Macrofolder there will be a Macro created by the plugin installer:
myMacroDir.FCMacro - this can be used from the Macro Menu
It would be nice to have a releaselog file in the dir to get information about the development state of the macro.
this news information can be composed with the wiki-page in the pluginviewer for the enduser. Maybe that releaseinfo also can be obtained by the git log but no every body will have write access to the git and can write his log into the commit, so there is more freedom to write a private log.
I think there should not be big problems to convert the existing macros in this manner. But its still a suggestion and i'm hoping for feedback.
https://github.com/FreeCAD/FreeCAD-macr ... fafb23abe5
Every Macro has its own directory (example myMacroDir)
with at least one python File myMacro.py and a __init__.py to control imports
If there is no __init__.py and only one python file in the directory it will be created automaticly, but for special effects the macro texter can write his one initfile.
The master file myMacro.py must have a main() function, which executes the macro.
It can have a test() function to check the success of the install process.
Example
Code: Select all
#
# your copyright info here
#
import FreeCAD
#
# the macro should have a test method to check the success of the installation
#
def test():
errorMsg="There are some errors: a, b, c"
warnMsg="There are some warnings: d, e"
infoMsg="There is a info: f"
errors=3
warns=2
infos=1
result=[errors,errorMsg,warns,warnMsg,infos,infoMsg]
return result
#
# the macro should have a main method - the macro itself
#
def main():
t=FreeCAD.ParamGet('User parameter:BaseApp/Preferences/Macro')
mp=t.GetString("MacroPath")
FreeCAD.Console.PrintMessage("\n"*4+"H E L L O W O R L D,\n I'm myMacro.py located in "+ mp+ "/MyMacroDir" + "\n"*4)
myMacroDir.FCMacro - this can be used from the Macro Menu
Code: Select all
#----------------------------------------------------
# generated by plugin installer
FreeCAD.Console.PrintMessage("\ntry Macro myMacroDir.MyMacro ...\n")
try:
import myMacroDir
reload(myMacroDir.myMacro)
myMacroDir.myMacro.main()
FreeCAD.Console.PrintMessage("\nmyMacroDir.MyMacro done\n")
except:
FreeCAD.Console.PrintError("\nError Macro myMacroDir.MyMacro\n")
#----------------------------------------------------
this news information can be composed with the wiki-page in the pluginviewer for the enduser. Maybe that releaseinfo also can be obtained by the git log but no every body will have write access to the git and can write his log into the commit, so there is more freedom to write a private log.
I think there should not be big problems to convert the existing macros in this manner. But its still a suggestion and i'm hoping for feedback.
Re: Plugin Loader
Hm this is cool, but I think it removes one of the main advantages of the macro: it simplicity. If we ask the user to do some heavier modification, we will have much less people ready or able to contribute with macros. And it adds more work to maintainers too, who need to check that things work, adapt existing macros, etc.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Plugin Loader
Okay, i unterstand. So we can handle macros two different ways .
One file macros simple stored in the root directory or a category subfolder and complex macros in a subfolder in the descibed way?
One file macros simple stored in the root directory or a category subfolder and complex macros in a subfolder in the descibed way?
Re: Plugin Loader
Yes that seems a good solution...
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Plugin Loader
]After some trouble with the menusystem I have found a way to bring up the plugininstaller automaticly on startup.
It will be available as dockwindow.
So now its time to classify the plugins
Simple macros start their life as one file.
If they become complex more over time files can be added: a library to store common function, some icons to beautify it.
If a macro has more then one file there should be the macrofilename MyMacro.FCMacro
and the same name for the directory to collect helper files (without the suffix).
python specific access control to the directory can be done by the __init__.py inside.
In this way macros can share libraries.
Macros are accessable through toolbars.
Behaviour of Macros:
1) silent: click and run without extra interaction
2) one starting dialog for configuration: example unfold box, replace part in assembly
3) always or longer time open: Work Feature
There are already addons which life in a dockwindow (but are not macros)
bolts
part library
drawing symbol library
I love the dockwindow because I can freely arrange all my windows and I often undock windows
to the other screen to get more space to the work area without loosing access to teh tools.
My idea is: long living dialogs should live as dockwindows.
Hide and show can be controlled by pluginloader menu.
The can be stored in the FreeCAD params and reactivated automaticly on freecad startup.
Workbenches can organize themselve, they have the ability to create menu, toolbars, contextmenues.
They only have to be installed/updated.
EDIT: picture replaced
It will be available as dockwindow.
So now its time to classify the plugins
Simple macros start their life as one file.
If they become complex more over time files can be added: a library to store common function, some icons to beautify it.
If a macro has more then one file there should be the macrofilename MyMacro.FCMacro
and the same name for the directory to collect helper files (without the suffix).
python specific access control to the directory can be done by the __init__.py inside.
In this way macros can share libraries.
Macros are accessable through toolbars.
Behaviour of Macros:
1) silent: click and run without extra interaction
2) one starting dialog for configuration: example unfold box, replace part in assembly
3) always or longer time open: Work Feature
There are already addons which life in a dockwindow (but are not macros)
bolts
part library
drawing symbol library
I love the dockwindow because I can freely arrange all my windows and I often undock windows
to the other screen to get more space to the work area without loosing access to teh tools.
My idea is: long living dialogs should live as dockwindows.
Hide and show can be controlled by pluginloader menu.
The can be stored in the FreeCAD params and reactivated automaticly on freecad startup.
Workbenches can organize themselve, they have the ability to create menu, toolbars, contextmenues.
They only have to be installed/updated.
EDIT: picture replaced
- Attachments
-
- bn_652.png (80.81 KiB) Viewed 2843 times
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Plugin Loader
This week I will finish macro substitution and platform depended switches in the configuration file:
Next Step: I will prepare templates for the mostly used plugins. But I do not know them all. Community, please tell me what/whre are interesting !
Which workbenches do exist and are in use?
I found these (and will integrate them step by step)
http://www.freecadweb.org/wiki/index.ph ... d_projects
http://www.freecadweb.org/wiki/index.ph ... os_recipes
Which operating systems I have do support?
import platform
os=platform.system() --> Linux, Windows ???
current state:
Code: Select all
defaulttest:
status: ignore
destdir:
Linux: UserAppData/Mod/testdir
Windows: c:/haha
backup: UserHomePath/tmp/bak_
icon: AppHomePath/Mod/plugins/icons/master.png
Which workbenches do exist and are in use?
I found these (and will integrate them step by step)
http://www.freecadweb.org/wiki/index.ph ... d_projects
http://www.freecadweb.org/wiki/index.ph ... os_recipes
Which operating systems I have do support?
import platform
os=platform.system() --> Linux, Windows ???
current state:
- Attachments
-
- bn_653.png (75.75 KiB) Viewed 2813 times
Re: Plugin Loader
This is becoming very impressive. Great job microelly!
I think you have all the most important ones already...
I think you have all the most important ones already...