Align a bunch of Nodes either horizontally or vertically in the DAG
alignNodes
Updated: 29 April 2021
Author: frank
Compatible Nuke versions: 10.0 or later
Compatibility: Linux, Mac, Windows
v1.3 - Nuke 13 compatible
v1.2 - using node centre now instead of upper left corner, which makes Dots work as well as nodes with non-default height due to labels
v1.1 - undo now works
Here is an example menu.py entries with hotkeys (note that this will overwrite alt+x as the shortcut cut for 'File/TCL File...'). It pus the entries into rather deep sub menus, but I always use the hotkeys anyway:
import nuke
import alignNodes
menuBar = nuke.menu('Nuke')
menuBar.addCommand('Edit/Node/Align/horizontally', 'alignNodes.alignNodes(nuke.selectedNodes(), direction=\'x\')' , 'alt+x')
menuBar.addCommand('Edit/Node/Align/vertically', 'alignNodes.alignNodes(nuke.selectedNodes(), direction=\'y\')' , 'alt+y')
before:
after: