W_smartAlign

Align your nodes faster in an easy and controllable way

Updated: 27 May 2016

Author: WouterGilsing

Compatible Nuke versions: 7.0 or later

Compatibility: Linux, Mac, Windows

watch the video   Tool Video

W_smartAlign

 

A script I wrote to make aligning your nodes faster in an easy and controllable way.

 

The way it works:

  • If only one node is selected, the node will align to the nearest connected node (both inputs and outputs) in the desired direction
  • Multiple nodes will align to the selected node that’s the furthest away in the desired direction
  • If a node already shares the same position on one axis with a node it’s aligning to, the node will be placed next to other node instead of overlapping it.
  • Takes a node’s screensize in account to ensure a correct alignment no matter what kind of node you’re dealing with.
  • Ignores Viewers and child nodes with hidden inputs

 

New in v1.1:

  • Undo now supported

 

 

 

 

 

Sample menu.py code

Note that Nukepedia is for some reason replacing double quotes with singles quotes. If you copy the following text, make sure to replace the single quotes around left/right/up/down with double quotes or the script will not work. Alternatively, you find the same code at the bottom of the W_smartAlign.py python file and copy it from there.

 

Nuke 9 and newer:

1
2
3
4
5
6
7
import W_smartAlign

menuBar = nuke.menu('Nuke')
menuBar.addCommand('Edit/Node/Align/Left', 'W_smartAlign.alignNodes('left')', 'Alt+left', shortcutContext=2)
menuBar.addCommand('Edit/Node/Align/Right', 'W_smartAlign.alignNodes('right')', 'Alt+right', shortcutContext=2)
menuBar.addCommand('Edit/Node/Align/Up', 'W_smartAlign.alignNodes('up')', 'Alt+up', shortcutContext=2)
menuBar.addCommand('Edit/Node/Align/Down', 'W_smartAlign.alignNodes('down')', 'Alt+down', shortcutContext=2)

Nuke 8 and older:

1
2
3
4
5
6
7
import W_smartAlign

menuBar = nuke.menu('Nuke')
menuBar.addCommand('Edit/Node/Align/Left', 'W_smartAlign.alignNodes('left')', 'Alt+left')
menuBar.addCommand('Edit/Node/Align/Right', 'W_smartAlign.alignNodes('right')', 'Alt+right')
menuBar.addCommand('Edit/Node/Align/Up', 'W_smartAlign.alignNodes('up')', 'Alt+up')
menuBar.addCommand('Edit/Node/Align/Down', 'W_smartAlign.alignNodes('down')', 'Alt+down')

 

Note that with this setup the ‘version up/down’ shortcuts will be overwritten. You are of course free to modify the menu.py code to change the shortcuts if that doesn't work for you. I personally however only use those function occasionally whereas I use this alignment tool all the time. Therefore I’d suggest assigning new shortcuts to the ‘version up/down’ functions instead, but that’s up to you of course. Personally I’m using the 'greater-than' and 'less-than'-signs (or ‘shift +.’ and ‘shift +,’ ) to version up and down:

1
2
3
4
5
#make sure to remove “, shortcutContext=2” when using Nuke 8 or older

import nukescripts

menuBar.addCommand('Edit/Node/Filename/Version Up', 'nukescripts.version_up()', 'Shift+.', shortcutContext=2)
menuBar.addCommand('Edit/Node/Filename/Version Down', 'nukescripts.version_down()', 'Shift+,', shortcutContext=2)

 

 

Sign in or register to download or rate.