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.

However, this way, we can only add the field itself to the user panel. What should we do if we want to include additional properties of the socket there, such as, for example, its minimum and maximum possible values?

First, let’s create a base class for our custom panel:

Don’t forget to register it in the Blender Python API so that the panel will appear in the 3D viewport area.

Inside the draw() function, we will define a property that we will associate with the desired socket of the Geometry Nodes node. This is the field that we can see on the modifier panel.

A pointer to the Geometry Nodes modifier.

Define the property field on our panel.

In order to display the min/max values ​​for a given socket on the panel, we will need to access them directly through the socket.

We can access the socket through the “interface” object of the node tree.

Get a pointer to it.

Pointers to all input and output sockets are in the “items_tree” list of the “interface” object.

Let’s find the socket we need, by its type (input/output) and name.

The properties for setting the maximum and minimum value of a socket are called “min_value” and “max_value”.

Having a pointer to the socket, we can now display these properties on our panel by creating the corresponding properties.

For maximum value:

And for the minimum value:

The complete code for our draw() function:

So, we made it possible to edit the socket value itself, as well as its maximum and minimum values.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments