Selecting a Tool in Blender 3.6 using the Blender Python API

To switch the active tool using the Blender Python API, we must use the wm.tool_set_by_id operator, passing the identifier of the required tool in its parameter. In earlier versions of Blender, to call this operator from an area with a different context, for example, from the Text Edit area, it was necessary to override the context.

In Blender 3.6 this operator can be executed either by temporarily overriding the context with “temp_override”, or by passing the type of the area for which the operator is called in its parameter.

Executing a tool select operator using a temporary context override

As usual, we first get a pointer to the area in which context we need to execute the operator.

Next, using “temp_override”, we execute the operator for the required area:

Executing the tool select operator specifying the area in the operator parameter

It is much easier to call the same operator for the required area if its type is passed in the space_type parameter of the operator itself.

The result of using both ways in your code is the same.

0 0 votes
Article Rating
Notify of

0 Comment
Inline Feedbacks
View all comments