1 import nuke
2 import string
3 from os import unlink as unlink
4 from foundry.frameserver.nuke.bases import RenderQueueObserverMixin
5 from foundry.ui import executeInMainThread
6
7 incompleteRenderStr = """Render did not complete, do you want to show the completed range?
8 Frame range contains %s frames but only %s finished."""
9
10
12
13
14 - def __init__(self, flipbookDialog, flipbookToRun):
15 self._flipbookDialog = flipbookDialog
16 self._flipbookToRun = flipbookToRun
17
23
24
26
27 options = self._flipbookDialog._getOptions( self._nodeToFlipbook )
28 extraOptions = self._flipbookToRun.getExtraOptions( self._flipbookDialog, self._nodeToFlipbook )
29 options.update( extraOptions )
30 return options
31
32
36
37
39 self._nodeToFlipbook = self._flipbookDialog._node
40
41
50
51
53
54 - def __init__(self, flipbookDialog, flipbookToRun):
56
60
61
64
65
87
88
89
91
92 - def __init__(self, flipbookDialog, flipbookToRun):
94
96
97
98
99 try:
100 frameRange, views = self.getFlipbookOptions()
101 self._flipbookDialog._showDeprecatedWarningMessage()
102 nuke.executeBackgroundNuke(nuke.EXE_PATH,
103 [self._writeNode],
104 frameRange,
105 views,
106 self._flipbookDialog._getBackgroundLimits(),
107 self._flipbookDialog._continueOnError.value(),
108 self._flipbookDialog._flipbookEnum.value(),
109 self.getOptions() )
110 except RuntimeError, msg:
111 import traceback
112 print traceback.format_exc()
113 nuke.delete(self._nodeToFlipbook)
114 self._nodeToFlipbook = None
115 nuke.message("Flipbook render failed:\n%s" % (msg.args[0],))
116
118 - def __init__(self, flipbookDialog, flipbookToRun):
120
121
123 name, wasSaved = self._flipbookDialog.saveFileToRender("tmp_flipbook",True)
124 try:
125 nodeName = self._writeNode.fullName()
126 frameRange, views = self.getFlipbookOptions()
127 flipbookRenderPath= nuke.filename(self._nodeToFlipbook)
128 options = self.getOptions()
129 import hiero.ui.nuke_bridge.FnNsFrameServer as FrameServer
130 task = FlipbookFrameServerTask(name,
131 frameRange,
132 nodeName,
133 flipbookRenderPath,
134 options,
135 views,
136 self._flipbookToRun )
137 FrameServer.renderFrames(
138 name,
139 frameRange,
140 nodeName,
141 views)
142 finally:
143 if wasSaved:
144 unlink(name)
145
147
148 - def __init__(self, scriptPath, frameRange, nodeName, flipbookpath, options, views,flipbookToRun):
149
150 self._flipbookToRun = flipbookToRun
151 self._flipbookpath = flipbookpath
152 self._frameRange = frameRange
153 self._options = options
154 self._views = views
155
156 self._scriptPath = scriptPath
157 self._nodeName = nodeName
158 self._totalFrames = frameRange.maxFrame() - frameRange.minFrame() + 1
159 self._successfulFrames = 0
160 self._completedFrames = 0
161 import hiero.ui.nuke_bridge.FnNsFrameServer as FrameServer
162 FrameServer.addBackgroundRenderObserver(self)
163
165 try:
166 if self._totalFrames != self._successfulFrames:
167 msg = incompleteRenderStr% (self._totalFrames, self._successfulFrames)
168 if nuke.ask(msg) == False:
169 return
170 self._flipbookToRun.runFromPath(self._flipbookpath,
171 self._frameRange,
172 self._views,
173 self._options)
174 except Exception, e:
175 nuke.tprint(e)
176 finally:
177 import hiero.ui.nuke_bridge.FnNsFrameServer as FrameServer
178 FrameServer.removeBackgroundRenderObserver(self)
179
182
184 """ Callback when a frame is rendered. If it's for the script being
185 rendered, increment the count. """
186 if scriptPath == self._scriptPath and nodeName == self._nodeName:
187 self._completedFrames = self._completedFrames + 1
188 self._successfulFrames = self._successfulFrames + 1
189 if self._completedFrames == self._totalFrames:
190 self.renderFinished()
191
192
194 """ Callback when there is an error rendering a frame. Set the error state
195 and cancel. """
196 if scriptPath == self._scriptPath and nodeName == self._nodeName:
197 self._completedFrames = self._completedFrames + 1
198 if self._completedFrames == self._totalFrames:
199 self.renderFinished()
200
202 if scriptPath == self._scriptPath and nodeName == self._nodeName:
203 self._completedFrames = self._completedFrames + 1
204 if self._completedFrames == self._totalFrames:
205 self.renderFinished()
206
207
220