How about a new "Command" addon type ?
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
How about a new "Command" addon type ?
I'm wondering if community would find useful to have a new "Command" addon type and mechanism.
The goal would be to provide an integration mechanism in between workbench and macros.
It would mainly target the stock workbenches coming with FreeCAD core and would make use of the command manager to offer possibility to externally integrate a single command into the existing workbench toolbars and/or menus.
The advantage is that user downloading them (through the addon manager for example) would have it immediately and automatically integrated as a new feature in the FreeCAD environment.
Also the "Command" addon could benefit for several internal mechanisms (eg to be exclusive with other commands, or to tell in which conditions it is enabled or disabled).
What are your thoughts on this ?
The goal would be to provide an integration mechanism in between workbench and macros.
It would mainly target the stock workbenches coming with FreeCAD core and would make use of the command manager to offer possibility to externally integrate a single command into the existing workbench toolbars and/or menus.
The advantage is that user downloading them (through the addon manager for example) would have it immediately and automatically integrated as a new feature in the FreeCAD environment.
Also the "Command" addon could benefit for several internal mechanisms (eg to be exclusive with other commands, or to tell in which conditions it is enabled or disabled).
What are your thoughts on this ?
Re: How about a new "Command" addon type ?
Python was banned from FreeCAD files for security reasons. Would this by such a Command addon come through the backdoor?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: How about a new "Command" addon type ?
Kind of a tangent I guess..but, just had a conversation with a guy who wanted to have fields in a Python script that would handle expressions and reference a spread sheet.
Is that likely a security thing as well?
Or is it already doable?
Is that likely a security thing as well?
Or is it already doable?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: How about a new "Command" addon type ?
I would answer with a totally non-technical reply : that's not better but not worse than workbenches and macros.
As existing add-ons, that would act only locally on the PC it's installed on, no code would be embedded in files (as Expressions are).
- alonso_jamm
- Posts: 77
- Joined: Mon Nov 11, 2019 11:32 pm
Re: How about a new "Command" addon type ?
There is a way to create commands from macros using Interface_Customization. Then they can be added to any workbench, though the toolbars from the workbenches that come with FreeCAD cannot be modified. In order to add custom macros to the workbenches that come with FreeCAD it is needed to create a new toolbar and then add the macro to the new toolbar.
However, the process of adding a macro into a toolbar can be tedious since it is needed to first create the command for the macro and then add it to the toolbars. Maybe when adding a new macro from the addon manager the macro command could be created automatically using the metadata from the macro. Then the user would only need to add it to the toolbars.
However, the process of adding a macro into a toolbar can be tedious since it is needed to first create the command for the macro and then add it to the toolbars. Maybe when adding a new macro from the addon manager the macro command could be created automatically using the metadata from the macro. Then the user would only need to add it to the toolbars.
Re: How about a new "Command" addon type ?
You don't have to create a macro. You can add a command directly to a personal toolbar.alonso_jamm wrote: ↑Tue Sep 28, 2021 4:13 pm However, the process of adding a macro into a toolbar can be tedious since it is needed to first create the command for the macro and then add it to the toolbars.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: How about a new "Command" addon type ?
I know that but AFAIK (it could be possible that I'm just ignoring things) you can only create "macro launcher". You cannot create "Command" -- as in the FreeCAD meaning -- that get all the mechanisms to be context aware. (I know you can create them with Python API, but I'm discussing a user friendly thing).alonso_jamm wrote: ↑Tue Sep 28, 2021 4:13 pm There is a way to create commands from macros using Interface_Customization. Then they can be added to any workbench, though the toolbars from the workbenches that come with FreeCAD cannot be modified. In order to add custom macros to the workbenches that come with FreeCAD it is needed to create a new toolbar and then add the macro to the new toolbar.
Re: How about a new "Command" addon type ?
Not sure, but I'm afraid it is not possible.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
- alonso_jamm
- Posts: 77
- Joined: Mon Nov 11, 2019 11:32 pm
Re: How about a new "Command" addon type ?
It is almost possible to use a custom command from a single file, but I think you need to add the command from a python module. For example, you could create a module using the namespace structure:
Code: Select all
-CustomCommands/
|-freecad/
|-customcommands/
|-__init__.py
|-init_gui.py
|-mycommand.py
Code: Select all
FreeCADGui.addCommand('My_Command', MyCommand())
Code: Select all
from . import command