Darren,

Sorry, I should have added a usage hint…


ListOfNodes = nuke.selectedNodes()      #Make a list of node objects...

center = nodeList_center(ListOfNodes)   #Find the center of the list of nodes… 
Returns [x, y]

cs = nuke.createNode("ContactSheet”)   #Create your new node...

cs.setXYpos(center[0], center[1])            #Use the setXYpos method and set 
the x, y values of your new node to the values you got above…


Does that make sense…?


Rich




> On Mar 16, 2017, at 1:22 AM, Darren Coombes <[email protected]> wrote:
> 
> Thanks Rich,
> 
> so if i create a ContactSheet node and i want to set its xpos to the result 
> of the nodeList_center()
> i can’t seem to figure that part out.
> 
> i’m creating the node this way.
> 
> 
> 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]
> 
> def createCS():
>       cs = nuke.createNode("ContactSheet”)
>       cs[‘gap’].setValue(20)
>       cs[‘center’].setValue(True)
>       cs.knob.(‘xpos’)setValue(nodeList_center)  ### this part not working, 
> my syntax not great.
> createCS()
> 
> 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
> 
>> On 16 Mar 2017, at 2:21 pm, Rich Bobo <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> 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] <mailto:[email protected]>
>> http://armstrong-white.com/ <http://armstrong-white.com/>
>> 
>> Email:  [email protected] <mailto:[email protected]>
>> Mobile:  (248) 840-2665
>> Web:  http://richbobo.com/ <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] 
>>> <mailto:[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] 
>>> <mailto:[email protected]>, 
>>> http://forums.thefoundry.co.uk/ <http://forums.thefoundry.co.uk/>
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users 
>>> <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users>
>> _______________________________________________
>> Nuke-users mailing list
>> [email protected] 
>> <mailto:[email protected]>, 
>> http://forums.thefoundry.co.uk/ <http://forums.thefoundry.co.uk/>
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users 
>> <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

_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to