Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg <gregzzmail@gmail.com>2016-08-08 18:25:38 +0300
committerGreg <gregzzmail@gmail.com>2016-08-08 19:25:20 +0300
commit25c00058b3e22d4219e175e3a46e409fa83f0cf4 (patch)
tree9819f0edb4da03c2e8de51119527943455b26c11 /node_wrangler.py
parent46ed2cd0d0babecbec7cdb087c34c9d6148431fc (diff)
Node Wrangler: Place "Multiple Images" nodes in center of view (instead of far left)
Diffstat (limited to 'node_wrangler.py')
-rw-r--r--node_wrangler.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/node_wrangler.py b/node_wrangler.py
index 32f81562..326d66ce 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -2994,18 +2994,8 @@ class NWAddMultipleImages(Operator, ImportHelper):
def execute(self, context):
nodes, links = get_nodes_links(context)
- nodes_list = [node for node in nodes]
- if nodes_list:
- nodes_list.sort(key=lambda k: k.location.x)
- xloc = nodes_list[0].location.x - 220 # place new nodes at far left
- yloc = 0
- for node in nodes:
- node.select = False
- yloc += node_mid_pt(node, 'y')
- yloc = yloc/len(nodes)
- else:
- xloc = 0
- yloc = 0
+
+ xloc, yloc = context.region.view2d.region_to_view(context.area.width/2, context.area.height/2)
if context.space_data.node_tree.type == 'SHADER':
node_type = "ShaderNodeTexImage"
@@ -3033,9 +3023,12 @@ class NWAddMultipleImages(Operator, ImportHelper):
# shift new nodes up to center of tree
list_size = new_nodes[0].location.y - new_nodes[-1].location.y
- for node in new_nodes:
- node.select = True
- node.location.y += (list_size/2)
+ for node in nodes:
+ if node in new_nodes:
+ node.select = True
+ node.location.y += (list_size/2)
+ else:
+ node.select = False
return {'FINISHED'}