-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomotion_saver_snipets.py
183 lines (118 loc) · 5.6 KB
/
automotion_saver_snipets.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
## [value NODE_NAME.projDir]/folder1/floder2/[value NODE_NAME.section]_[value NODE_NAME.floor]/1.filename_P[value NODE_NAME.plan]_S[value NODE_NAME.section]_L[value NODE_NAME.floor].####.jpg
##
#
# import nuke
nProject = nuke.root()
nodesList=list()
writeNodesList=list()
lastframeList=list()
firstframeList=list()
## create write nodes and fill lists
for iiter, enumSel in enumerate(nuke.selectedNodes()):
fileName = enumSel.knob('file').value()
inFirstFrame = enumSel.knob('first').value()
inLastFrame = enumSel.knob('last').value()
newFileName = fileName[:-4]+".mov"
print newFileName
a=nuke.nodes.Write(file=newFileName, file_type="mov", first=inFirstFrame, last=inLastFrame, use_limit=True, create_directories=True)
a.setInput(0, enumSel)
nodesList.append(enumSel)
writeNodesList.append(a)
lastframeList.append(inLastFrame)
firstframeList.append(inFirstFrame)
print writeNodesList
## set codec
##for y in writeNodesList:
# y.knob("meta_codec").setValue("mp4v")
#y.knob("_jpeg_quality").setValue(1)
# print "codecType ", y.knob("meta_codec").value()
#print "max quality", y.knob("mov64_quality_max").value()
## set project maxFrame
nProject.knob("last_frame").setValue(max(lastframeList))
nProject.knob("first_frame").setValue(min(firstframeList))
##
import csv
import sys
WriteBase = 'Write_MAIN'
ReadBase = 'ReadMAIN'
file=open(r"z:/production/Z_Exterior/01_Rumyzncevo/Renders/PANO_PLAN_EXT/00_system/data/data_01.txt", "r")
csvReader = csv.reader(file, delimiter="\t")
EpicWrite = nuke.toNode(WriteBase)
seqTime = str(int(nuke.toNode(ReadBase).knob('first').getValue()))+'-'+str(int(nuke.toNode(ReadBase).knob('last').getValue()))
for row in csvReader:
print (row)
print (len(row))
nuke.toNode('NODE_NAME').knob('framehold').setValue(int(row[0]))
nuke.toNode('NODE_NAME').knob('section').setValue(row[1])
nuke.toNode('NODE_NAME').knob('floor').setValue(row[2])
print nuke.toNode('NODE_NAME').knob('framehold').getValue()
print nuke.toNode('NODE_NAME').knob('section').getValue()
print nuke.toNode('NODE_NAME').knob('floor').getValue()
nuke.executeBackgroundNuke(nuke.EXE_PATH,[EpicWrite],nuke.FrameRanges(seqTime),['main'],{'maxThreads':4, 'maxCache':"5G"})
##
import csv
import sys
import time
WriteBase = 'Write_MAIN' # node name in variable
ReadBase = 'ReadMAIN' # same
file=open(r"z:/production/Z_Exterior/01_Rumyzncevo/Renders/PANO_PLAN_EXT/00_system/data/data_01.txt", "r") # open file for read
csvReader = csv.reader(file, delimiter="\t") # read csv contrnt with space delimiter
EpicWrite = nuke.toNode(WriteBase) # locate node in graph with setted name
seqTime = str(int(nuke.toNode(ReadBase).knob('first').getValue()))+'-'+str(int(nuke.toNode(ReadBase).knob('last').getValue())) # compose string of frames for write node
# cycle in file
for row in csvReader: # in csv file for each row -- ERROR -- ROW is actually column in csv
print (row) #
print (len(row)) #
nuke.toNode('NODE_NAME').knob('framehold').setValue(int(row[0])) # set framehold value from file
nuke.toNode('NODE_NAME').knob('section').setValue(row[1]) # set cetion value from file
nuke.toNode('NODE_NAME').knob('floor').setValue(row[2]) # set floor value from file
print nuke.toNode('NODE_NAME').knob('framehold').getValue() # print results
print nuke.toNode('NODE_NAME').knob('section').getValue()
print nuke.toNode('NODE_NAME').knob('floor').getValue()
nuke.executeBackgroundNuke(nuke.EXE_PATH,[EpicWrite],nuke.FrameRanges(seqTime),['main'],{'maxThreads':4, 'maxCache':"5G"}) # setup bg render with one write node. exe_path is ok, need to spec writenode, framerange string
time.sleep(1) # wait for next iteration
import csv
import sys
txtFile = nuke.toNode('NODE_NAME').knob('datafile').getValue()
file=open(txtFile, "r")
csvReader = csv.reader(file, delimiter="\t")
for row in csvReader:
print (row)
print (len(row))
#
[value NODE_NAME.projDir]/[value NODE_NAME.plan]/post_[value NODE_NAME.type]/S[value NODE_NAME.section]_L[value NODE_NAME.floor]/1.P[value NODE_NAME.plan]_S[value NODE_NAME.section]_L[value NODE_NAME.floor].####.jpg
[value PATHS_NODE.path]/C[value PATHS_NODE.CEKK]/bg/BASE_CAMERA_C0[value PATHS_NODE.CEKK]_####.exr
Z:/production/Rumyancevo-88/floor/RENDERS/C04/180330/Final/1.VRayDenoiser.####.tif
[value PATHS_NODE.path]/C[value PATHS_NODE.CEKK]/base/1.VRayDenoiser.####.tif
[value PATHS_NODE.path]/C[value PATHS_NODE.CEKK]/base/1_.Alpha.####.tif
[value PATHS_NODE.path]/C[value PATHS_NODE.CEKK]/base/1_.VRayReflection.####.tif
[value PATHS_NODE.path]/out/C[value PATHS_NODE.CEKK]/[value PATHS_NODE.framehold]/1.Denoiser.####.jpg
#### WOKRKING METHOD ###
from os import listdir
# writer = 'WRITER'
endWrite = nuke.toNode('WRITER')
ctrl = nuke.toNode('PATHS_NODE')
timestring = ctrl.knob('allframes').getValue()
fstart = int(ctrl.knob('fstart').getValue())
path = ctrl.knob('path').getValue() + "/" + "C" + ctrl.knob('CEKK').getValue() + "/bg/"
fend = len(listdir(path))
# print (fend)
# fend = int(nuke.toNode(ctrl).knob('fend').getValue())+1
# iterate over levels with framehold and fstart fend
for i in range(0, fend, 1):
# set value to framehold and start bg render
ctrl.knob('framehold').setValue(int(i))
nuke.executeBackgroundNuke(nuke.EXE_PATH,[endWrite],nuke.FrameRanges(timestring),['main'],{'maxThreads':4, 'maxCache':"5G"})
## time.sleep(2)
print "submitted"
pt = ctrl.knob('path').getValue()
dirlist = listdir(pt)
print (dirlist)
dl = list()
for i in dirlist:
if i[0]=="C":
dl.append(i[1:])
print dl
type(dl[0])
dir(dirlist[0])
type(dirlist[0])