Hello everyone! As a disclaimer, I am not a C++ coder, but I can do Python, however I don't mind learning C++ if it is the better way to solve a problem.
If I go to Tools->Customize->Keyboard tab, I can select from a list of categories, see their commands, and then assign shortcuts to them. I noticed that the "Draft" workbench is not there. I can also see that the Draft workbench keyboard shortcuts are hardcoded.
I'd like to add the draft workbench's commands to this command manager, so that users can customise their commands.
Questions:
1. A quick look at the C++ makes me think that I need to add the command to the commandManager. Since the Draft WB is written in Python, can I write a bit of C++ that somehow adds the Python defined commands into the C++ Command Manager?
2. Alternatively, perhaps I can write some Python bindings for the commandManager class?
Any hints would be appreciated on the best approach to solve this.
How to create shortcuts for the Draft workbench, and calling commandManager from Python
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
How to create shortcuts for the Draft workbench, and calling commandManager from Python
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
Re: How to create shortcuts for the Draft workbench, and calling commandManager from Python
They are there but likely in not all that obvious place. After Draft workbench gets activated look again under i guess the Python entry.
This therefore should already be possible.I'd like to add the draft workbench's commands to this command manager, so that users can customise their commands.
As for some additional hints, there is ShortCuts module.Any hints would be appreciated on the best approach to solve this.
Re: How to create shortcuts for the Draft workbench, and calling commandManager from Python
Thank you triplus. I didn't notice the Python entry.
Is there another way to add a customisable shortcut to that list without it having to be a command? For example, the "draft" workbench has what are called "in-command shortcuts". E.g. once you are already inside a command, pressing a single key will toggle a mode within that command. These keys are being listened to by keyboard events, but are not technically a command and therefore don't show up in that module.
Is there another way to add a customisable shortcut to that list without it having to be a command? For example, the "draft" workbench has what are called "in-command shortcuts". E.g. once you are already inside a command, pressing a single key will toggle a mode within that command. These keys are being listened to by keyboard events, but are not technically a command and therefore don't show up in that module.
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
Re: How to create shortcuts for the Draft workbench, and calling commandManager from Python
Okay I see you found a way that is good for now...
My original idea was this: for each of the Draft shortcuts, create a dummy FreeCAD command (a class with its getResources() dictionary)). That command would basically just do nothing at all. But it would get registered by FreeCAD, and appear in the keyboard shortcuts config screen, where users can change shortcuts. All shortcuts that are changed by the users that way, get an own entry in the preferences ( BaseApp/Preferences/Shortcut), so it's also easy to look them up from Python
My original idea was this: for each of the Draft shortcuts, create a dummy FreeCAD command (a class with its getResources() dictionary)). That command would basically just do nothing at all. But it would get registered by FreeCAD, and appear in the keyboard shortcuts config screen, where users can change shortcuts. All shortcuts that are changed by the users that way, get an own entry in the preferences ( BaseApp/Preferences/Shortcut), so it's also easy to look them up from Python