Nathan,

FYI --

Here's what I came up with; yet another variation on a function to create Write 
node output directories for all the write nodes in a script -- except for the 
write nodes that are either a) disabled or b) without an input or c) without an 
output pathname or d) have an existing directory path.  Of course, I'll add it 
as a menu selection… Please let me know if you see any glaring errors! Thanks 
for your help.


def createWriteDirs():
    import nuke, os, errno
    for w in nuke.allNodes('Write'):
        name=nuke.Node.name(w)
        file=nuke.filename(w)
                if w['disable'].value()==True:
                        print "%s is disabled, skipping..." %(name)
                elif w.inputs()==0:
                        print "%s has no input, skipping..." %(name)
                elif file==None:
                        print "%s has an empty output path, skipping..." %(name)
                elif (os.path.isdir(os.path.dirname(file))):
                        print "%s path exists, skipping..." %(name)
                else:
                        dir = os.path.dirname(file)
                        osdir = nuke.callbacks.filenameFilter(dir)
                        try:
                                os.makedirs(osdir)
                        except OSError, e:
                                if e.errno != errno.EEXIST:
                                        raise
                        finally:
                                print "%s - created output directory:\n %s" 
%(name,osdir)
                                nuke.message("%s - created output directory:\n 
%s" %(name,osdir))
createWriteDirs()



Rich


Rich Bobo
Senior VFX Compositor

Mobile:  (248) 840-2665
Web:  http://richbobo.com/

"A man should never be ashamed to own that he has been in the wrong, which is 
but saying that he is wiser today than he was yesterday."
- Alexander Pope (1688-1744) English Poet






On May 16, 2012, at 9:13 PM, Richard Bobo wrote:

> Perfect. Thanks, Nathan!
> 
> Rich
> 
> On May 16, 2012, at 9:10 PM, Nathan Rusch wrote:
> 
>> node['disable'].value()
>>  
>> If it’s True, the node is disabled.
>>  
>> -Nathan
>> 
>>  
>> From: Richard Bobo
>> Sent: Wednesday, May 16, 2012 6:07 PM
>> To: Nuke-Users Mailing List
>> Subject: [Nuke-users] Python Question - How to test for disabled node…?
>>  
>> Hi,
>>  
>> Anyone know a good way to test a node to see if it is disabled? I want to be 
>> able to ignore all disabled Write nodes in my script. I figured out how to 
>> ignore unconnected nodes and nodes without any pathname, but I haven't 
>> stumbled on the method for checking if the node is disabled, yet...
>>  
>> Thanks for any help,
>>  
>> Rich
>> 
>> 
>> 
>> Rich Bobo
>> Senior VFX Compositor
>> 
>> Mobile:  (248) 840-2665
>> Web:  http://richbobo.com/
>> 
>> "Failure is the opportunity to begin again more intelligently."
>> - Henry Ford
>>  
>>  
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> 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

_______________________________________________
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