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):