alignNodes v1.3


 
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:
13.1, 12.2, 12.1, 12.0, 11.3, 11.2, 11.1, 11.0, 10 or later
Linux, Mac, Windows
28 Apr 2021
3338

v1.3 - Nuke 13 compatible


 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:

import nuke
import alignNodes

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   

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

br mayanic
 
 
0 # 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.
 
 
0 # 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?
 
 
0 # 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.....
 
 
0 # 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.
 
 
0 # life srichathi 2011-02-27 07:23
nice one... its working
 
 
0 # 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 ^^
 
 
0 # 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!
 
 
0 # 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.
 
 
0 # edwin perez 2012-06-24 06:23
Thank you so much,,, this help me for my workflow, really.
 
 
+2 # 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!
 
 
0 # 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
 
 
0 # 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 ?
 
 
0 # 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.
 
 
0 # 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
 
 
0 # 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.
 
 
0 # 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? :)
 
 
0 # 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.
 
 
0 # 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
 
 
0 # Frank Rueter 2017-12-11 19:36
I can have a look
 
 
0 # Frank Rueter 2017-12-11 20:20
fixed, try 1.2
 
 
0 # H Hakim 2020-09-21 18:44
Doesn't work with Nuke 12.2 :sigh:
 
 
0 # Frank Rueter 2020-09-24 04:36
The script itself works just fine in Nuke 12, I did have some hiccups in the example for the menu.py entry which are corrected now.
 
 
0 # Alex Afanasyev 2021-01-22 09:33
Frank, thanks for a handy addon!

For those having trouble installing:
1. Download alignNodes.py
2. Put alignNodes.py into /nukescripts folder on your drive (for me it is C:\Program Files\Nuke12.1v1\plugins\nukescripts)
3. In this (C:\Program Files\Nuke12.1v 1\plugins\nuke) directory find a file menu.py
4. Add the following code to it:
import nukescripts.alignNodes
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')
5. Save this updated menu file in here: C:\Users\(YOURNAME)\.nuke

Worked for me in 12.1
 
 
0 # Vako Agladze 2021-04-14 21:03
If you have issues with the Nuke 13 and Python update (Nuke might crash on the startup) Open alignNodes.py and replace 7th line "raise ValueError, 'direction argument must be x or y'" With "raise ValueError('dir ection argument must be x or y')" This should fix the error
 
 
0 # Ben Sutton 2021-04-27 22:10
I seem to have an issue with this part of the code
menuBar.addCommand('Edit/Node/Align/horizontally', 'alignNodes.ali gnNodes( nuke.selectedNo des(), direction='x')' , 'alt+x')
menuBar.addCommand('Edit/Node/Align/vertically', 'alignNodes.ali gnNodes( nuke.selectedNo des(), direction='y')' , 'alt+y')

keeps on coming up with 'error interpreting this plugin. I am using nuke 12.0v5 and 12.2v4
 
 
0 # Frank Rueter 2021-04-27 22:21
Sorry, my bad, I had incorrect nested quotes going there. I have updated the description now, so you should be able to copy/paste that again to make it work.
 
 
0 # Ben Sutton 2021-04-28 19:44
Weird I still get the same error. I just copied and pasted
import nuke
import alignNodes

menuBar = nuke.menu('Nuke')
menuBar.addCommand('Edit/Node/Align/horizontally', 'alignNodes.ali gnNodes( nuke.selectedNo des(), direction='x')' , 'alt+x')
menuBar.addCommand('Edit/Node/Align/vertically', 'alignNodes.ali gnNodes( nuke.selectedNo des(), direction='y')' , 'alt+y')


into my menu.py and have the alighnnodes.py in my .nuke folder
 
 
0 # Frank Rueter 2021-04-28 20:09
Strange, the editor keeps turning my douible quotes back into single quotes which in this cases causes problems. There was also a couple of stray white spaces from copy/pasting.
Try again now
 
 
0 # Lee Kirown 2022-04-25 05:03
It din't work for me in nuke 12.1v4。
The error is this:
File "", line 1
nukescripts.al ignNodes.alignN odes( nuke.selectedNo des(), direction="y" )

SyntaxError: invalid syntax
 
 
0 # Frank Rueter 2022-04-26 00:05
looks like there are some extra white spaces in that line
 

You have no rights to post comments

We have 3349 guests and 84 members online