API

Showing custom UI panel in Blender by pressing keycodes

When creating add-ons for Blender, developers almost always create the user UI panel with tools that provide the main functionality of the add-on. Typically, such custom panels are placed in the N-panel block, called by pressing the N key. However, if it is assumed that the user will often call the panel with add-on tools, its call can be bound to a keyboard shortcut and the panel can be called from the keyboard.

Setting an icon from the tools panel to a button in the custom UI panel in Blender

To set an icon to a button when creating the custom user UI panel in Blender, we look for the text identifier of the desired icon (usually using the built-in Icon Viewer add-on) and set its value to the “icon” parameter when binding the desired operator to the button. However, the icons used in the tools panel are not existed in the common Blender icons list.

Moving node tree to the node editor area origin

In Blender, when creating complex procedural materials or geometry nodes, the node tree often moves away from the starting point of the node editor area. Later, when working with materials, this causes some inconvenience – when switching from material to material, the node tree “runs away” and we have to scroll the screen each time to see the nodes. This problem can be solved using a simple script that will move the entire node tree to the origin of the node editor area.

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.