List tools and settings in workbenches

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
yoshua
Posts: 13
Joined: Sat Dec 03, 2022 3:13 am

List tools and settings in workbenches

Post by yoshua »

dir(Part) was only one who succeeded.

This seems incomplete

Code: Select all

>>> import PartDesign
>>> dir(PartDesign)
['InvoluteGearFeature', 'SprocketFeature', 'WizardShaft', '_PartDesign', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'makeFilletArc']

How about revealing the settings of these tools without creating object?

>>> dir(Part.Toroid.Axis)
returns class methods.

If the object exists this works
>>> doc.Toroid.PropertiesList

this is a nice list. How to access further?
>>> Gui.listCommands()

or how to extend this idea?
carlopav wrote: Fri Apr 03, 2020 3:03 pm
HakanSeven12 wrote: Fri Apr 03, 2020 2:37 pm
Kunda1 wrote: Fri Apr 03, 2020 2:35 pm I see. Do we even know if this function is exposed through the Python API?
That is the the purpose of that thread :D
try this quick macro:

Code: Select all

from PySide import QtGui

mw = Gui.getMainWindow()

wbs=Gui.listWorkbenches()

for k in wbs.keys():
    Gui.activateWorkbench(k)
    print("WORKBENCH: "+k)
    tbs = mw.findChildren(QtGui.QToolBar)
    for t in tbs:
        if t.isVisible():
            print("--> "+t.objectName())
            for a in t.actions():
                print("----> "+a.objectName())
you have to customize it a bit I think, and it works just with installed wbs.
This is the result on my system:

Code: Select all

WORKBENCH: NoneWorkbench
--> DynamicData Commands
----> DynamicDataCreateObject
----> DynamicDataAddProperty
----> DynamicDataRemoveProperty

----> 
--> Draft creation tools
----> Draft_Line
----> Draft_Wire
----> Draft_Circle
----> Draft_Ellipse
----> Draft_Rectangle
etc,etc
or for active WB, similar to above
>>> wb=Gui.activeWorkbench()
>>> wb.getToolbarItems()

:D any idea?

thanks
Post Reply