How to get which tool is active

This “bpy.ops.wm.tool_set_by_id()” python command can set a tool as active tool.
Is there any way to detect which Tool currently is active?

2 Likes

bpy.context.workspace.tools.from_space_view3d_mode(“EDIT_MESH”, create=False).idname

The only drawback to this method is that you already need to know what mode you’re in, and pass it to tools.from_space_view3d_mode. In this example I’ve passed in EDIT_MESH. from the auto-docs, valid options include:

EDIT_MESH’, ‘EDIT_CURVE’, ‘EDIT_SURFACE’, ‘EDIT_TEXT’, ‘EDIT_ARMATURE’, ‘EDIT_METABALL’, ‘EDIT_LATTICE’, ‘POSE’, ‘SCULPT’, ‘PAINT_WEIGHT’, ‘PAINT_VERTEX’, ‘PAINT_TEXTURE’, ‘PARTICLE’, ‘OBJECT’, ‘PAINT_GPENCIL’, ‘EDIT_GPENCIL’, ‘SCULPT_GPENCIL’, ‘WEIGHT_GPENCIL’

4 Likes

Cool, this is exactly what I need.
Getting mode is easy the “bpy.context.mode” already return that.

Thank you

2 Likes