From 997cb11d9e7f61620bfc4835d10d838c1400b390 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Wed, 12 Apr 2023 14:41:02 +0200 Subject: [PATCH] Fix #104470: Node Wrangler: Lazy Connect changed behaviour There was an API change in Blender 3.5, after which connecting virtual sockets (sockets inside groups not yet matching any output or input) through scripts resulted in broken links. A link was created, but not the matching group input or output. In 81815681d0 a new API `bpy_extras.node_utils.connect_sockets()` was introduced to handle this case by creating an input or output of the matching type and name. The Lazy Connect operator was in this exact situation, and replacing `links.new()` by `connect_sockets()` fixes the issue. --- node_wrangler/__init__.py | 4 ++-- node_wrangler/utils/nodes.py | 19 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/node_wrangler/__init__.py b/node_wrangler/__init__.py index 24606e886..2d241e98f 100644 --- a/node_wrangler/__init__.py +++ b/node_wrangler/__init__.py @@ -3,8 +3,8 @@ bl_info = { "name": "Node Wrangler", "author": "Bartek Skorupa, Greg Zaal, Sebastian Koenig, Christian Brinkmann, Florian Meyer", - "version": (3, 44), - "blender": (3, 4, 0), + "version": (3, 45), + "blender": (3, 6, 0), "location": "Node Editor Toolbar or Shift-W", "description": "Various tools to enhance and speed up node-based workflow", "warning": "", diff --git a/node_wrangler/utils/nodes.py b/node_wrangler/utils/nodes.py index 2214c161e..557e99646 100644 --- a/node_wrangler/utils/nodes.py +++ b/node_wrangler/utils/nodes.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later import bpy +from bpy_extras.node_utils import connect_sockets from math import hypot @@ -29,48 +30,42 @@ def node_mid_pt(node, axis): def autolink(node1, node2, links): - link_made = False available_inputs = [inp for inp in node2.inputs if inp.enabled] available_outputs = [outp for outp in node1.outputs if outp.enabled] for outp in available_outputs: for inp in available_inputs: if not inp.is_linked and inp.name == outp.name: - link_made = True - links.new(outp, inp) + connect_sockets(outp, inp) return True for outp in available_outputs: for inp in available_inputs: if not inp.is_linked and inp.type == outp.type: - link_made = True - links.new(outp, inp) + connect_sockets(outp, inp) return True # force some connection even if the type doesn't match if available_outputs: for inp in available_inputs: if not inp.is_linked: - link_made = True - links.new(available_outputs[0], inp) + connect_sockets(available_outputs[0], inp) return True # even if no sockets are open, force one of matching type for outp in available_outputs: for inp in available_inputs: if inp.type == outp.type: - link_made = True - links.new(outp, inp) + connect_sockets(outp, inp) return True # do something! for outp in available_outputs: for inp in available_inputs: - link_made = True - links.new(outp, inp) + connect_sockets(outp, inp) return True print("Could not make a link from " + node1.name + " to " + node2.name) - return link_made + return False def abs_node_location(node): -- 2.30.2