W_smartAlign v1.1


 
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Wouter Gilsing
Align your nodes faster in an easy and controllable way
Requirements:
10.0, 9.0, 8.0, 7.1, 7.0 or later
Linux, Mac, Windows
26 May 2016
612

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)

 

 

Please login in order to download these files.

Comments   

 
-3 # Erwan Leroy 2015-12-29 10:12
That's really cool, it beats my own node align.
However I would suggest using a different default keyboard shortcut as these overwrite default nuke functions. (Especially alt+up/down for version up/down is extremely useful)
 
 
+2 # Wouter Gilsing 2015-12-29 14:34
Hi Erwan,

Thanks for the input, glad you like it!

I’m indeed aware of the the ‘version up/down’ shortcuts being overwritten. You are of course free to modify my code to change the shortcuts to something that works better 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, but that’s up to you.

I included some extra code at the bottom of the mainpost.

Thanks for the feedback
Cheers
 
 
# Caleb Dermyer 2016-01-12 17:11
When adding to the menu I get the following error:

"...menu.py : error interpreting this plugin"

Under details it says:

"SynataxError: invalid syntax" with an " ^ " under "Context"

any ideas? Thanks!
 
 
# Wouter Gilsing 2016-01-12 17:18
Hi Caleb,

If I'm correct, you're using Nuke 8 or older, right? Make sure to get rid of the all the 'shortcutContex t=2' in your menu.py, as this functionality is only supported in version 9.

I posted a version suitable for older versions of nuke in the mainpost, so make sure you copy the right one.
 
 
+2 # Caleb Dermyer 2016-01-12 17:27
Hmm, I copied the sample menu code from the .py file and it worked. The difference seems to be double verse single quotes.
"Nuke" vs 'Nuke'
 
 
# Wouter Gilsing 2016-01-12 17:37
Interesting as that shouldn't make a difference and doesn't really correspond with the syntax error you posted earlier. Glad it's working for you now though!
 
 
# Caleb Dermyer 2016-01-12 17:40
thank you, and thanks for the resource; its handy!
 
 
# be de 2016-01-18 10:05
very nice script!
 
 
# sridharan K 2016-01-20 14:01
Thanks a lot :D . Really useful script :D
 
 
# Raoul Ventel 2016-02-04 10:50
Very much thank you :lol:
 
 
# Thierry Muller 2016-05-26 23:40
I really like it.
It doesn't allow any Undo though. Is that smth that could be implemented?
 
 
# Wouter Gilsing 2016-05-27 02:33
Hey Thierry,

I tried to implement this when I initially wrote the tool, but couldn't figure out why it wasn't working. I gave it another try after I read your comment and found a workaround.

I just uploaded v1.1.

For whom it may interest: Turns out that for some reason changing a node's position by changing the values of the position knobs can not be undone. But using the 'setXpos' and 'setYpos' methods instead will do the trick.
 
 
# Thierry Muller 2016-05-27 02:36
Holy moly that was quick :D Thanks a lot man, I'll try it out soon. :D
 
 
# Wouter Gilsing 2016-05-27 03:17
Haha, no problem :-)
 
 
# Octavio Mancilla 2016-05-27 15:26
Nice one, thanks!
 
 
# sungmin park 2016-05-31 11:25
thanks!!! very nice~!! that's what I want
 
 
# Mher Minasian 2017-02-01 19:00
import W_smartAlign

menuBar = nuke.menu("Nuke")
menuBar.addCommand("Edit/Node/Align/Left", 'W_smartAlign.a lignNodes("left ")', "Alt+left", shortcutContext =2)
menuBar.addCommand("Edit/Node/Align/Right", 'W_smartAlign.a lignNodes("righ t")', "Alt+right", shortcutContext =2)
menuBar.addCommand("Edit/Node/Align/Up", 'W_smartAlign.a lignNodes("up") ', "Alt+up", shortcutContext =2)
menuBar.addCommand("Edit/Node/Align/Down", 'W_smartAlign.a lignNodes("down ")', "Alt+down", shortcutContext =2)
 
 
# BIll Marsh 2017-04-02 11:46
Installed W_smartalign in the .nuke folder
Added this:

import W_smartAlign

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

in menu.py

and got this error message:

invalid syntax (, line 1)

Did I install correctly?
 
 
# Wouter Gilsing 2017-04-02 11:50
Looks like there's a space between 'a' and 'lign':
W_smartAlign.a lignNodes

See whether removing it fixes your problem. Cheers.
 
 
# BIll Marsh 2017-04-02 15:54
Thank you for your follow through.
Nukepedia added the space between 'a' and 'lign'.
I had included the three apostrophes that were in your W_smartalign.py"



#--------------------------------------
#EXAMPLE MENU.PY CODE
#--------------------------------------

'''
import W_smartAlign

When I removed the ''', the script worked.

Thank you for this excellent timesaver.
 

You have no rights to post comments

We have 2555 guests and 133 members online