diff options
author | Bartek Skorupa <bartekskorupa@bartekskorupa.com> | 2013-04-26 20:08:19 +0400 |
---|---|---|
committer | Bartek Skorupa <bartekskorupa@bartekskorupa.com> | 2013-04-26 20:08:19 +0400 |
commit | 1ddf4a890a904f57199cf77f6d7a8842842ec5b2 (patch) | |
tree | f589a6c9516d777550e4dbc98239b2f6a8f7f9dc /node_efficiency_tools.py | |
parent | e126b1d310939923e3a4cad52b1a8b89aa16a128 (diff) |
In 'Merge Nodes' when first selected node is linked to anything - last added merging node will be linked to the same sockets. This gives possibility to kind of 'insert' merges into existing noodle.
Diffstat (limited to 'node_efficiency_tools.py')
-rw-r--r-- | node_efficiency_tools.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/node_efficiency_tools.py b/node_efficiency_tools.py index 77213838..ee9665fa 100644 --- a/node_efficiency_tools.py +++ b/node_efficiency_tools.py @@ -19,7 +19,7 @@ bl_info = { 'name': "Nodes Efficiency Tools", 'author': "Bartek Skorupa", - 'version': (2, 25), + 'version': (2, 26), 'blender': (2, 6, 6), 'location': "Node Editor Properties Panel (Ctrl-SPACE)", 'description': "Nodes Efficiency Tools", @@ -294,8 +294,14 @@ class MergeNodes(Operator, NodeToolBase): count_adds = i + 1 count_after = len(nodes) index = count_after - 1 + 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] + # 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: + links.new(last_add.outputs[0], fs_link.to_socket) # add link from "first" selected and "first" add node - links.new(nodes[nodes_list[0][0]].outputs[0], nodes[count_after - 1].inputs[first]) + links.new(first_selected.outputs[0], nodes[count_after - 1].inputs[first]) # add links between added ADD nodes and between selected and ADD nodes for i in range(count_adds): if i < count_adds - 1: @@ -304,7 +310,7 @@ class MergeNodes(Operator, NodeToolBase): links.new(nodes[index].inputs[second], nodes[nodes_list[i + 1][0]].outputs[0]) index -= 1 # set "last" of added nodes as active - nodes.active = nodes[count_before] + nodes.active = last_add for i, x, y in nodes_list: nodes[i].select = False |