Python

Custom Icons for EnumProperty in Blender

We can use custom icons, icons loaded from external files, and not embedded in Blender libraries, for example, to add customization to operator call buttons in UI panels. However, it is not only buttons that may require custom icons. Using the Blender Python API, we can add customization to drop-down list items or switches that are created based on the EnumProperty type.

Placing Max/Min socket controls of geometry node on the user panel

In order to display the value of a socket on the Geometry Nodes modifier panel in Blender, we simply need to create a link and connect the desired socket of the desired node with an empty socket on the Group Input node. After this, a field appears in the modifier panel in which we can change the value of the desired socket. We can then place this field on the user panel by accessing it as a dynamic property.

Changing the order of sockets in Blender Geometry Nodes groups

We can change the order of sockets in a Blender Geometry Nodes node group manually by simply dragging it – in the N-panel in the Group – Interface tab, hold down the desired socket and drag it with the mouse to the desired place. We can move a socket in a group node to a new location using the Blender Python API with the move() function of the “interface” object.

Labels for Reroute nodes in Blender Geometry Nodes

Did you know that you can set your own text labels for Reroute nodes in Blender Geometry Nodes? Since Reroute nodes are most often used to simplify and improve the readability of node trees in Geometry Nodes, marking such nodes with a label with a short informational inscription can be very convenient – you will not need to remember or scroll through the tree of nodes every time to find out where this Reroute data comes from.

Quickly setting the point at which the light sources in the scene should be directed

When we set up lighting in a scene in Blender, we usually set the direction of the light to the desired point manually for each light source. However, this process can be simplified and we can specify the point to which all selected light sources in the scene will be directed at once.

Moving the Auto Smooth modifier to the end of the modifier list

Since version 4.1, the normal smoothing operator in Blender has been completely replaced by a modifier implemented on the Geometry Nodes mechanism. This is convenient for solving a number of problems, but if the Auto Smooth modifier is not located on the last place in the modifier stack, before other modifiers that change the mesh geometry, this leads to the appearance of artifacts. To quickly move the Auto Smooth modifier to the end of the stack, we can use a simple script.

Working with Mean Bevel Weight using the Blender Python API

To interact with the Bevel modifier, which creates a bevel on specified edges, each of the required edges must be given a specific numeric weight parameter ranging from 0.0 to 1.0. In manual mode, the weight for the bevel is set in the N-panel on the Item tab in Edges Data – Mean Bevel Weight field. This weight can also be read and set via the Blender Python API.

Working with sharp edges using Blender Python API

In Blender, we can mark the edges of the mesh as sharp so that they remain sharp and do not become smooth even when we enabling smooth shading. This can be done manually by selecting the desired edges and pressing the Edge – Mark Sharp items in the main menu. Edges can also be marked as sharp using the Blender Python API.

Working with mesh edges marked for rendering using the Freestyle render engine

To create line-based renderings, such as blueprints or 3D to 2D stylizations, an additional “Freestyle” render engine is usually used with the main render engine. Edges that should be clearly outlined in the final render must be marked as “freestyle” so that the Freestyle render engine can process them.