alignNodes

 v1.1

Align a bunch of Nodes either horizontally or vertically in the DAG
Author
Frank Rueter
www.ohufx.com
Requirements
6.1, 6.2 or later
Created on: 16/04/2012
Updated on: 28/03/2011
Downloads: 609
Login or Register

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.

 

 

1
2
3
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:
alignNodes_01

after:
alignNodes_02

Comments (11)

djati waskito said:

...
hhey Frank, it didnt work. i put your script in Nuke directories--or should i put into nukescript folder or plugins ? the error said :
---------------------------
Nuke
---------------------------
name 'alignNodes' is not defined
---------------------------
OK Hide Details...
---------------------------
August 31, 2010

Frank Rueter said:

...
you need to import alignNodes first. Sorry, I always forget that in my examples
October 18, 2010

Matt Mustermann said:

...
hmmmm
sorry fot the basic question - but what to import? and how???

br mayanic
December 21, 2010

Frank Rueter said:

...
it's a basic python thing. just put "import alignNodes" at the top of your menu.py file and Nuke will try and find that module in it's plugin path.
December 27, 2010

a guest said:

...
When I try to put import alignNodes at the top of my menu.py I get

ImportError: No module named alignNodes

has the name of the module changed?
February 21, 2011

Jacqueline Cooper said:

...
OK sorry I did download the file and stick it into the python directory....but when I tried to use in practice if I hit the hotkey and i tried to undo it I got some very weird results.....
February 21, 2011

Michael Morehouse said:

...
Hey Frank, two things ...

1) Most people seem to think of 'align horizontally' as all nodes aligned along the same y value (the x axis), and 'align vertically' as all nodes aligned along the same x value (y axis) ... the menu example would appear to do the opposite, unless I'm reading something incorrectly.

2) By using knob.setValue instead of node.setXYpos you make it so the user can't undo correctly.
February 21, 2011

life srichathi said:

...
nice one... its working
February 27, 2011

steve morel said:

...
Hey Frank,
That's a pretty amasing script here ! : ) I was lookin' for this ! Thanks a lot !
@Michael, if you feel like making an update to get a proper undo, please do so :D I'd like to have a proper undo as well : ) I'm not good enough yet to make this patch :D
Cheer everybody ^^
March 28, 2011

Frank Rueter said:

...
thanks for the kind words.
Michael, thanks for the heads up, I've fixed this and undo now works with this (v1.1). I think this was written before the setPos methods were available in the API.

As for the confusion between horizontal and vertical, I will leave that up to the people how they label their menu items (assigning good icons might be the best way to do this)), as from experience there are different opinions on how it should be interpreted.

thanks again for int input guys!
March 28, 2011

Anshul Mathuria said:

...
Hey frank this gr8 script. I really like that n you know what i know you since 2004.
September 16, 2011

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy