alignNodes v1.2


 
This location is for Registered Users Only.
Perhaps you need to login or register.
Contributor: Frank Rueter
Website: www.ohufx.com
Align a bunch of Nodes either horizontally or vertically in the DAG
Requirements:
11.0, 10.5, 10.0, 9.0, 8.0, 7.1, 7.0, 6.3, 6.2, 6. or later
Linux, Mac, Windows
11 Dec 2017
2214

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.
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

Please login in order to download these files.

Comments   

 
# djati waskito 2010-08-31 07:32
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...
--------------- ------------
 
 
# Frank Rueter 2010-10-18 01:45
you need to import alignNodes first. Sorry, I always forget that in my examples
 
 
# Matt Mustermann 2010-12-21 13:44
hmmmm
sorry fot the basic question - but what to import? and how???

br mayanic
 
 
# Frank Rueter 2010-12-26 23:48
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.
 
 
# Jacqueline Cooper 2011-02-21 05:37
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?
 
 
# Jacqueline Cooper 2011-02-21 06:53
OK sorry I did download the file and stick it into the python directory....bu t when I tried to use in practice if I hit the hotkey and i tried to undo it I got some very weird results.....
 
 
# Michael Morehouse 2011-02-21 08:58
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.
 
 
# life srichathi 2011-02-27 07:23
nice one... its working
 
 
# steve morel 2011-03-28 09:45
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 ^^
 
 
# Frank Rueter 2011-03-28 15:53
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!
 
 
# Anshul Mathuria 2011-09-15 21:45
Hey frank this gr8 script. I really like that n you know what i know you since 2004.
 
 
# edwin perez 2012-06-24 06:23
Thank you so much,,, this help me for my workflow, really.
 
 
# lee spooner 2014-11-11 15:21
ok, so to get mine to work.

I put the alignNodes.py into my ...Nuke8.0v6\pl ugins\nukescrip ts folder.

Added the following to the top of menu.py
import nukescripts.alignNodes

Adn pasted the following at the bottom, adding "nukescripts." to link to the correct folder

menuBar = nuke.menu("Nuke")
menuBar.addCommand('Edit/Node/Align/horizontally', 'nukescripts.al ignNodes.alignN odes( nuke.selectedNo des(), direction="x" )', 'alt+x')
menuBar.addCommand('Edit/Node/Align/vertically', 'nukescripts.al ignNodes.alignN odes( nuke.selectedNo des(), direction="y" )', 'alt+y')

I switched the x and y around, as i more frequently arange horizontally, so better to have that key closer to hand

Great script by the way!
 
 
# Frank Rueter 2014-11-11 22:01
yeah, depending on where you put this in your plugin path and how you import the module, your actual commands will vary slightly like in your case
 
 
# djati waskito 2018-08-31 06:39
Quoting lee spooner:
ok, so to get mine to work.

I put the alignNodes.py into my ...Nuke8.0v6\plugins\nukescripts folder.

Added the following to the top of menu.py
import nukescripts.alignNodes

Adn pasted the following at the bottom, adding "nukescripts." to link to the correct folder

menuBar = nuke.menu("Nuke")
menuBar.addCommand('Edit/Node/Align/horizontally', 'nukescripts.alignNodes.alignNodes( nuke.selectedNodes(), direction="x" )', 'alt+x')
menuBar.addCommand('Edit/Node/Align/vertically', 'nukescripts.alignNodes.alignNodes( nuke.selectedNodes(), direction="y" )', 'alt+y')

I switched the x and y around, as i more frequently arange horizontally, so better to have that key closer to hand

Great script by the way!




i use v.11.1 but it doesn't work. I already follow your method. Any chance to solve mine ?
 
 
# Frank Rueter 2018-09-02 23:07
It should work by putting a menu.py into your a $HOME/.nuke/ folder and pasting the above code into it.
Messing with the install folder is usually not a good idea.
 
 
# djati waskito 2018-09-09 11:26
Hi Frank,

Thank you for brighten up my brain. I put inside nukescripts folder and put my menu.py into users/.nuke folder.

It's work like a champ now !
Thanks a lot Frank..g8t gizmo..help me a tons.

regards
Kito
 
 
# Anthony Thomas 2016-02-10 05:50
That'd be great if this had a slider that popped up. So when you hit alt+L a slider appears, and allows you to control how it spreads in spacing of the nodes.
 
 
# Frank Rueter 2016-02-13 06:23
Sounds interesting but I'm not sure what exactly you mean.
Do you want to almost align nodes but not quite? :)
 
 
# Frank Rueter 2016-02-14 00:12
or are you referring to scaleNodes?
http://www.nukepedia.com/python/nodegraph/scalenodes
That would make more sense and would indeed be a cool feature.
 
 
# Marcel Pichert 2017-12-11 11:36
can you make it work with dots?
because when you use it now with dots it places the dot alligned to the right site of the other nodes
 
 
# Frank Rueter 2017-12-11 19:36
I can have a look
 
 
# Frank Rueter 2017-12-11 20:20
fixed, try 1.2
 

You have no rights to post comments

We have 2378 guests and 39 members online