Darren,
I can’t take credit for this; it’s from my co-worker, Drew Loveridge…
— If you don’t give it a list of nodes, it will use the currently selected
nodes as the default list.
— It returns a list, for example: [26, -458] -- which is the center x, y
position of the node list. Then, you can create your new node and use those
values to set the XYPosition for the node, probably with an offset on Y... I
use it all the time!
def nodeList_center(nodeList=None):
'''Node placement function, from Drew Loveridge...'''
if nodeList == None:
nodeList=nuke.selectedNodes()
nNodes = len(nodeList)
x=0
y=0
for n in nodeList:
x += n.xpos()
for n in nodeList:
y += n.ypos()
try:
return [x/nNodes,y/nNodes]
except ZeroDivisionError:
return [0,0]
Rich
Rich Bobo
Senior VFX Compositor
Armstrong White
Email: [email protected]
http://armstrong-white.com/
Email: [email protected]
Mobile: (248) 840-2665
Web: http://richbobo.com/
"A professional is someone who can do his best work when he doesn't feel like
it."
- Alistair Cooke
> On Mar 15, 2017, at 10:07 PM, Darren Coombes <[email protected]> wrote:
>
> How can i find out the centre co-ordinate of say, 9 selected nodes, so i can
> create a node that’s directly below
>
> nodes = nuke.selectedNodes()
> amount = len(nodes)
> center = ?? this where i’m stuck, need to get the value.
>
> nuke.nodes.ContactSheet(xpos=center)
>
> any help, greatly appreciated.
> Thanks.
>
> Darren.
>
>
> Check out some of my work…
> www.vimeo.com/darrencoombes/reel2017
> <http://www.vimeo.com/darrencoombes/reel2017>
>
> Mob: +61 418 631 079 <tel:+61%20418%20631%20079>
> IMDB: www.imdb.com/name/nm3719099/ <http://www.imdb.com/name/nm3719099/>
> Instagram: @7secondstoblack
> Instagram: @durwood0781
> Skype: darren.coombes81
> Twitter: @durwood81
>
> _______________________________________________
> Nuke-users mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users