[Bf-extensions-cvs] [aa15501] master: Improved links creation in "Merge Nodes"

Bartek Skorupa noreply at git.blender.org
Thu Oct 16 20:05:45 CEST 2014


Commit: aa15501a01285b1363cdd453ac0e998c086ddede
Author: Bartek Skorupa
Date:   Thu Oct 16 20:05:38 2014 +0200
Branches: master
https://developer.blender.org/rBAaa15501a01285b1363cdd453ac0e998c086ddede

Improved links creation in "Merge Nodes"

Added special case when two nodes are selected and first selected has
no output links and second does.
Then relink the new node's output to preserve the chain.

===================================================================

M	node_efficiency_tools.py

===================================================================

diff --git a/node_efficiency_tools.py b/node_efficiency_tools.py
index de008aa..b252f7c 100644
--- a/node_efficiency_tools.py
+++ b/node_efficiency_tools.py
@@ -19,7 +19,7 @@
 bl_info = {
     "name": "Node Wrangler (aka Nodes Efficiency Tools)",
     "author": "Bartek Skorupa, Greg Zaal",
-    "version": (3, 16),
+    "version": (3, 17),
     "blender": (2, 72, 0),
     "location": "Node Editor Properties Panel or Ctrl-Space",
     "description": "Various tools to enhance and speed up node-based workflow",
@@ -1931,6 +1931,19 @@ class NWMergeNodes(Operator, NWBase):
                 first_selected = nodes[nodes_list[0][0]]
                 # "last" node has been added as first, so its index is count_before.
                 last_add = nodes[count_before]
+                # Special case:
+                # Two nodes were selected and first selected has no output links, second selected has output links.
+                # Then add links from last add to all links 'to_socket' of out links of second selected.
+                if len(nodes_list) == 2:
+                    if not first_selected.outputs[0].links:
+                        second_selected = nodes[nodes_list[1][0]]
+                        for ss_link in second_selected.outputs[0].links:
+                            # Prevent cyclic dependencies when nodes to be marged are linked to one another.
+                            # Create list of invalid indexes.
+                            invalid_i = [n[0] for n in (selected_mix + selected_math + selected_shader + selected_z)]
+                            # Link only if "to_node" index not in invalid indexes list.
+                            if ss_link.to_node not in [nodes[i] for i in invalid_i]:
+                                links.new(last_add.outputs[0], ss_link.to_socket)
                 # add links from last_add to all links 'to_socket' of out links of first selected.
                 for fs_link in first_selected.outputs[0].links:
                     # Prevent cyclic dependencies when nodes to be marged are linked to one another.



More information about the Bf-extensions-cvs mailing list