-
Notifications
You must be signed in to change notification settings - Fork 0
/
breaker.py
64 lines (54 loc) · 1.84 KB
/
breaker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'''
BreakDowner : a little tool to render the various pass for breakdowns
It takes a number of nodes in input. Plugs some write nodes.
Renders out based on the directory structure established in Hobbes
author : Victor
version : 0.1
'''
import nuke
import os
import re
import hobbes
reload(hobbes)
filePath = nuke.Root()['name'].value()
h = hobbes.Hobbes(verbose = False)
def BreakDowner(listNodes = nuke.selectedNodes()):
if listNodes is None or listNodes == []:
raise TypeError, 'You have not selected any nodes !'
listWriteNode = []
for node in listNodes:
nodeName = node['name'].value()
wName = 'Write_'+nodeName
w = nuke.nodes.Write()
w['name'].setValue(wName)
w.setInput(0, node)
listWriteNode.append(w)
project = h.currentProject(filePath)
print project
print h.PROJECTS
shotNumber = h.currentShot(filePath)#.split('/')[-2]
print shotNumber
pathBKD = os.path.join(h.PROJECTS, project, h.SHOTS, h.RENDER, shotNumber)#, 'Breakdown')
if not os.path.exists(pathBKD):
try:
os.mkdir(pathBKD)
except IOError:
print 'Error IO'
pathBKD = os.path.join(pathBKD, 'Breakdown')
try:
if not os.path.exists(pathBKD):
os.mkdir(pathBKD)
else:
print 'Already Created'
except IOError:
print 'An error occured whil creating the dir'
return -1
#We set the correct path for the write nodes
renderOrder = 1
for w in listWriteNode:
fileKnob = os.path.join(pathBKD, w['name'].value())
fileKnob += '.'+str(nuke.frame())+'.exr'
w['file_type'].setValue('exr')
w['file'].setValue(fileKnob)
#write
nuke.execute(w['name'].value(), int(nuke.frame()), int(nuke.frame()))