Hi guys, How can I implement solutions like this in Hiero or Nuke Studio? I'm looking to include a bit of python into the "before render" of a write node generated by the export process.
If you make a comp node, and then version it up, so that it would be rendering to a non-existent directory (ie. SHOT010_comp_v02) If you render this in the timeline, it will *error *because it can't make that new directory. Thanks, Ryan On Fri, Apr 27, 2012 at 9:40 PM, Nathan Rusch <nathan_ru...@hotmail.com> wrote: > Not to beat a dead horse, but there are a couple other things that may be > worth considering: > > 1) The views your node is trying to write may not match nuke.views(). > 2) If your code is running on a farm, there’s always the chance of > collisions, even if you check for an existing directory, so it’s a good > idea to handle EEXIST exceptions gracefully. If you wanted to go a step > further, you could just skip the existence check altogether and simply try > to create the directory, ignore an EEXIST exception if raised, and move on. > > Another take on the same: > > def createWriteDirs(): > import os > import re > baseDir = os.path.dirname(nuke.filename(nuke.thisNode())) > viewTokenRE = re.compile(r'%V') > if viewTokenRE.search(baseDir): > nodeViews = nuke.thisNode()['views'].value().split() > outDirs = [nuke.filenameFilter(viewTokenRE.sub(v, baseDir)) for v > in nodeViews] > else: > outDirs = [nuke.filenameFilter(baseDir)] > for outDir in outDirs: > if not os.path.exists(outDir): > print 'Creating output directory: %s' % outDir > try: > os.makedirs(outDir) > except (OSError, IOError) e: > # Don't choke if directory has been created since we > checked. > # This can be an issue with farm renders. > import errno > if e.errno != errno.EEXIST: > raise > > -Nathan > > > *From:* Bill Gilman <bi...@prologue.com> > *Sent:* Friday, April 27, 2012 11:42 AM > *To:* Nuke user discussion <nuke-users@support.thefoundry.co.uk> > *Subject:* Re: [Nuke-users] Auto-create directories via Write node - > Python"before render"? > > Here's one for stereo work (works for non-stereo as well): > > > def createWriteDir(): > import nuke, os > import re > #view = nuke.thisView() > views = nuke.views() > file = nuke.filename(nuke.thisNode()) > dir = os.path.dirname(file) > viewdirs = [] > try: > if re.search('%V', dir).group(): # replacing %V with view > name > for v in views: > viewdirs.append(re.sub('%V', v, dir)) > except: > pass > if len(viewdirs) == 0: > osdir = nuke.callbacks.filenameFilter(dir) > if not os.path.isdir(osdir): > os.makedirs (osdir) > else: > for vd in viewdirs: > osdir = nuke.callbacks.filenameFilter(vd) > if not os.path.isdir(osdir): > os.makedirs (osdir) > print 'Directory (with viewname) created: %s' % (osdir) > > nuke.addBeforeRender(createWriteDir) > > > _______________________________________________ > Nuke-users mailing list > Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >
_______________________________________________ Nuke-users mailing list Nuke-users@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users