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.
Adding a text label to the Reroute node manually is very simple – we need to enter the desired text in the “Label” field in the node properties. The entered text will be displayed above the Reroute node in the node tree.
We can add even more convenience and, using a simple script, add a text label to all Reroute nodes at once, which will inform from which output and from which node the link comes to this Reroute.
First, we need to get a pointer to the Geometry Nodes modifier of the currently active object.
1 |
gn = bpy.context.object.modifiers['GeometryNodes'] |
Now we can get a list of all Reroute nodes through the modifier node tree by type.
1 |
rerouters = [node for node in gn.node_group.nodes if node.type == 'REROUTE'] |
We can view the current labels through the “label” property of the node.
1 2 3 4 5 6 |
for reroute in rerouters: print(reroute.label) # label_1 # Hello World! ... |
We can set the desired test for Reroute labels also through the “label” property.
To get the name of the node and the name of the output from which the link comes to the Reroute node, we can use the “links” property of the Geometry Nodes node tree, which stores a list of all links. In the properties of each link, there is a pointer to the node and its input/output to which this link is connected.
Filter only those links in which the end node is the Reroute node.
1 2 |
links_to_retoute = [link for link in gn.node_group.links if link.to_node.type == 'REROUTE'] |
Loop through the resulting list of links. For each end Reroute node, set the value of the “label” property in the “node name – output name” format, taken from the start node of the link.
1 2 |
for link in links_to_retoute: link.to_node.label = link.from_node.name + ' - ' + link.from_socket.name |
Now all Reroute nodes are indicated with a label, which shows us the node and its output, which serve as a source of data for this Reroute node.