I thought I’d share this beauty with you all.
I’m currently working as part of a two man comp team and as such we are missing so many of the lovely scripts and buttons you get when you work in a large facility. Finding this little beauty is going to save us a lot of time. It wasn’t completely plain sailing to install so I thought I would share my findings here.
The node automatically creates and names the folders to render to based on your script name. Genius! And a huge time saver.
The Autowrite node is written by Tim Bowman and can be downloaded from Nukepedia.
It takes the existing write node and adds Python to it that works out your directory structure based on your current Nuke script location. The numbers in the window above are changed to suit your pipeline. The node has a read out in the node graph – this gives you feedback on where the write node is going to render to. This is a very useful feature.
The tricky part of using the node comes when you want Nuke to create the directories when they don’t already exist. Also in our two man team we wanted the write node to overwrite anything that’s there already (this last part proved difficult to find the code for).
Add the following to your init.py file and all will be well with the world… and your Autowrite node.
def createWriteDir(): #Create dir callack def createWriteDir(): import nuke, os, errno file = nuke.filename(nuke.thisNode()) dir = os.path.dirname( file ) osdir = nuke.callbacks.filenameFilter( dir ) # cope with the directory existing already by ignoring that exception try: os.makedirs( osdir ) except OSError, e: if e.errno != errno.EEXIST: raise nuke.addBeforeRender(createWriteDir)
It took me a while to work out this part of the puzzle. It uses the callback Python function ‘beforeRender’. This is run before a render is executed. It checks if the directory structure for the write node exists and if it doesn’t it creates it.