Here is the code snippet. Sorry for misaligned lines. Anyone knows a better way for displaying code?
def createWriteDir():
import nuke, os
import re
#view = nuke.thisView()
views = nuke.views()
file = nuke.filename(nuke.thisNode())
dir = os.path.dirname(file)
viewdirs = []
if re.search('%V', dir): # replacing %V with view name
for v in views:
viewdirs.append(re.sub('%V', v, dir))
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)
(I edited the script, there was an unnecessary try: except part)
No comments:
Post a Comment