Ooops! Howard is right!

You need to feed nuke.selectedNode() or a node object to it. I did that to 
allow people to use that function from elsewhere while passing node objects 
from loops and whatnots and not just based on the node selection.

Sorry. 

Cheers,
Diogo

On 17/10/2011, at 14:21, Howard Jones <[email protected]> wrote:

> Hi
> Yes works well - I modified it so it had nuke.selectedNode() fed into it it.
> See below though no doubt the formatting may have screwed.
> 
>  
> Howard
> 
> 
> ###    Splits each and every layer on their own pipes using
> ###    shuffle nodes.
> ###    ------------------------------------------
> ###    splitLayers.py
> ###    v1.0 - Last modified: 07/08/2009
> ###    Written by Diogo Girondi
> ###    [email protected]
> 
> import nuke
> 
> def splitLayers( node=nuke.selectedNode() ):
>     
>     '''
>     Splits each and every layer from the selected node into their own pipes
>     '''
>     
>     ch = node.channels()
>     
>     layers = []
>     valid_channels = ['red', 'green', 'blue', 'alpha', 'black', 'white']
>     
>     for each in ch:
>         layer_name = each.split( '.' )[0]
>         tmp = []
>         for channel in ch:
>             if channel.startswith( layer_name ) == True:
>                 tmp.append( channel )
>         if len( tmp ) < 4:
>             for i in range( 4 - len( tmp ) ):
>                 tmp.append( layer_name + ".white" )
>         if tmp not in layers:
>             layers.append( tmp )
>             
>     for each in layers:
>         layer = each[0].split( '.' )[0]
>         ch1 = each[0].split( '.' )[1]
>         ch2 = each[1].split( '.' )[1]
>         ch3 = each[2].split( '.' )[1]
>         ch4 = each[3].split( '.' )[1]
>         
>         if ch1 not in valid_channels:
>             ch1 = "red red"
>         else:
>             ch1 = '%s %s' % ( ch1, ch1 )
>             
>         if ch2 not in valid_channels:
>             ch2 = "green green"
>         else:
>             ch2 = '%s %s' % ( ch2, ch2 )
>             
>         if ch3 not in valid_channels:
>             ch3 = "blue blue"
>         else:
>             ch3 = '%s %s' % ( ch3, ch3 )
>             
>         if ch4 not in valid_channels:
>             ch4 = "alpha alpha"
>         else:
>             ch4 = '%s %s' % ( ch4, ch4 )
>             
>         prefs = "in %s %s %s %s %s" % (layer, ch1, ch2, ch3, ch4)
>         shuffle = nuke.createNode( 'Shuffle', prefs, inpanel=False )
>         shuffle.knob( 'label' ).setValue( layer )
>         shuffle.setInput( 0, node )
>         
> From: JKehler <[email protected]>
> To: Nuke user discussion <[email protected]>
> Sent: Monday, 17 October 2011, 17:26
> Subject: [Nuke-users] Diogo's splitLayers.py script
> 
> Hey.
> 
> Just wondering if anyone has had any luck using the splitLayers.py 
> script.?(Diogo maybe)
> I tried running it on an .exr file but nothing happened.
> 
> Thanks for the feedback.
> 
> JK
> _______________________________________________
> 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
_______________________________________________
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