AutoWrite

 v1.0

Semi-automatic output paths for Write nodes in Nuke.
Author
Tim BOWMAN
http://netherlogic.com
Requirements
6.0, 6.1 or later
Linux, Mac, Windows
Created on: 24/11/2010
Updated on: 23/11/2010
Downloads: 527
Login or Register

AutoWrite

Semi-automatic output paths for Write nodes in Nuke.

The gist:

Create output paths by parsing the Nuke script name and path.

Most of the information needed for the output of a Nuke script is contained in it's name. We can reduce manual name changing on behalf of the artists and simultaneously increase consistency by creating a Write node that creates (and updates) it's own output path by parsing the script's name.

The details:

Most projects at a facility will use a standardized file hierarchy, which means that a Nuke script's name and path on the filesystem will often contain all the information needed to define the output destination for it's render. As an example, here is a path from one of my comp scripts:

/Volumes/PICO/show/testproj/abc/abc123/nuke/abc123_comp_v01.nk

From this path, we can see that I have a project called "testproj" that has a sequence with an abbreviation "abc" and that there is a shot called "abc123" in that sequence. I am working on composite version #1 on that shot.

What I do to create an AutoWrite is add a tab to the Write node where I break down these path elements in four knobs: project root, sequence name (or abbreviation), shot name and script name. These knobs are then re-assembled to create the AutoWrite's output path.

Since each facility creates their own file structure, I have set it up for my own structure and I leave it to you to parse your own paths for your facility.

Installation:

Put this script in your Nuke path and add this line to your menu.py: import autowrite

Important note:

Because this node creates paths that don't yet exist on the filesystem, you'll want to implement the beforeRender callback listed in the Nuke manual (page 575 for Nuke 6.1v2.) That way your auto-generated output paths get auto-created on render and life stays groovy.

LICENSE

Copyright (c) 2010 Tim BOWMAN

Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions: The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments (16)

Laureline Lansil said:

...
thanks a lot !
February 22, 2011

Anselm Lier said:

...
Thank you very much! This Script helps me a lot! I have been looking for something like this for a long time...
July 05, 2011

Anselm Lier said:

...
after installing your script, Nuke won't overwrite existing files from the Write node nor when flipbooking. Is there a way tot tell Nuke to overwrite existing files?
July 06, 2011

Tim BOWMAN said:

...
Hi Anselm. That's a curious problem you've got there. The AutoWrite doesn't change anything about how the files are written, it just just helps you put them in the right place. Take a look at the error message(s) you're getting to help you figure out what's happening. Does this issue occur when using a regular write node, too?
July 06, 2011

Anselm Lier said:

...
Thanks for the quick response...
Yes, it also occurs when i use a regular write node. Previously I only encountered this problem when rendering exr. But now it also happens when writing tga.
July 06, 2011

Anselm Lier said:

...
It might be a windows related problem though. I just deleted the file manually and Nuke still won't render to the same place.
July 06, 2011

Anselm Lier said:

...
I just figured out that your script is not the problem. Somehow the beforRender callback is what keeps me from overwriting. I wrote it according to the latest Nuke manual. Can you maybe tell me what I did wrong? Here is what I entered in the init.py:

def createWriteDir():
import nuke, os
file = nuke.filename(nuke.thisNode())
dir = os.path.dirname( file )
osdir = nuke.callbacks.filenameFilter( dir )
os.makedirs(osdir)
nuke.addBeforeRender(createWriteDir)

When I remove the init.py everything runs normally, but then I would have to create the directories manually, right?

Cheers,
Anselm
July 06, 2011

Anselm Lier said:

...
For those interested I'll post a solution that someone gave me in a different forum.
Appearently it's not overwriting the file that's the problem. It's creating the path. By os.makedirs(osdir) Nuke tries to create a path that already exists. So the solution is to put
if not os.path.isdir(osdir): os.makedirs(osdir)
instead.
July 08, 2011

asin shin said:

...
hello sir, thankyou for the script, im still new to nuke and python. im kinda lost from the beginning, can u guide me?

regards,
shin
August 03, 2011

Anselm Lier said:

...
In your /.Nuke folder you can save a menu.py and a init.py file. You can create and save these files with the Nuke script editor. Or even a text editor.
You install the autowrite script according to the manual given above. Then you put these lines into your init.py :
def createWriteDir():
import nuke, os
file = nuke.filename(nuke.thisNode())
dir = os.path.dirname( file )
osdir = nuke.callbacks.filenameFilter( dir )
if not os.path.isdir(osdir): os.makedirs(osdir)
nuke.addBeforeRender(createWriteDir)
The lines 2 to 6 are indented (=moved to the right, ? my english is not so good ?) by one tab. Otherwise they might not work.
Usually the .Nuke folder is located in your users directory.
Hope I could help you. I'm also still a newby to Nuke...

I also changes some lines in the autowrite script to make it fit to my folder structure. But that is quite simple, just read the lines carefully and you will find out what they do in detail.

To make changes work you need to restart Nuke.

Regards,
Anselm
August 03, 2011

vivek tekale said:

...
hey thanks for the script... but i hv one question... if i want a version up render from the same nuke file ?
March 24, 2012

Anselm Lier said:

...
There is a part in the script that says [value script]. If you have this in your write nodes file path you only have to save your script as mynukesrcipt_v01.nk. Now if you want to save/render a new version just hit shift+alt+s and nuke saves a new version and the write node will put the new name into its file path due to the [value script].
Is that what you wanted to know?
My write nodes file path for example is [join [lrange [split [value root.name] / ] 0 3 ] / ]/03_Output/01_WIP/[value script]_[value views]/[value script]_[value views].d.tga
April 03, 2012

kaushal shah said:

...
hi, while clicking on AutoWrite i am getting following error...

name 'autowrite' is not defined

Traceback (most recent call last):
File "", line 1, in
NameError: name 'autowrite' is not defined

any clue for this :))
May 02, 2012

kaushal shah said:

...
i have solved the problem
thank you for ur amazing superb script
May 02, 2012

kaushal shah said:

...
Ooops!!! still i want to add something more in Auto Write node....
i am using 6.3 v4
(for .dpx render format)
colorspace raw data should be on
&
transfer should be log

what shd i add into the script ?
May 03, 2012

vivek tekale said:

...
hi kaushal...
That is all done in my comp... u'll find the codes for raw data ON and transfer to log.. check in my PC...
May 03, 2012

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy