[Bf-extensions-cvs] [ff3f557] master: Node Wrangler: When doing auto-arrange, keep active node still.
Greg Zaal
noreply at git.blender.org
Wed Jun 24 16:53:22 CEST 2015
Commit: ff3f5574174a6c411015974c4697c4bb2c84e0ef
Author: Greg Zaal
Date: Wed Jun 24 16:50:24 2015 +0200
Branches: master
https://developer.blender.org/rBAff3f5574174a6c411015974c4697c4bb2c84e0ef
Node Wrangler: When doing auto-arrange, keep active node still.
Other selected nodes are arranged around the active one - I've been using this for a while and found this behavior is much more useful.
===================================================================
M node_wrangler.py
===================================================================
diff --git a/node_wrangler.py b/node_wrangler.py
index 54e11fa..d7a0a2d 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -19,8 +19,8 @@
bl_info = {
"name": "Node Wrangler",
"author": "Bartek Skorupa, Greg Zaal, Sebastian Koenig",
- "version": (3, 27),
- "blender": (2, 74, 0),
+ "version": (3, 28),
+ "blender": (2, 75, 0),
"location": "Node Editor Toolbar or Ctrl-Space",
"description": "Various tools to enhance and speed up node-based workflow",
"warning": "",
@@ -35,8 +35,9 @@ from bpy.props import FloatProperty, EnumProperty, BoolProperty, IntProperty, St
from bpy_extras.io_utils import ImportHelper
from mathutils import Vector
from math import cos, sin, pi, hypot
-from os import listdir, path
+from os import path
from glob import glob
+from copy import copy
#################
# rl_outputs:
@@ -2674,7 +2675,6 @@ class NWAlignNodes(Operator, NWBase):
margin = IntProperty(name='Margin', default=50, description='The amount of space between nodes')
def execute(self, context):
- # TODO prop: lock active (arrange everything without moving active node)
nodes, links = get_nodes_links(context)
margin = self.margin
@@ -2684,8 +2684,11 @@ class NWAlignNodes(Operator, NWBase):
selection.append(node)
# If no nodes are selected, align all nodes
+ active_loc = None
if not selection:
selection = nodes
+ elif nodes.active in selection:
+ active_loc = copy(nodes.active.location) # make a copy, not a reference
# Check if nodes should be layed out horizontally or vertically
x_locs = [n.location.x + (n.dimensions.x / 2) for n in selection] # use dimension to get center of node, not corner
@@ -2717,14 +2720,19 @@ class NWAlignNodes(Operator, NWBase):
current_pos -= (current_margin * 0.3) + node.dimensions.y # use half-margin for vertical alignment
node.location.x = mid_x - (node.dimensions.x / 2)
- # Position nodes centered around where they used to be
- locs = ([n.location.x + (n.dimensions.x / 2) for n in selection]) if horizontal else ([n.location.y - (n.dimensions.y / 2) for n in selection])
- new_mid = (max(locs) + min(locs)) / 2
- for node in selection:
- if horizontal:
- node.location.x += (mid_x - new_mid)
- else:
- node.location.y += (mid_y - new_mid)
+ # If active node is selected, center nodes around it
+ if active_loc is not None:
+ active_loc_diff = active_loc - nodes.active.location
+ for node in selection:
+ node.location += active_loc_diff
+ else: # Position nodes centered around where they used to be
+ locs = ([n.location.x + (n.dimensions.x / 2) for n in selection]) if horizontal else ([n.location.y - (n.dimensions.y / 2) for n in selection])
+ new_mid = (max(locs) + min(locs)) / 2
+ for node in selection:
+ if horizontal:
+ node.location.x += (mid_x - new_mid)
+ else:
+ node.location.y += (mid_y - new_mid)
return {'FINISHED'}
More information about the Bf-extensions-cvs
mailing list