Node Wrangler: Improved accuracy on Align Nodes operator #104551
@ -2375,20 +2375,24 @@ class NWAlignNodes(Operator, NWBase):
|
||||
|
||||
# Alignment
|
||||
current_pos = 0
|
||||
weird_offset = 10 # Somehow hidden nodes would come out 10 units higher that non-hidden nodes when aligned, so this offset has to exist
|
||||
|
||||
if horizontal:
|
||||
for node in selection:
|
||||
current_margin = (0.5 * margin) if node.hide else margin
|
||||
|
||||
node.location.x = current_pos
|
||||
node.location.y = mid_y + (0.5 * node.dimensions.y)
|
||||
current_pos += current_margin + node.dimensions.x
|
||||
if node.hide:
|
||||
node.location.y -= (0.5 * node.dimensions.y) - weird_offset
|
||||
|
||||
current_pos += margin + node.dimensions.x
|
||||
else:
|
||||
for node in selection:
|
||||
current_margin = (0.5 * margin) if node.hide else margin
|
||||
|
||||
node.location.y = current_pos
|
||||
if node.hide:
|
||||
node.location.y -= (0.5 * node.dimensions.y) - weird_offset
|
||||
|
||||
node.location.x = mid_x - (0.5 * node.dimensions.x)
|
||||
current_pos -= (current_margin * 0.3) + node.dimensions.y # use half-margin for vertical alignment
|
||||
current_pos -= 0.3 * margin + node.dimensions.y # use half-margin for vertical alignment
|
||||
|
||||
# If active node is selected, center nodes around it
|
||||
if active_loc is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user