Thanks @wmayer
[Help] How to get WBs, Toolbars, Tools
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: [Help] How to get WBs, Toolbars, Tools
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
- HakanSeven12
- Veteran
- Posts: 1481
- Joined: Wed Feb 06, 2019 10:30 pm
Re: [Help] How to get WBs, Toolbars, Tools
Support me: Hakan Seven on Patreon
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
- HakanSeven12
- Veteran
- Posts: 1481
- Joined: Wed Feb 06, 2019 10:30 pm
Re: [Help] How to get WBs, Toolbars, Tools
Hi. I can get every command by using this code. But some commands are command groups. How can I get the commnds of command group?wmayer wrote: ↑Sat Apr 04, 2020 9:49 am git commit 8663e724f
Code: Select all
wb=Gui.activeWorkbench() wb.getToolbarItems()
For example I want to get this commands.
Code: Select all
workbenches = Gui.listWorkbenches()
for wb_name in workbenches:
Gui.activateWorkbench(wb_name)
wb = Gui.getWorkbench(wb_name)
items = wb.getToolbarItems()
for i in items:
#if i in pass_list: pass
tb_name = i
toolbar = items[i]
for cmd in toolbar:
command = Gui.Command.get(cmd)
print(command)
Support me: Hakan Seven on Patreon
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Re: [Help] How to get WBs, Toolbars, Tools
I see. This is currently not possible. What we need is a way to check if a QAction has a QMenu and if yes also list its items.HakanSeven12 wrote: ↑Sun Nov 22, 2020 7:21 pm Hi. I can get every command by using this code. But some commands are command groups. How can I get the commnds of command group?
For example I want to get this commands.
command group.png
- HakanSeven12
- Veteran
- Posts: 1481
- Joined: Wed Feb 06, 2019 10:30 pm
Re: [Help] How to get WBs, Toolbars, Tools
When I created Modern UI, I accessed to qpushbuttons in toolbars. But İt's just a work around. So I don't like this method. If there is another way, it would be good for me.
Support me: Hakan Seven on Patreon
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Re: [Help] How to get WBs, Toolbars, Tools
git commit b3200a8a9 implements a way to get the QAction of a Command. This function always returns a list which can
From a QAction you should get all the additional information you need. See https://doc.qt.io/qt-5/qaction.html
- be empty if the command is not used yet in a workbench
- have a single element which is the case for the majority of commands
- have several elements for an action group
Code: Select all
cmd = Gui.Command.get("Sketcher_CompCreateRegularPolygon")
cmd.getAction()
Code: Select all
cmd = Gui.Command.get("Sketcher_CreatePoint")
cmd.getAction()
- HakanSeven12
- Veteran
- Posts: 1481
- Joined: Wed Feb 06, 2019 10:30 pm
Re: [Help] How to get WBs, Toolbars, Tools
That was realy quick thanks
Support me: Hakan Seven on Patreon
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Re: [Help] How to get WBs, Toolbars, Tools
Anybody game to document this?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
- HakanSeven12
- Veteran
- Posts: 1481
- Joined: Wed Feb 06, 2019 10:30 pm
Re: [Help] How to get WBs, Toolbars, Tools
I think there must be an UI api for python which UI developers can reach, edit or disable UI objects. Then we can talk about a documentation. Otherwise there is just some code that can reach wbs and their commands.
Support me: Hakan Seven on Patreon
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum
Modern UI: Modern UI on FreeCAD Forum
Trails Workbench: Trails Workbench on FreeCAD Forum