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
1876

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   

 
-2 # 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
 
 
0 # 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!
 
 
0 # 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'
 
 
0 # 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!
 
 
0 # Caleb Dermyer 2016-01-12 17:40
thank you, and thanks for the resource; its handy!
 
 
0 # be de 2016-01-18 10:05
very nice script!
 
 
0 # sridharan K 2016-01-20 14:01
Thanks a lot :D . Really useful script :D
 
 
0 # Raoul Ventel 2016-02-04 10:50
Very much thank you :lol:
 
 
0 # 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?
 
 
0 # 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.
 
 
0 # Thierry Muller 2016-05-27 02:36
Holy moly that was quick :D Thanks a lot man, I'll try it out soon. :D
 
 
0 # Wouter Gilsing 2016-05-27 03:17
Haha, no problem :-)
 
 
0 # Octavio Mancilla 2016-05-27 15:26
Nice one, thanks!
 
 
0 # sungmin park 2016-05-31 11:25
thanks!!! very nice~!! that's what I want
 
 
0 # 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)
 
 
0 # 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?
 
 
0 # 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.
 
 
0 # 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.
 
 
0 # Tony Shu 2019-10-07 01:46
In Windows , Nuke11.3 , I change W_smartAlign.al ignNodes('****' ) to W_smartAlign.al ignNodes("****" ) ,and It works.


full script
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)
 
 
0 # djati waskito 2018-08-31 07:37
i am using v.11.1..when i tried press "Alt Up" it doesn't work just like you had. Whenever i press "Alt UP" and "Alt DOWN" give me same result --> Alt RIGHT/LEFT. Any SOlution , Gilsing ?

and yet...It's a very helpful script. Thanks for your good support.

-Kito
 
 
0 # Lundy Hu 2018-12-05 18:03
如果两个平行的节点没有连接,那么在平行的方向及将会重叠。
可以不让他们重叠吗?
I am chinese, my english is so bad.
 
 
0 # Lundy Hu 2018-12-05 18:05
如果两个平行的节点没有连接,那么在平行的方向及将会重叠。
可以不让他们重叠吗?
(google translate: If two parallel nodes are not connected, they will overlap in parallel directions.
Can you not let them overlap? )
 
 
0 # Lundy Hu 2018-12-05 18:48
如果两个垂直的节点连接,其中一个与另一个水平的节点没有连接,那么alt+后,水平的节点将会重叠。
如何不重叠?
(google translate :If two vertical nodes are connected, one of them is not connected to another horizontal node, then alt+< or alt+>, the horizontal nodes will overlap.
How to not overlap?)
 
 
0 # Lundy Hu 2018-12-05 18:53
如果两个垂直的节点连接,其中一个与另一个水平的节点没有连接,然后选择这三个节点,那么alt+后,水平的节点将会重叠。
如何不重叠?
(google translate :If two vertical nodes are connected, one of them is not connected to another horizontal node, and then the three nodes are selected, then alt+< or alt+>, the horizontal nodes will overlap.
How to not overlap?)
 
 
0 # Cleber Redondo 2020-08-03 20:48
Hello,


I install the script on ( Nuke12.1v3) but still getting this error
any suggestion:

File "", line 1
W_smartAlign.a lignNodes("left ")
^
SyntaxError: invalid syntax



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)
 
 
0 # LEE JINHEE 2021-01-12 19:08
Thanks!!!
 
 
0 # Lukas Schwabe 2022-01-25 10:40
Hey Wouter,

amazing tool! Thanks man. Just a little speed improvement I found, cause it's lagging sometimes in bigger scripts.

Line 65:
inputNodes = curNode.depende ncies(nuke.INPU TS)
outputNodes = curNode.depende nt(nuke.INPUTS, forceEvaluate = False)


Cheers
 

You have no rights to post comments

We have 2048 guests and 78 members online