API

Calculating a rotation matrix from one vector to another

Aligning one plane to another is a common task in 3D modeling. The easiest way to align planes is by using their normal vectors – we need to rotate the original plane so that its normal vector coincides with the normal vector of the plane for which the alignment is performed. Therefore, the task of rotating one plane to another can be reduced to the problem of rotating the normal vector of the first place to the normal vector of the second plane.

Hiding all inputs and outputs on nodes in Blender using Python API

For ease of display, all input and output sockets on nodes, both shader and geometry, can be hidden from the user. Hiding unused node inputs and outputs may be necessary to simplify the visual perception of the node tree, which can be very large and complex and does not need to be overloaded with unnecessary information.

Polygons and triangles correspondence after triangulating a mesh in Blender

One of the methods for mesh analytics is exploring its triangulated geometry. For example, such exploration is used when searching for polygons that overlaps in the mesh itself or in its UV. In order to return the result obtained after analyzing the triangulated mesh back to the original mesh, we need to know the exact correspondence between the original polygon and the triangles created from it.

Working with inputs and outputs for the Capture Attribute Node in Blender Geometry Nodes

Starting with Blender 4.2, the Capture Attribute node has changed in functionality. If earlier this node always had only one “Value” input and only one “Attribute” output, intended for recording attributes, in addition to the standard geometry socket, then starting with version 4.2, the number of inputs/outputs for recording attributes has been made dynamic.

Selecting edges on the boundaries of a mesh in Blender

It is often necessary to select all the boundary edges of a mesh – edges that are on the outer perimeter of the mesh, or located around areas of the mesh that are not filled by polygons. This operation can be performed by the user from the 3D Viewport menu: Select – Select Loops – Select Boundary Loop.

Creating a custom UI window in Blender using PySide

The Blender Python API provides add-on developers with quite a wide range of options for designing a user interface. However, sometimes the built-in capabilities of the Blender API may not be enough. We can create a window with a UI that is completely independent of the built-in API by connecting and using the PySide module.

Getting the active property value in Blender using context

To get the current active object in a Blender scene, we usually use the context and its context.object (or context.active_object) property. Similarly, when working with the interface, we can access the context to get the currently active property – the value of the field in the Blender UI over which we hover the cursor or on which we clicked with the mouse. The context.property value is used for this.