From 9bd89c67d259a475affbfdfb768b66b7a18cd9b2 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Wed, 27 Sep 2023 16:45:56 +0200 Subject: [PATCH] Fix node socket connection util after changes to the interface API The `connect_sockets()` node util function is used to connect sockets even when inside node groups, when only a "virtual socket" is available. It takes care of creating the interface in the group, so that a socket is available in the Input or Output node. This feature was broken after the change of API, replacing `tree.inputs` and `tree.outputs` with a unified `tree.interface`. This commit updates the util to account for this change. Fixes an exception in the Node Wrangler add-on, when connecting a socket of a type not yet available in an Input or Output node. More info here: https://wiki.blender.org/wiki/Reference/Release_Notes/4.0/Python_API#Node_Groups Pull Request: https://projects.blender.org/blender/blender/pulls/112960 --- scripts/modules/bpy_extras/node_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/modules/bpy_extras/node_utils.py b/scripts/modules/bpy_extras/node_utils.py index e4789696573..747f0349180 100644 --- a/scripts/modules/bpy_extras/node_utils.py +++ b/scripts/modules/bpy_extras/node_utils.py @@ -35,11 +35,15 @@ def connect_sockets(input, output): return if output_node.type == 'GROUP_OUTPUT' and type(input) == bpy.types.NodeSocketVirtual: - output_node.id_data.outputs.new(type(output).__name__, output.name) + output_node.id_data.interface.new_socket( + name=output.name, socket_type=type(output).__name__, in_out='OUTPUT' + ) input = output_node.inputs[-2] if input_node.type == 'GROUP_INPUT' and type(output) == bpy.types.NodeSocketVirtual: - output_node.id_data.inputs.new(type(input).__name__, input.name) + input_node.id_data.interface.new_socket( + name=input.name, socket_type=type(input).__name__, in_out='INPUT' + ) output = input_node.outputs[-2] return input_node.id_data.links.new(input, output)