def getRange(gizmo): ''' getRange(node): This function set a range in order to execute an action to the node. It depends on the gizmo's knob 'tdRangeMode'. If the 'tdRangeMode' is set to 'Custom' it opens a pop-up window where we can set a user range before executing the action. Other range modes could be choose like 'Global' or 'Current'. @param 'gizmo': Must be a Gizmo object Nuke. Created on March 11, 2013 @author: Ryuu ''' #| TESTS |------------------------------------------------------------------------------------- if gizmo != None: if (gizmo.__class__.__name__) != 'Gizmo': tdLogger.printError('td.nuke.gizmos.vertexTracker3D', 'getRange()', "Argument 'node' must be a Gizmo object Nuke") #| VARIABLES |--------------------------------------------------------------------------------- rangeMode = gizmo.knob('tdRangeMode').value() #| EXECUTE |----------------------------------------------------------------------------------- if rangeMode == 'Custom': firstFrame = nuke.root().firstFrame() lastFrame = nuke.root().lastFrame() userInput = nuke.getFramesAndViews('Range', '%s-%s' %(firstFrame, lastFrame)) if not userInput: pass else: views = userInput[1] if views == ['main']: views = ['L', 'R'] userRange = nuke.FrameRange(userInput[0]) userFirstFrame = userRange.first() userLastFrame = userRange.last() userIncrFrame = userRange.increment() execRange(gizmo, userFirstFrame, userLastFrame, userIncrFrame, views) elif rangeMode == 'Global': views = nuke.views() firstFrame = nuke.root().firstFrame() lastFrame = nuke.root().lastFrame() execRange(gizmo, firstFrame, lastFrame, 1, ['L', 'R']) elif rangeMode == 'Current': views = nuke.views() currentFrame = nuke.frame() execRange(gizmo, currentFrame, currentFrame, 1, ['L', 'R'])
def bakeExpressions(nodes=None, start=None, end=None, views=None): if nodes is None: nodes = nuke.selectedNodes() if not nodes: nuke.message('No nodes to bake') return scriptRange = nuke.root().frameRange() if start is None: start = scriptRange.first() if end is None: end = scriptRange.last() if views is None: views = nuke.views() elif not views: nuke.message('No views to bake') return elif not set(views).issubset(nuke.views()): nuke.message('Not all views in %s exist in script' % views) return for node in nodes: for knob in node.knobs().itervalues(): if isinstance(knob, nuke.Array_Knob): for view in views: # There's currently no way to ask a knob if it has an # expression at a given view, so we have to check the # AnimationCurve objects for that. However, we can still # use knob.isAnimated() to partially optimize this. if knob.isAnimated(view=view): aSize = 1 if knob.singleValue( view) else knob.arraySize() for index in range(aSize): anim = knob.animation(index, view=view) if anim is None or anim.noExpression(): continue for f in range(start, end + 1): #knob.setValueAt(anim.evaluate(f), f, index) anim.setKey(f, anim.evaluate(f)) knob.setExpression('curve', channel=index, view=view) # Even if the expression would have evaluated to a # constant (flat) curve, we can't tell until after # it has been baked and the expression is gone. if anim.constant(): knob.clearAnimated(index, view=view)
def copyKeys(verbose=False): tmpDir = os.environ['NUKE_TEMP_DIR']+'/' if verbose: print ('tempDir is '+tmpDir) numViews=len(nuke.views()) keysList=[] for node in nuke.allNodes(): nodeAnimated=isNodeAnimated(node) if nodeAnimated : for knob in node.knobs().values(): if knob.isAnimated(): aSize = knob.arraySize() for index in range(aSize): for vues in range(1,numViews+1): anim = knob.animation(index,vues) try: numKeys=anim.size() except: continue if numKeys: #step through the keys - check if they are selected then paste the values from timebar onwards for i in range(numKeys): keySelected= (anim.keys()[i].selected) if keySelected: keyVals= (anim.keys()[i].x, anim.keys()[i].y) if verbose: print ('keySelected: '+str(keySelected)+' keyvalues: '+str(keyVals)) keysList.append((keyVals[0],keyVals[1])) i+=1 if verbose: nuke.message(str(keysList)) return (keysList)
def get_params(self): """Returns a dictionary of the job parameters from the submit render gui.""" params = dict() params['plugin_version'] = __version__ params['num_instances'] = self.num_slots.value() for inst_type in self.zync_conn.INSTANCE_TYPES: if self.instance_type.value().startswith(inst_type): params['instance_type'] = inst_type # these fields can't both be blank, we check in submit() before # reaching this point params['proj_name'] = self.existing_project.value().strip() if params['proj_name'] == '': params['proj_name'] = self.new_project.value().strip() params['frange'] = self.frange.value() params['step'] = self.fstep.value() params['chunk_size'] = self.chunk_size.value() params['upload_only'] = int(self.upload_only.value()) params['priority'] = int(self.priority.value()) parent = self.parent_id.value() if parent != None and parent != '': params['parent_id'] = int(self.parent_id.value()) params['start_new_instances'] = '1' params['skip_check'] = '1' if self.skip_check.value() else '0' params['notify_complete'] = '0' params['scene_info'] = {'nuke_version': nuke.NUKE_VERSION_STRING, 'views': nuke.views()} caravr_version = ZyncRenderPanel._get_caravr_version() if caravr_version: params['scene_info']['caravr_version'] = caravr_version return params
def __init__(self): import nuke.rotopaint super(RotoViewsPanel, self).__init__('Change views on RotoPaint Nodes...') self.changeKnob = nuke.Enumeration_Knob( 'change', 'change', ['all RotoPaint nodes', 'selected RotoPaint nodes']) self.addKnob(self.changeKnob) self.viewsKnob = nuke.MultiView_Knob('views') self.addKnob(self.viewsKnob) self.viewsKnob.setValue((' ').join(nuke.views())) self.okButton = nuke.Script_Knob("Change Views") self.addKnob(self.okButton) self.okButton.setFlag(nuke.STARTLINE) self.cancelButton = nuke.Script_Knob("Cancel") self.addKnob(self.cancelButton)
def getFrameList(fileKnob, existingFilePaths): ''' Return a list of frames that are part of the sequence that fileKnob is pointing to. If the file path is already in existingFilePaths it will not be included. ''' node = fileKnob.node() originalCacheMode = node['cacheLocal'].value() node['cacheLocal'].setValue('never') #frameRange = nuke.FrameRange(node.firstFrame(), node.lastFrame(), 1) frameRange = nuke.FrameRange(node['first'].value(), node['last'].value(), 1) print 'frame range: {0}-{1}'.format(frameRange.first(), frameRange.last()) outputContext = nuke.OutputContext() frameList = [] # Cycle over views for viewNumber in xrange(outputContext.viewcount()): viewName = outputContext.viewname(viewNumber) # Skip "default" view if viewName not in nuke.views(): continue # Set context to viewNumber outputContext.setView(viewNumber) # Cycle over frame range for frameNumber in frameRange: outputContext.setFrame(frameNumber) filePath = fileKnob.getEvaluatedValue(outputContext) if filePath not in existingFilePaths: frameList.append(filePath) node['cacheLocal'].setValue(originalCacheMode) return frameList
def pasteSelected(verbose=False): numViews=len(nuke.views()) offset=getOffset(False) keysList=[] nuke.root().begin() for node in nuke.allNodes(): if node.Class() not in exclusionList: nodeAnimated=isNodeAnimated(node) if nodeAnimated : for knob in node.knobs().values(): if knob.isAnimated(): try: aSize = knob.arraySize() for index in range(aSize): for vues in range(numViews+1): anim = knob.animation(index,vues) numKeys=anim.size() if numKeys: #step through the keys - check if they are selected then paste the values from timebar onwards for i in range(numKeys): keySelected= (anim.keys()[i].selected) if keySelected: keyVals= (anim.keys()[i].x, anim.keys()[i].y) if verbose: print ('keySelected: '+str(keySelected)+' keyvalues: '+str(keyVals)+' offset: '+str(offset)) anim.setKey(keyVals[0]+offset,keyVals[1]) keysList.append((keyVals[0]+offset,keyVals[1])) except: continue
def stereoCam(node=None, interoc=.6): ''' Create a simple stereo camera or convert an existing one. args: node - camera node to convert to stereo. if None a camera will be created interoc - distance between right and left view ''' try: node = node or nuke.selectedNode() except ValueError: # IF NO NODE IS GIVEN AND NOTHING IS SELECTED, CREATE A NEW NODE node = nuke.createNode('Camera2') # GET SCRIPT SETTIONGS' VIEWS views = nuke.views() leftView = views[0] rightView = views[1] # THE OFFSET AS REQUESTED rightOffset = float(interoc) / 2 leftOffset = -rightOffset # THE KNOB TO SPLIT if node['useMatrix'].value(): knob = node['matrix'] leftEyeMatrix = node['transform'].value( ) # GETS MATRIX BUT IN REVERSE ORDER rightEyeMatrix = nuke.math.Matrix4(leftEyeMatrix) # COPY MATRIX # GET THE NEW VALUES FOR LEFT AND RIGHT EYE leftEyeMatrix.translate(leftOffset, 0, 0) rightEyeMatrix.translate(rightOffset, 0, 0) # REVERSE FOR ASSIGNMENT leftEyeMatrix.transpose() rightEyeMatrix.transpose() # IF THERE ARE MORE THAN 2 VIEWS MAKE SURE TO SPLIT OFF LEFT VIEW AS WELL if len(views) > 2: knob.splitView(leftView) knob.splitView(rightView) # ASSIGN VALUES for i in range(16): knob.setValueAt(leftEyeMatrix[i], nuke.frame(), i, leftView) knob.setValueAt(rightEyeMatrix[i], nuke.frame(), i, rightView) else: knob = node['translate'] # GET THE NEW VALUES FOR LEFT AND RIGHT EYE leftEye = knob.value(0) + leftOffset rightEye = knob.value(0) + rightOffset # IF THERE ARE MORE THAN 2 VIEWS MAKE SURE TO SPLIT OFF LEFT VIEW AS WELL if len(views) > 2: knob.splitView(leftView) knob.splitView(rightView) # ASSIGN NEW VALUE knob.setValue(leftEye, 0, view=leftView) knob.setValue(rightEye, 0, view=rightView)
def getFrameList(fileKnob, existingFilePaths): ''' Return a list of frames that are part of the sequence that fileKnob is pointing to. If the file path is already in existingFilePaths it will not be included. ''' node = fileKnob.node() originalCacheMode = node['cacheLocal'].value() node['cacheLocal'].setValue('never') frameRange = nuke.FrameRange(node.firstFrame(), node.lastFrame(), 1) outputContext = nuke.OutputContext() frameList = [] # Cycle over views for viewNumber in xrange(outputContext.viewcount()): viewName = outputContext.viewname(viewNumber) # Skip "default" view if viewName not in nuke.views(): continue # Set context to viewNumber outputContext.setView(viewNumber) # Cycle over frame range for frameNumber in frameRange: outputContext.setFrame(frameNumber) filePath = fileKnob.getEvaluatedValue(outputContext) if filePath not in existingFilePaths: frameList.append(filePath) node['cacheLocal'].setValue("always") #########node['cacheLocal'].setValue(originalCacheMode) my fix return frameList
def checkReadNodeViews(read): """ Check if a read has multiple views, and if so, ask the user if they want to add them to the root node. """ global UserAlreadySaidNo if not UserAlreadySaidNo: views = getViews(read) if views: # Find the views in the read that do not exist on the Root node and if # there are any, ask the user what to do. rootViews = nuke.views() missingViews = [view for view in views if view not in rootViews] if missingViews: userChoice = nuke.showCreateViewsDialog(missingViews) if userChoice is nuke.DONT_CREATE_VIEWS: UserAlreadySaidNo = True elif userChoice is nuke.REPLACE_VIEWS: viewsToDelete = [ view for view in rootViews if view not in views ] # Create all views in the clip createViews(views) # Remove the views that are not in views for existingView in viewsToDelete: nuke.root().deleteView(existingView) elif userChoice is nuke.ADD_VIEWS: # Create only the missing views createViews(missingViews)
def rrSubmit_CreateSingleJobs_Node(jobList, noLocalSceneCopy, node): nViews = nuke.views() if node["disable"].value(): return pathScripted = "" writeNode = node writeNodeName = writeNode["name"].value() if isGizmo(node): with node: gList = nuke.allNodes("Write") + nuke.allNodes("DeepWrite") for gnode in gList: if gnode["disable"].value(): continue pathScripted = gnode["file"].value() if (pathScripted == None) or (len(pathScripted) < 3): continue writeNode = gnode if isScriptedOutput(pathScripted, True): noLocalSceneCopy[0] = True else: pathScripted = writeNode["file"].value() if (pathScripted == None) or (len(pathScripted) < 3): return newJob = rrJob() rrSubmit_fillGlobalSceneInfo(newJob) useStereoFlag = False if len(nViews) == 2: useStereoFlag = True newJob.imageStereoR = nViews[0] newJob.imageStereoL = nViews[1] if writeNode["use_limit"].value(): newJob.seqStart = writeNode["first"].value() newJob.seqEnd = writeNode["last"].value() newJob.imageFileName = nuke.filename(writeNode) if (newJob.imageFileName == None) or (len(newJob.imageFileName) < 3): return if newJob.seqStart == newJob.seqEnd and (newJob.imageFileName.find("#") < 0): newJob.imageSingleOutput = True if useStereoFlag: if newJob.imageFileName.find("%V") >= 0: newJob.imageFileName = string.replace(newJob.imageFileName, "%V", "<Stereo>") elif newJob.imageFileName.find("%v") >= 0: newJob.imageFileName = string.replace(newJob.imageFileName, "%v", "<Stereo>") newJob.imageStereoR = newJob.imageStereoR[0] newJob.imageStereoL = newJob.imageStereoL[0] else: useStereoFlag = False elif (newJob.imageFileName.find("%V") >= 0) or (newJob.imageFileName.find("%v") >= 0): for vn in range(1, len(nViews)): newJob.maxChannels = newJob.maxChannels + 1 newJob.channelFileName.append( string.replace(string.replace(newJob.imageFileName, "%v", nViews[vn][0]), "%V", nViews[vn]) ) newJob.channelExtension.append("") newJob.imageFileName = string.replace(string.replace(newJob.imageFileName, "%v", nViews[0][0]), "%V", nViews[0]) newJob.layer = writeNodeName newJob.isActive = False jobList.append(newJob)
def __init__(self): """ """ rvmon = initRvMon() panel = RvRenderPanel() panel.setMinimumSize(450, 100) if not panel.showModalDialog(): return panel.saveToRoot() node = nuke.toNode(panel.outputNode.value()) if (not node): nuke.message("No such node as '%s'." % panel.outputNode.value()) return if node.Class() == "Viewer": node = node.input(int(nuke.knob(node.name() + ".input_number"))) """ self.views = panel.views.value().split() self.output = panel.output.value() self.proxy = panel.proxy.value() """ dateStr = rvmon.prepForRender(node, "current") start = panel.firstFrame.value() end = panel.lastFrame.value() log(" start %d end %d" % (start, end)) """ log (" has_key %s" % str(node.knobs().has_key("use_limit"))) log (" firstFrame %d lastFrame %d" % (node.firstFrame(), node.lastFrame())) if ((not node.knobs().has_key("use_limit")) or node["use_limit"].value()) : start = max (start, node.firstFrame()) end = min (end, node.lastFrame()) log (" start %d end %d" % (start, end)) """ incr = 1 audioFile = "" audioOffset = 0.0 checkpointFrame = int((start + end) / 2) rvmon.initializeRvSide() if (nuke.views() == ['left', 'right']): stereo = "stereo" else: stereo = "mono" rvmon.queueCommand( "self.initRenderRun('%s', %d, %d, %d, \"%s\", %g, %d, '%s', '%s', '%s', '%s')" % (node.name(), start, end, incr, audioFile, audioOffset, checkpointFrame, encodeNL( node["label"].value()), dateStr, "current", stereo))
def createScene(cameraTracker): """Create a Scene with a Camera and PointCloud for the camera solve.""" scene = nuke.createNode('Scene', '', False) camera = nuke.createNode('Camera', '', False) pointCloud = nuke.createNode('CameraTrackerPointCloud', '', False) sw = scene.screenWidth() sh = scene.screenHeight() x = cameraTracker.xpos() y = cameraTracker.ypos() w = cameraTracker.screenWidth() h = cameraTracker.screenHeight() m = int(x + w / 2) camera.setXYpos(m + w, y + w + int((h - sh) / 2)) pointCloud.setXYpos(m - int(pointCloud.screenWidth() / 2), y + w) scene.setXYpos(m - int(sw / 2), y + w * 2 - int((sh - h) / 2)) camera.setInput(0, None) pointCloud.setInput(0, cameraTracker) scene.setInput(0, camera) scene.setInput(1, pointCloud) numviews = len(nuke.views()) link = False linkKnob = cameraTracker.knob("linkOutput") if linkKnob: link = bool(linkKnob.getValue()) if link: camera.knob("focal").setExpression(cameraTracker.name() + ".focalLength") camera.knob("haperture").setExpression(cameraTracker.name() + ".aperture.x") camera.knob("vaperture").setExpression(cameraTracker.name() + ".aperture.y") camera.knob("translate").setExpression(cameraTracker.name() + ".camTranslate") camera.knob("rotate").setExpression(cameraTracker.name() + ".camRotate") camera.knob("win_translate").setExpression(cameraTracker.name() + ".windowTranslate") camera.knob("win_scale").setExpression(cameraTracker.name() + ".windowScale") else: camera.knob("focal").fromScript( cameraTracker.knob("focalLength").toScript(False)) camera.knob("translate").fromScript( cameraTracker.knob("camTranslate").toScript(False)) camera.knob("rotate").fromScript( cameraTracker.knob("camRotate").toScript(False)) camera.knob("win_translate").fromScript( cameraTracker.knob("windowTranslate").toScript(False)) camera.knob("win_scale").fromScript( cameraTracker.knob("windowScale").toScript(False)) for i in xrange(numviews): camera.knob("haperture").setValue( cameraTracker.knob("aperture").getValue(0, i + 1), 0, 0, i + 1) camera.knob("vaperture").setValue( cameraTracker.knob("aperture").getValue(1, i + 1), 0, 0, i + 1) return [scene, camera, pointCloud]
def __init__( self): """ """ rvmon = initRvMon() panel = RvRenderPanel() panel.setMinimumSize (450, 100) if not panel.showModalDialog(): return panel.saveToRoot() node = nuke.toNode(panel.outputNode.value()) if (not node) : nuke.message ("No such node as '%s'." % panel.outputNode.value()) return; if node.Class() == "Viewer": node = node.input (int(nuke.knob (node.name() + ".input_number"))) """ self.views = panel.views.value().split() self.output = panel.output.value() self.proxy = panel.proxy.value() """ dateStr = rvmon.prepForRender (node, "current") start = panel.firstFrame.value() end = panel.lastFrame.value() log (" start %d end %d" % (start, end)) """ log (" has_key %s" % str(node.knobs().has_key("use_limit"))) log (" firstFrame %d lastFrame %d" % (node.firstFrame(), node.lastFrame())) if ((not node.knobs().has_key("use_limit")) or node["use_limit"].value()) : start = max (start, node.firstFrame()) end = min (end, node.lastFrame()) log (" start %d end %d" % (start, end)) """ incr = 1 audioFile = "" audioOffset = 0.0 checkpointFrame = int((start + end) / 2) rvmon.initializeRvSide() if (nuke.views() == ['left', 'right']) : stereo = "stereo" else : stereo = "mono" rvmon.queueCommand("self.initRenderRun('%s', %d, %d, %d, \"%s\", %g, %d, '%s', '%s', '%s', '%s')" % ( node.name(), start, end, incr, audioFile, audioOffset, checkpointFrame, encodeNL(node["label"].value()), dateStr, "current", stereo))
def _render(self, group_node, mov_path, png_path): """ Renders quickdaily node """ # setup quicktime output resolution width = self.get_setting("width", 1024) height = self.get_setting("height", 540) mov_reformat_node = group_node.node("mov_reformat") mov_reformat_node["box_width"].setValue(width) mov_reformat_node["box_height"].setValue(height) # setup output png path png_out = group_node.node("png_writer") png_path = png_path.replace(os.sep, "/") png_out["file"].setValue(png_path) # setup output quicktime path mov_out = group_node.node("mov_writer") mov_path = mov_path.replace(os.sep, "/") mov_out["file"].setValue(mov_path) # on the mac and windows, we use the quicktime codec # on linux, use ffmpeg if sys.platform == "win32" or sys.platform == "darwin": # apple photo-jpeg movie mov_out["file_type"].setValue('mov') mov_out["codec"].setValue('jpeg') mov_out["fps"].setValue(23.97599983) mov_out["settings"].setValue( "000000000000000000000000000019a7365616e0000000100000001000000000000018676696465000000010000000e00000000000000227370746c0000000100000000000000006a706567000000000018000003ff000000207470726c000000010000000000000000000000000017f9db00000000000000246472617400000001000000000000000000000000000000530000010000000100000000156d70736f00000001000000000000000000000000186d66726100000001000000000000000000000000000000187073667200000001000000000000000000000000000000156266726100000001000000000000000000000000166d70657300000001000000000000000000000000002868617264000000010000000000000000000000000000000000000000000000000000000000000016656e647300000001000000000000000000000000001663666c67000000010000000000000000004400000018636d66720000000100000000000000006170706c00000014636c75740000000100000000000000000000001c766572730000000100000000000000000003001c00010000" ) elif sys.platform == "linux2": mov_out["file_type"].setValue("ffmpeg") mov_out["codec"].setValue("MOV format (mov)") # turn on the nodes mov_out.knob('disable').setValue(False) png_out.knob('disable').setValue(False) # finally render everything! # default to using the first view on stereo try: first_view = nuke.views()[0] nuke.executeMultiple( [mov_out, png_out], ([self._get_first_frame() - 1, self._get_last_frame(), 1], ), [first_view]) finally: # turn off the nodes again mov_out.knob('disable').setValue(True) png_out.knob('disable').setValue(True)
def _render(self, group_node, mov_path, png_path): """ Renders quickdaily node """ # setup quicktime output resolution width = self.get_setting("width", 1024) height = self.get_setting("height", 540) mov_reformat_node = group_node.node("mov_reformat") mov_reformat_node["box_width"].setValue(width) mov_reformat_node["box_height"].setValue(height) # setup output png path png_out = group_node.node("png_writer") png_path = png_path.replace(os.sep, "/") png_out["file"].setValue(png_path) # setup output quicktime path mov_out = group_node.node("mov_writer") mov_path = mov_path.replace(os.sep, "/") mov_out["file"].setValue(mov_path) # on the mac and windows, we use the quicktime codec # on linux, use ffmpeg if sys.platform == "win32" or sys.platform == "darwin": # apple photo-jpeg movie mov_out["file_type"].setValue('mov') mov_out["codec"].setValue('jpeg') mov_out["fps"].setValue(23.97599983) mov_out["settings"].setValue("000000000000000000000000000019a7365616e0000000100000001000000000000018676696465000000010000000e00000000000000227370746c0000000100000000000000006a706567000000000018000003ff000000207470726c000000010000000000000000000000000017f9db00000000000000246472617400000001000000000000000000000000000000530000010000000100000000156d70736f00000001000000000000000000000000186d66726100000001000000000000000000000000000000187073667200000001000000000000000000000000000000156266726100000001000000000000000000000000166d70657300000001000000000000000000000000002868617264000000010000000000000000000000000000000000000000000000000000000000000016656e647300000001000000000000000000000000001663666c67000000010000000000000000004400000018636d66720000000100000000000000006170706c00000014636c75740000000100000000000000000000001c766572730000000100000000000000000003001c00010000") elif sys.platform == "linux2": mov_out["file_type"].setValue("ffmpeg") mov_out["format"].setValue("MOV format (mov)") # turn on the nodes mov_out.knob('disable').setValue(False) png_out.knob('disable').setValue(False) # finally render everything! # default to using the first view on stereo try: first_view = nuke.views()[0] nuke.executeMultiple( [mov_out, png_out], ([ self._get_first_frame()-1, self._get_last_frame(), 1 ],), [first_view] ) finally: # turn off the nodes again mov_out.knob('disable').setValue(True) png_out.knob('disable').setValue(True)
def render(frameList): _maxCache = str(max(nuke.memory("max_usage") / 1097152, 16) * 4) + "M" try: t = nuke.executeBackgroundNuke( nuke.EXE_PATH, [renderNode], nuke.FrameRanges(frameList), nuke.views(), {"maxThreads": 1, "maxCache": _maxCache}, ) THREAD_FRAMES[t] = frameList except Exception as e: print e
def _render(self, mov_path, start_frame, end_frame): """ Renders write node :param mov_path: temporary path where quicktime should be written :param int start_frame: First frame to render :param int end_frame: Last frame to render """ import nuke # setup quicktime output resolution (width, height) = self._bundle.execute_hook_method( "settings_hook", "get_resolution", base_class=self._bundle.base_hooks.ReviewSettings ) mov_reformat_node = self._group_node.node("mov_reformat") mov_reformat_node["box_width"].setValue(width) mov_reformat_node["box_height"].setValue(height) # setup output quicktime path mov_out = self._group_node.node("mov_writer") mov_path = mov_path.replace(os.sep, "/") mov_out["file"].setValue(mov_path) # apply the Write node codec settings we'll use for generating the Quicktime self._bundle.execute_hook_method( "settings_hook", "setup_quicktime_node", write_node=mov_out, base_class=self._bundle.base_hooks.ReviewSettings ) # turn on the node mov_out.knob("disable").setValue(False) # render everything - default to using the first view on stereo logger.debug("Rendering quicktime") try: first_view = nuke.views()[0] nuke.executeMultiple( [mov_out], ([start_frame - 1, end_frame, 1],), [first_view] ) finally: # turn off the nodes again mov_out.knob("disable").setValue(True)
def topInputNode(node, ch_class, input=0): if node: input_node = node.input(input) if input_node: if nodeClass(input_node) == ch_class: return input_node else: if nodeClass(input_node) == 'JoinViews': # print nuke.views() # print nuke.thisView() current_view = nuke.views().index(nuke.thisView()) return topInputNode(input_node, current_view, ch_class) else: return topInputNode(input_node, ch_class) else: return None
def getOffset(verbose=False): numViews=len(nuke.views()) #sn=nuke.selectedNodes() #s=len(sn) firstKeyFound=0 offset=0 keysList=[] nuke.root().begin() for node in nuke.allNodes(): if node.Class() not in exclusionList: nodeAnimated=isNodeAnimated(node) print node['name'].value(), nodeAnimated if nodeAnimated : #loop through and find largest offset for knob in node.knobs().values(): if knob.isAnimated(): try: aSize = knob.arraySize() for index in range(aSize): for vues in range(numViews+1): anim = knob.animation(index,vues) numKeys=anim.size() if numKeys: for i in range(numKeys): keySelected= (anim.keys()[i].selected) if keySelected: firstKeyFound+=1 keyVals= (anim.keys()[i].x, anim.keys()[i].y) if firstKeyFound==1: offset=nuke.frame()-keyVals[0] else: foundKey=nuke.frame()-keyVals[0] if foundKey>offset: offset=foundKey if verbose: print (foundKey,offset) except: continue else: print ('Skipped Node ' + str(node['name'].value())) if verbose: print (' : FirstKeyFound is '+ str(firstKeyFound) + ' : offset is' + str(offset)) return (offset)
def rrSubmit_CreateSingleJobs_shotgun(jobList, noLocalSceneCopy): import sgtk eng = sgtk.platform.current_engine() app = eng.apps["tk-nuke-writenode"] nList = app.get_write_nodes() nViews = nuke.views() for nod in nList: if nod["disable"].value(): continue newJob = rrJob() rrSubmit_fillGlobalSceneInfo(newJob) useStereoFlag = False if len(nViews) == 2: useStereoFlag = True newJob.imageStereoR = nViews[0] newJob.imageStereoL = nViews[1] newJob.imageFileName = app.get_node_render_path(nod) if (newJob.imageFileName == None) or (len(newJob.imageFileName) < 3): continue if newJob.seqStart == newJob.seqEnd and (newJob.imageFileName.find("#") < 0): newJob.imageSingleOutput = True if useStereoFlag: if newJob.imageFileName.find("%V") >= 0: newJob.imageFileName = string.replace(newJob.imageFileName, "%V", "<Stereo>") elif newJob.imageFileName.find("%v") >= 0: newJob.imageFileName = string.replace(newJob.imageFileName, "%v", "<Stereo>") newJob.imageStereoR = newJob.imageStereoR[0] newJob.imageStereoL = newJob.imageStereoL[0] else: useStereoFlag = False elif (newJob.imageFileName.find("%V") >= 0) or (newJob.imageFileName.find("%v") >= 0): for vn in range(1, len(nViews)): newJob.maxChannels = newJob.maxChannels + 1 newJob.channelFileName.append( string.replace(string.replace(newJob.imageFileName, "%v", nViews[vn][0]), "%V", nViews[vn]) ) newJob.channelExtension.append("") newJob.imageFileName = string.replace( string.replace(newJob.imageFileName, "%v", nViews[0][0]), "%V", nViews[0] ) newJob.layer = app.get_node_name(nod) newJob.renderer = "shotgun" newJob.isActive = False jobList.append(newJob)
def _render(self, group_node, mov_path, png_path): """ Renders quickdaily node """ # setup quicktime output resolution # width = self.get_setting("width", 1024) # height = self.get_setting("height", 540) # mov_reformat_node = group_node.node("mov_reformat") # mov_reformat_node["box_width"].setValue(width) # mov_reformat_node["box_height"].setValue(height) # setup output png path png_out = group_node.node("png_writer") png_path = png_path.replace(os.sep, "/") png_out["file"].setValue(png_path) # setup output quicktime path mov_out = group_node.node("mov_writer") mov_path = mov_path.replace(os.sep, "/") mov_out["file"].setValue(mov_path) # MDS - Disabled codec settings. Defined in Gizmo now instead # apply the Write node codec settings we'll use for generating the Quicktime # self.execute_hook_method("codec_settings_hook", # "get_quicktime_settings", # write_node=mov_out) # turn on the nodes mov_out.knob('disable').setValue(False) png_out.knob('disable').setValue(False) # finally render everything! # default to using the first view on stereo try: first_view = nuke.views()[0] nuke.executeMultiple( [mov_out, png_out], ([self._get_first_frame(), self._get_last_frame(), 1], ), [first_view]) finally: # turn off the nodes again mov_out.knob('disable').setValue(True) png_out.knob('disable').setValue(True)
def topInputKnob(node, ch_class, knob, input=0): if node: input_node = node.input(input) if input_node: if nodeClass(input_node) == ch_class: if input_node.knob(knob): return input_node[knob] else: if nodeClass(input_node) == 'JoinViews': # print nuke.views() # print nuke.thisView() current_view = nuke.views().index(nuke.thisView()) return topInputKnob(input_node, current_view, ch_class, knob) else: return topInputKnob(input_node, ch_class, knob) else: return None
def topInput(node, input, ch_class, knob, ch_frame): if node: input_node = node.input(input) if input_node: if input_node.Class() == ch_class: if input_node.knob(knob): return input_node[knob].getValueAt(ch_frame) else: if input_node.Class() == 'JoinViews': # print nuke.views() # print nuke.thisView() current_view = nuke.views().index(nuke.thisView()) return topInput(input_node, current_view, ch_class, knob, ch_frame) else: return topInput(input_node, 0, ch_class, knob, ch_frame) else: return None
def _render(self, group_node, mov_path, png_path): """ Renders quickdaily node """ # setup quicktime output resolution width = self.get_setting("width", 1024) height = self.get_setting("height", 540) mov_reformat_node = group_node.node("mov_reformat") mov_reformat_node["box_width"].setValue(width) mov_reformat_node["box_height"].setValue(height) # setup output png path png_out = group_node.node("png_writer") png_path = png_path.replace(os.sep, "/") png_out["file"].setValue(png_path) # setup output quicktime path mov_out = group_node.node("mov_writer") mov_path = mov_path.replace(os.sep, "/") mov_out["file"].setValue(mov_path) # apply the Write node codec settings we'll use for generating the Quicktime self.execute_hook_method("codec_settings_hook", "get_quicktime_settings", write_node=mov_out) # turn on the nodes mov_out.knob('disable').setValue(False) png_out.knob('disable').setValue(False) # finally render everything! # default to using the first view on stereo try: first_view = nuke.views()[0] nuke.executeMultiple( [mov_out, png_out], ([ self._get_first_frame()-1, self._get_last_frame(), 1 ],), [first_view] ) finally: # turn off the nodes again mov_out.knob('disable').setValue(True) png_out.knob('disable').setValue(True)
def createCheckpoint(): nodes = nuke.selectedNodes() if (len(nodes) != 1): nuke.message("Please select a node to checkpoint.") return node = nodes[0] if (type(node).__name__ != "Node" and type(node).__name__ != "Viewer"): nuke.message( "Node '%s' is not renderable, pleases select a node that can be rendered." % node.name()) return if (node.Class() == "Read" or node.Class() == "Write"): nuke.message( "There's no need to checkpoint Read or Write nodes, since they can be viewed directly in RV." ) return log("createCheckpoint %s" % node.name()) rvmon = initRvMon() rvmon.initializeRvSide() if node.Class() == "Viewer": node = node.input(int(nuke.knob(node.name() + ".input_number"))) dateStr = rvmon.prepForRender(node, "checkpoint") f = nuke.frame() if (nuke.views() == ['left', 'right']): stereo = "stereo" else: stereo = "mono" rvmon.queueCommand( "self.initRenderRun('%s', %d, %d, %d, \"%s\", %g, %d, '%s', '%s', '%s', '%s')" % (node.name(), f, f, 1, "", 0.0, f, encodeNL( node["label"].value()), dateStr, "checkpoint", stereo)) """
def changeViews(self, nodes, views): for n in nodes: print n.name() k = n['curves'] shapes = self.getShapes(k.rootLayer) for s in shapes: attrs = s.getAttributes() # reset the number of views attribute if 'nv' in attrs: attrs.remove('nv') attrs.add('nv', len(views)) # delete any previous view attributes count = 1 while ('view%s' % count) in attrs: attrs.remove('view%s' % count) count += 1 # handle no selected views if views == ['']: attrs.add('view1', 0.0) # handle any other number of views else: count = 1 for view in views: index = float(nuke.views().index(view) + 1) attrs.add('view%s' % count, index) count += 1 k.changed()
def createCamera(solver): """Create a camera node based on the projection calculated by the solver.""" x = solver.xpos() y = solver.ypos() w = solver.screenWidth() h = solver.screenHeight() m = int(x + w / 2) numviews = len(nuke.views()) link = False linkKnob = solver.knob("linkOutput") if linkKnob: link = bool(linkKnob.getValue()) camera = nuke.createNode('Camera', '', False) camera.setInput(0, None) camera.setXYpos(m - int(camera.screenWidth() / 2), y + w) if link: camera.knob("focal").setExpression(solver.name() + ".focalLength") camera.knob("haperture").setExpression(solver.name() + ".aperture.x") camera.knob("vaperture").setExpression(solver.name() + ".aperture.y") camera.knob("translate").setExpression(solver.name() + ".camTranslate") camera.knob("rotate").setExpression(solver.name() + ".camRotate") camera.knob("win_translate").setExpression(solver.name() + ".windowTranslate") camera.knob("win_scale").setExpression(solver.name() + ".windowScale") else: camera.knob("focal").fromScript( solver.knob("focalLength").toScript(False)) camera.knob("translate").fromScript( solver.knob("camTranslate").toScript(False)) camera.knob("rotate").fromScript( solver.knob("camRotate").toScript(False)) camera.knob("win_translate").fromScript( solver.knob("windowTranslate").toScript(False)) camera.knob("win_scale").fromScript( solver.knob("windowScale").toScript(False)) for i in xrange(numviews): camera.knob("haperture").setValue( solver.knob("aperture").getValue(0, i + 1), 0, 0, i + 1) camera.knob("vaperture").setValue( solver.knob("aperture").getValue(1, i + 1), 0, 0, i + 1)
def rrSubmit_CreateSingleJobs(jobList): nList = nuke.allNodes('Write') + nuke.allNodes('DeepWrite') nViews=nuke.views() for writeNode in nList: if (writeNode['disable'].value()): continue newJob= rrJob() rrSubmit_fillGlobalSceneInfo(newJob) useStereoFlag=False if (len(nViews)==2): useStereoFlag=True newJob.imageStereoR=nViews[0] newJob.imageStereoL=nViews[1] if (writeNode['use_limit'].value()): newJob.seqStart = writeNode['first'].value() newJob.seqEnd = writeNode['last'].value() newJob.imageFileName= nuke.filename(writeNode) if ((newJob.imageFileName== None) or (len(newJob.imageFileName)<3)): continue if (newJob.seqStart==newJob.seqEnd and (newJob.imageFileName.find("#")<0)): newJob.imageSingleOutput = True if (useStereoFlag): if (newJob.imageFileName.find("%V")>=0): newJob.imageFileName = string.replace(newJob.imageFileName,"%V","<Stereo>") elif (newJob.imageFileName.find("%v")>=0): newJob.imageFileName = string.replace(newJob.imageFileName,"%v","<Stereo>") newJob.imageStereoR=newJob.imageStereoR[0] newJob.imageStereoL=newJob.imageStereoL[0] else: useStereoFlag=False elif ( (newJob.imageFileName.find("%V")>=0) or (newJob.imageFileName.find("%v")>=0)): for vn in range(1, len(nViews)): newJob.maxChannels= newJob.maxChannels + 1 newJob.channelFileName.append(string.replace(string.replace(newJob.imageFileName,"%v",nViews[vn][0]),"%V",nViews[vn])) newJob.channelExtension.append("") newJob.imageFileName = string.replace(string.replace(newJob.imageFileName,"%v",nViews[0][0]),"%V",nViews[0]) newJob.layer= writeNode['name'].value() newJob.isActive = False jobList.append(newJob)
def paste_stereo_nodeset(nodeset_path, additional_views=[]): """ Pastes the nodeset from the given nodeset_path. If the current nuke script doesn't have stereo views, they will be set up. :param nodeset_path: :return: """ if nuke.views() == ['main']: # only one view (main) exists -> setup for stereo user_choice = nuke.ask( "This Toolset only works properly in a stereo environment." "\n Allow Nuke to set up a left and right view?") if (user_choice == True): nuke.root()['setlr'].execute() # adds all other views (for gizmos that need additional views for calculation) for view in additional_views: nuke.addView(view) node = nuke.nodePaste( nodeset_path) # Nodeset will be created regardless of user choice. return node
def createCheckpoint () : nodes = nuke.selectedNodes() if (len(nodes) != 1) : nuke.message ("Please select a node to checkpoint.") return node = nodes[0] if (type(node).__name__ != "Node" and type(node).__name__ != "Viewer") : nuke.message ("Node '%s' is not renderable, pleases select a node that can be rendered." % node.name()) return if (node.Class() == "Read" or node.Class() == "Write") : nuke.message ("There's no need to checkpoint Read or Write nodes, since they can be viewed directly in RV.") return log ("createCheckpoint %s" % node.name()) rvmon = initRvMon() rvmon.initializeRvSide() if node.Class() == "Viewer": node = node.input (int (nuke.knob (node.name() + ".input_number"))) dateStr = rvmon.prepForRender (node, "checkpoint") f = nuke.frame() if (nuke.views() == ['left', 'right']) : stereo = "stereo" else : stereo = "mono" rvmon.queueCommand("self.initRenderRun('%s', %d, %d, %d, \"%s\", %g, %d, '%s', '%s', '%s', '%s')" % ( node.name(), f, f, 1, "", 0.0, f, encodeNL (node["label"].value()), dateStr, "checkpoint", stereo)) """
def get_params(self): """Returns a dictionary of the job parameters from the submit render gui.""" params = dict() params['plugin_version'] = __version__ params['num_instances'] = self.num_slots.value() for inst_type in self.zync_conn.INSTANCE_TYPES: if self.instance_type.value().startswith(inst_type): params['instance_type'] = inst_type # these fields can't both be blank, we check in submit() before # reaching this point params['proj_name'] = self.existing_project.value().strip() if params['proj_name'] == '': params['proj_name'] = self.new_project.value().strip() params['frange'] = self.frange.value() params['step'] = self.fstep.value() params['chunk_size'] = self.chunk_size.value() params['upload_only'] = int(self.upload_only.value()) params['priority'] = int(self.priority.value()) parent = self.parent_id.value() if parent != None and parent != '': params['parent_id'] = int(self.parent_id.value()) params['start_new_instances'] = '1' params['skip_check'] = '1' if self.skip_check.value() else '0' params['notify_complete'] = '0' params['scene_info'] = { 'nuke_version': nuke.NUKE_VERSION_STRING, 'views': nuke.views() } caravr_version = ZyncRenderPanel._get_caravr_version() if caravr_version: params['scene_info']['caravr_version'] = caravr_version return params
def render_movie_in_nuke(self, path, output_path, width, height, first_frame, last_frame, version, name, color_space): """ Use Nuke to render a movie. This assumes we're running _inside_ Nuke. :param path: Path to the input frames for the movie :param output_path: Path to the output movie that will be rendered :param width: Width of the output movie :param height: Height of the output movie :param first_frame: Start frame for the output movie :param last_frame: End frame for the output movie :param version: Version number to use for the output movie slate and burn-in :param name: Name to use in the slate for the output movie :param color_space: Colorspace of the input frames """ output_node = None ctx = self.__app.context # create group where everything happens group = nuke.nodes.Group() # now operate inside this group group.begin() try: # create read node read = nuke.nodes.Read(name="source", file=path.replace(os.sep, "/")) read["on_error"].setValue("black") read["first"].setValue(first_frame) read["last"].setValue(last_frame) if color_space: read["colorspace"].setValue(color_space) # now create the slate/burnin node burn = nuke.nodePaste(self._burnin_nk) burn.setInput(0, read) # set the fonts for all text fields burn.node("top_left_text")["font"].setValue(self._font) burn.node("top_right_text")["font"].setValue(self._font) burn.node("bottom_left_text")["font"].setValue(self._font) burn.node("framecounter")["font"].setValue(self._font) burn.node("slate_info")["font"].setValue(self._font) # add the logo burn.node("logo")["file"].setValue(self._logo) # format the burnins version_padding_format = "%%0%dd" % self.__app.get_setting("version_number_padding") version_str = version_padding_format % version if ctx.task: version_label = "%s, v%s" % (ctx.task["name"], version_str) elif ctx.step: version_label = "%s, v%s" % (ctx.step["name"], version_str) else: version_label = "v%s" % version_str burn.node("top_left_text")["message"].setValue(ctx.project["name"]) burn.node("top_right_text")["message"].setValue(ctx.entity["name"]) burn.node("bottom_left_text")["message"].setValue(version_label) # and the slate slate_str = "Project: %s\n" % ctx.project["name"] slate_str += "%s: %s\n" % (ctx.entity["type"], ctx.entity["name"]) slate_str += "Name: %s\n" % name.capitalize() slate_str += "Version: %s\n" % version_str if ctx.task: slate_str += "Task: %s\n" % ctx.task["name"] elif ctx.step: slate_str += "Step: %s\n" % ctx.step["name"] slate_str += "Frames: %s - %s\n" % (first_frame, last_frame) burn.node("slate_info")["message"].setValue(slate_str) # create a scale node scale = self.__create_scale_node(width, height) scale.setInput(0, burn) # Create the output node output_node = self.__create_output_node(output_path) output_node.setInput(0, scale) finally: group.end() if output_node: # Make sure the output folder exists output_folder = os.path.dirname(output_path) self.__app.ensure_folder_exists(output_folder) # Render the outputs, first view only nuke.executeMultiple([output_node], ([first_frame-1, last_frame, 1],), [nuke.views()[0]]) # Cleanup after ourselves nuke.delete(group)
def _render(self, mov_path, start_frame, end_frame): """ Renders write node :param mov_path: temporary path where quicktime should be written :param int start_frame: First frame to render :param int end_frame: Last frame to render """ import nuke # setup quicktime output resolution (width, height) = self._bundle.execute_hook_method( "settings_hook", "get_resolution", base_class=self._bundle.base_hooks.ReviewSettings, ) #mov_reformat_node = self._group_node.node("mov_reformat") #mov_reformat_node["box_width"].setValue(width) #mov_reformat_node["box_height"].setValue(height) # setup output quicktime path mov_out = self._group_node.node("mov_writer") mov_path = mov_path.replace(os.sep, "/") mov_out["file"].setValue(mov_path) # setting output colorspace colorspace = nuke.root().knob('colorManagement').getValue() # If OCIO is set, output - sRGB if colorspace: mov_out.knob('colorspace').setValue('Output - sRGB') # If no OCIO is set, detect if ACES is used or nuke_default else: ocio_config = nuke.root().knob('OCIO_config').getValue() if ocio_config == 2.0: mov_out.knob('colorspace').setValue('sRGB') else: mov_out.knob('colorspace').setValue('Output - sRGB') # apply the Write node codec settings we'll use for generating the Quicktime self._bundle.execute_hook_method( "settings_hook", "setup_quicktime_node", write_node=mov_out, base_class=self._bundle.base_hooks.ReviewSettings, ) # turn on the node mov_out.knob("disable").setValue(False) # render everything - default to using the first view on stereo logger.debug("Rendering quicktime") try: first_view = nuke.views()[0] nuke.executeMultiple([mov_out], ([start_frame - 1, end_frame, 1], ), [first_view]) finally: # turn off the nodes again mov_out.knob("disable").setValue(True)
def _render_movie_in_nuke(self, fields, path, output_path, width, height, first_frame, last_frame): """ Use Nuke to render a movie. This assumes we're running _inside_ Nuke. """ output_node = None # create group where everything happens group = nuke.nodes.Group() # now operate inside this group group.begin() try: # create read node read = nuke.nodes.Read(name="source", file=path) read["on_error"].setValue("black") read["first"].setValue(first_frame) read["last"].setValue(last_frame) # now create the slate/burnin node burn = nuke.nodePaste(self._burnin_nk) burn.setInput(0, read) # set the fonts for all text fields burn.node("top_left_text")["font"].setValue(self._font) burn.node("top_right_text")["font"].setValue(self._font) burn.node("bottom_left_text")["font"].setValue(self._font) burn.node("framecounter")["font"].setValue(self._font) burn.node("slate_info")["font"].setValue(self._font) # add the logo burn.node("logo")["file"].setValue(self._logo) # format the burnins version_padding_format = "%%0%dd" % self.get_setting("version_number_padding") version_str = version_padding_format % fields.get("version", 0) if self.context.task: version = "%s, v%s" % (self.context.task["name"], version_str) elif self.context.step: version = "%s, v%s" % (self.context.step["name"], version_str) else: version = "v%s" % version_str burn.node("top_left_text")["message"].setValue(self.context.project["name"]) burn.node("top_right_text")["message"].setValue(self.context.entity["name"]) burn.node("bottom_left_text")["message"].setValue(version) # and the slate slate_str = "Project: %s\n" % self.context.project["name"] slate_str += "%s: %s\n" % (self.context.entity["type"], self.context.entity["name"]) slate_str += "Name: %s\n" % fields.get("name", "Unnamed").capitalize() slate_str += "Version: %s\n" % version_str if self.context.task: slate_str += "Task: %s\n" % self.context.task["name"] elif self.context.step: slate_str += "Step: %s\n" % self.context.step["name"] slate_str += "Frames: %s - %s\n" % (first_frame, last_frame) burn.node("slate_info")["message"].setValue(slate_str) # create a scale node scale = self._create_scale_node(width, height) scale.setInput(0, burn) # Create the output node output_node = self._create_output_node(output_path) output_node.setInput(0, scale) finally: group.end() if output_node: # Make sure the output folder exists output_folder = os.path.dirname(output_path) self.ensure_folder_exists(output_folder) # Render the outputs, first view only nuke.executeMultiple([output_node], ([first_frame - 1, last_frame, 1],), [nuke.views()[0]]) # Cleanup after ourselves nuke.delete(group)
fileknob = writenode["proxy"] else: fileknob = writenode["file"] # Get views and images folders: imagesdirs = [] filenames = [] views_str = None views = [] views_num = 0 try: views_str = writenode["views"].value() print('Views = "%s"' % views_str) for view in views_str.split(" "): view = view.strip() if view != "": if not view in nuke.views(): print('Warning: Skipping invalid view: "%s"' % view) print(parser.str_warning) continue views_num += 1 views.append(view) octx = nuke.OutputContext() octx.setView(1 + nuke.views().index(view)) filename = fileknob.getEvaluatedValue(octx) imagesdirs.append(os.path.dirname(filename)) filenames.append(filename) except: errorExit('Can`t process views on "%s" write node:\n' % xnode + str(sys.exc_info()[1]), True) # Check for valid view founded: if views_num < 1: errorExit('Can`t find valid views on "%s" write node.' % xnode, True)
def render( self, input_path, output_path, width, height, first_frame, last_frame, version, name, color_space, ): """ Use Nuke to render a movie. :param str input_path: Path to the input frames for the movie :param str output_path: Path to the output movie that will be rendered :param int width: Width of the output movie :param int height: Height of the output movie :param int first_frame: The first frame of the sequence of frames. :param int last_frame: The last frame of the sequence of frames. :param str version: Version number to use for the output movie slate and burn-in :param str name: Name to use in the slate for the output movie :param str color_space: Colorspace of the input frames :returns: Location of the rendered media :rtype: str """ output_node = None ctx = self.__app.context # create group where everything happens group = nuke.nodes.Group() # now operate inside this group group.begin() try: # create read node read = nuke.nodes.Read(name="source", file=input_path.replace(os.sep, "/")) read["on_error"].setValue("black") read["first"].setValue(first_frame) read["last"].setValue(last_frame) if color_space: read["colorspace"].setValue(color_space) # now create the slate/burnin node burn = nuke.nodePaste(self._burnin_nk) burn.setInput(0, read) # set the fonts for all text fields burn.node("top_left_text")["font"].setValue(self._font) burn.node("top_right_text")["font"].setValue(self._font) burn.node("bottom_left_text")["font"].setValue(self._font) burn.node("framecounter")["font"].setValue(self._font) burn.node("slate_info")["font"].setValue(self._font) # add the logo burn.node("logo")["file"].setValue(self._logo) # format the burnins version_padding_format = "%%0%dd" % self.__app.get_setting( "version_number_padding" ) version_str = version_padding_format % version if ctx.task: version_label = "%s, v%s" % (ctx.task["name"], version_str) elif ctx.step: version_label = "%s, v%s" % (ctx.step["name"], version_str) else: version_label = "v%s" % version_str burn.node("top_left_text")["message"].setValue(ctx.project["name"]) burn.node("top_right_text")["message"].setValue(ctx.entity["name"]) burn.node("bottom_left_text")["message"].setValue(version_label) # and the slate slate_str = "Project: %s\n" % ctx.project["name"] slate_str += "%s: %s\n" % (ctx.entity["type"], ctx.entity["name"]) slate_str += "Name: %s\n" % name.capitalize() slate_str += "Version: %s\n" % version_str if ctx.task: slate_str += "Task: %s\n" % ctx.task["name"] elif ctx.step: slate_str += "Step: %s\n" % ctx.step["name"] slate_str += "Frames: %s - %s\n" % (first_frame, last_frame) burn.node("slate_info")["message"].setValue(slate_str) # create a scale node scale = self.__create_scale_node(width, height) scale.setInput(0, burn) # Create the output node output_node = self.__create_output_node(output_path) output_node.setInput(0, scale) finally: group.end() if output_node: # Make sure the output folder exists output_folder = os.path.dirname(output_path) self.__app.ensure_folder_exists(output_folder) # Render the outputs, first view only nuke.executeMultiple( [output_node], ([first_frame - 1, last_frame, 1],), [nuke.views()[0]] ) # Cleanup after ourselves nuke.delete(group) return output_path
def dailiesGenCmd(node): # Process Input Node: inputnode = None for i in range(node.inputs()): inputnode = node.input(i) if inputnode is None: nuke.message("Error:\n" "%s\n" "Not connected to Read or Write node." % node.name()) return if not inputnode.Class() in ["Read", "Write"]: nuke.message("Error:\n" "%s\n" "Connected not to Read or Write node." % node.name()) return # Process Images: images = "" root_frame_first = nuke.Root().firstFrame() root_frame_last = nuke.Root().lastFrame() if root_frame_first == root_frame_last: root_frame_last += 100 # Get needed views from dailies node if forced: if node.knob("forceviews").value(): views = node.knob("viewsnames").value().split(" ") else: # Get needed views write node: views_knob = inputnode.knob("views") if views_knob is not None: views = inputnode.knob("views").value().split(" ") else: # Get all scene views: views = nuke.views() # Generate input pattern from each view: for view in views: if not len(view): continue # skip empty view, may be after split(' ') if not view in nuke.views(): print('Error: Skipping invalid view: "%s"' % view) continue octx = nuke.OutputContext() octx.setView(1 + nuke.views().index(view)) octx.setFrame(root_frame_first) images1 = inputnode.knob("file").getEvaluatedValue(octx) if images1 is None or images1 == "": nuke.message( "Error:\n" "%s\n" "Files are empty.\n" 'View "%s", frame %d.' % (inputnode.name(), view, root_frame_first) ) return octx.setFrame(root_frame_last) images2 = inputnode.knob("file").getEvaluatedValue(octx) if images2 is None or images2 == "": nuke.message( "Error:\n" "%s\n" "Files are empty.\n" 'View "%s", frame %d.' % (inputnode.name(), view, root_frame_last) ) return part1, padding, part2 = afcommon.splitPathsDifference(images1, images2) if padding < 1: nuke.message("Error:\n" "%s\Invalid files pattern.\n" 'View "%s".' % (inputnode.name(), view)) return if len(images): images += " " images += "%s%s%s" % (part1, "#" * padding, part2) if images == "": nuke.message("Error:\n%s\No valid views found." % inputnode.name()) return # Get Movie Name: movname = node.knob("movname").value() if movname is None or movname == "": nuke.message("Error:\n%s\nMovie name is not set." % node.name()) return # Get Movie Folder: movfolder = node.knob("movfolder").getEvaluatedValue() if movfolder is None or movfolder == "": nuke.message("Error:\n%s\nMovie folder is not set." % node.name()) return # Get Parameters: format = node.knob("format").value() fps = node.knob("fps").value() codec = node.knob("codec").value() template = node.knob("template").getEvaluatedValue() slate = node.knob("slate").getEvaluatedValue() company = node.knob("company").value() project = node.knob("project").value() shot = node.knob("shot").value() version = node.knob("version").value() artist = node.knob("artist").value() activity = node.knob("activity").value() comments = node.knob("comments").value() cach_op = node.knob("cach_op").value() line_clr = node.knob("line_clr").value() draw169 = node.knob("draw169").value() draw235 = node.knob("draw235").value() line169 = node.knob("line169").value() line235 = node.knob("line235").value() lgspath = node.knob("lgspath").getEvaluatedValue() lgfpath = node.knob("lgfpath").getEvaluatedValue() lgsgrav = node.knob("lgsgrav").value() lgfgrav = node.knob("lgfgrav").value() lgssize = int(node.knob("lgssize").value()) lgfsize = int(node.knob("lgfsize").value()) fstart = int(node.knob("fstart").value()) fend = int(node.knob("fend").value()) fffirst = int(node.knob("fffirst").value()) faketime_on = int(node.knob("faketime_on").value()) faketime_str = node.knob("faketime_str").value() encodeonly = node.knob("encodeonly").value() tmpformat = node.knob("tmpformat").value() tmpquality = node.knob("tmpquality").value() autocolorspace = int(node.knob("autocolorspace").value()) asp_in = float(node.knob("asp_in").value()) gamma = float(node.knob("gamma").value()) cach_as = float(node.knob("cach_as").value()) line_as = float(node.knob("line_as").value()) # Command Construction: cmd = os.environ["CGRU_LOCATION"] cmd = os.path.join(cmd, "utilities") cmd = os.path.join(cmd, "moviemaker") cmd = os.path.join(cmd, "makemovie.py") cmd = "python " + cmd cmd += ' -f "%s"' % fps cmd += ' -c "%s"' % codec if faketime_on and faketime_str is not None and faketime_str != "": cmd += " --faketime %d" % int(time.mktime(time.strptime(faketime_str, TimeFromat))) if tmpformat is not None and tmpformat != "": cmd += ' --tmpformat "%s"' % tmpformat if tmpquality is not None and tmpquality != "": cmd += ' --tmpquality "%s"' % tmpquality if not autocolorspace: cmd += " --noautocorr" if gamma != 1.0: cmd += " -g %03f" % gamma if asp_in > 0.0: cmd += " --aspect_in %f" % asp_in if fstart != -1: cmd += " --fs %d" % fstart if fend != -1: cmd += " --fe %d" % fend if fffirst: cmd += " --fff" if not encodeonly: cmd += ' -r "%s"' % format if template is not None and template != "": cmd += ' -t "%s"' % template if slate is not None and slate != "": cmd += ' -s "%s"' % slate if company is not None and company != "": cmd += ' --company "%s"' % company if project is not None and project != "": cmd += ' --project "%s"' % project if shot is not None and shot != "": cmd += ' --shot "%s"' % shot if version is not None and version != "": cmd += ' --ver "%s"' % version if artist is not None and artist != "": cmd += ' --artist "%s"' % artist if activity is not None and activity != "": cmd += ' --activity "%s"' % activity if comments is not None and comments != "": cmd += ' --comments "%s"' % comments if draw169 is not None and draw169 != "": cmd += ' --draw169 "%s"' % draw169 if draw235 is not None and draw235 != "": cmd += ' --draw235 "%s"' % draw235 if line169 is not None and line169 != "": cmd += ' --line169 "%s"' % line169 if line235 is not None and line235 != "": cmd += ' --line235 "%s"' % line235 if line_clr is not None and line_clr != "": cmd += " --line_aspect %f" % line_as cmd += ' --line_color "%s"' % line_clr if cach_op is not None and cach_op != "": cmd += " --cacher_aspect %f" % cach_as cmd += ' --cacher_opacity "%s"' % cach_op if lgspath is not None and lgspath != "": cmd += ' --lgspath "%s"' % lgspath cmd += " --lgssize %d" % lgssize cmd += " --lgsgrav %s" % lgsgrav if lgfpath is not None and lgfpath != "": cmd += ' --lgfpath "%s"' % lgfpath cmd += " --lgfsize %d" % lgfsize cmd += " --lgfgrav %s" % lgfgrav if node.knob("stereodub").value(): cmd += " --stereo" cmd += " " + images cmd += " " + os.path.join(os.path.abspath(movfolder), movname) return cmd
def rrSubmit_CreateAllJob(jobList,noLocalSceneCopy): newJob= rrJob() rrSubmit_fillGlobalSceneInfo(newJob) nList = nuke.allNodes('Write') + nuke.allNodes('DeepWrite') mainNode = True nViews=nuke.views() useStereoFlag=False if (len(nViews)==2): useStereoFlag=True newJob.imageStereoR=nViews[0] newJob.imageStereoL=nViews[1] for writeNode in nList: if (writeNode['disable'].value()): continue pathScripted=writeNode['file'].value() if ((pathScripted== None) or (len(pathScripted)<3)): continue if ( (pathScripted.lower().find("root.name")>=0) or (pathScripted.lower().find("root().name")>=0) ): noLocalSceneCopy[0]=True if (mainNode): if (writeNode['use_limit'].value()): newJob.seqStart = writeNode['first'].value() newJob.seqEnd = writeNode['last'].value() newJob.imageFileName= nuke.filename(writeNode) if (newJob.seqStart==newJob.seqEnd and (newJob.imageFileName.find("#")<0)): newJob.imageSingleOutput = True if (useStereoFlag): if (newJob.imageFileName.find("%V")>=0): newJob.imageFileName = string.replace(newJob.imageFileName,"%V","<Stereo>") elif (newJob.imageFileName.find("%v")>=0): newJob.imageFileName = string.replace(newJob.imageFileName,"%v","<Stereo>") newJob.imageStereoR=newJob.imageStereoR[0] newJob.imageStereoL=newJob.imageStereoL[0] else: useStereoFlag=False mainNode = False else: newJob.maxChannels= newJob.maxChannels + 1 if (useStereoFlag): newJob.channelFileName.append(string.replace(string.replace(nuke.filename(writeNode),"%v","<Stereo>"),"%V","<Stereo>")) else: newJob.channelFileName.append(string.replace(string.replace(nuke.filename(writeNode),"%v",nViews[0][0]),"%V",nViews[0])) newJob.channelExtension.append("") if (not useStereoFlag): if ( (newJob.imageFileName.find("%V")>=0) or (newJob.imageFileName.find("%v")>=0)): for vn in range(1, len(nViews)): newJob.maxChannels= newJob.maxChannels + 1 newJob.channelFileName.append(string.replace(string.replace(newJob.imageFileName,"%v",nViews[vn][0]),"%V",nViews[vn])) newJob.channelExtension.append("") newJob.imageFileName = string.replace(string.replace(newJob.imageFileName,"%v",nViews[0][0]),"%V",nViews[0]) #if there is an .avi outout, place it as main output to RR knows that this job can only be send to one client at once for C in range(0, newJob.maxChannels): if (newJob.channelFileName[C].endswith(".avi") or newJob.channelFileName[C].endswith(".mov")): tempName=newJob.channelFileName[C] newJob.channelFileName[C]=newJob.imageFileName newJob.imageFileName=tempName break newJob.layer= "** All **" newJob.isActive = True jobList.append(newJob)
def _render(self, group_node, mov_path, png_path): """ Renders quickdaily node """ # setup quicktime output resolution width = self.get_setting("width", 1024) height = self.get_setting("height", 540) mov_reformat_node = group_node.node("mov_reformat") mov_reformat_node["box_width"].setValue(width) mov_reformat_node["box_height"].setValue(height) # setup output png path png_out = group_node.node("png_writer") png_path = png_path.replace(os.sep, "/") png_out["file"].setValue(png_path) # setup output quicktime path mov_out = group_node.node("mov_writer") mov_path = mov_path.replace(os.sep, "/") mov_out["file"].setValue(mov_path) # on the mac and windows, we use the quicktime codec # on linux, use ffmpeg # if sys.platform in ["win32","darwin"]: # # apple photo-jpeg movie # mov_out["file_type"].setValue('mov') # mov_out["codec"].setValue('apco') # mov_out["fps"].setValue(24) # #mov_out["settings"].setValue("000000000000000000000000000019a7365616e0000000100000001000000000000018676696465000000010000000e00000000000000227370746c0000000100000000000000006a706567000000000018000003ff000000207470726c000000010000000000000000000000000017f9db00000000000000246472617400000001000000000000000000000000000000530000010000000100000000156d70736f00000001000000000000000000000000186d66726100000001000000000000000000000000000000187073667200000001000000000000000000000000000000156266726100000001000000000000000000000000166d70657300000001000000000000000000000000002868617264000000010000000000000000000000000000000000000000000000000000000000000016656e647300000001000000000000000000000000001663666c67000000010000000000000000004400000018636d66720000000100000000000000006170706c00000014636c75740000000100000000000000000000001c766572730000000100000000000000000003001c00010000") # mov_out["mov32_pixel_format"].setValue('{{0} "default (YCbCrA 8-bit 444 Biased (r408))" "RGBA 8-bit" "YCbCrA 8-bit 444 Biased (r408)" "YCbCr 8-bit 422 (2vuy)"}') # mov_out["mov64_codec"].setValue("apco") # mov_out["mov64_bitrate"].setValue(20000) # mov_out["mov64_bitrate_tolerance"].setValue(40000000) # mov_out["mov64_quality_min"].setValue(2) # mov_out["mov64_quality_max"].setValue(31) # mov_out["mov64_gop_size"].setValue(12) # mov_out["mov64_b_frames"].setValue(0) # mov_out["checkHashOnRead"].setValue(False) # mov_out["selected"].setValue(True) # mov_out["xpos"].setValue(236) # mov_out["ypos"].setValue(-90) # elif sys.platform == "linux2": # mov_out["file_type"].setValue("ffmpeg") # mov_out["codec"].setValue("MOV format (mov)") # turn on the nodes mov_out.knob('disable').setValue(False) png_out.knob('disable').setValue(False) # finally render everything! # default to using the first view on stereo try: first_view = nuke.views()[0] nuke.executeMultiple( [mov_out, png_out], ([ self._get_first_frame()-1, self._get_last_frame(), 1 ],), [first_view] ) finally: # turn off the nodes again mov_out.knob('disable').setValue(True) png_out.knob('disable').setValue(True)
def get_views(): ''' Return a list of the views that are available in the scene. ''' return nuke.views()
def bake_knob(node, name, value=None): """ Function to set a knob using knob=value or bake the knob directly. Args: node (nuke.Node): A node we are trying to bake a knob on. name (str): The knob name we are trying to set. value ([Optional str]): If value is None execute the """ knob = node.knob(name) if not knob: return if value is None: if isinstance(knob, nuke.Array_Knob): views = nuke.views() start = nuke.Ada.script_frame_range.start end = nuke.Ada.script_frame_range.end for view in views: curves = knob.animations(view) for curve in curves: values = set() index = curve.knobIndex() for frame in range(start, end + 1): knob.setKeyAt(frame, index, view) value = curve.evaluate(frame) values.add(value) knob.setValueAt(value, frame, index, view) if len(values) > 1: knob.setExpression("curve", channel=index, view=view) else: knob.clearAnimated() # "BAKE" elif isinstance(knob, nuke.File_Knob): knob.setValue(str(nuke.tcl("subst", knob.value()))) elif isinstance(knob, nuke.EvalString_Knob): knob.setValue(knob.evaluate()) else: getLog().warning("{}.{} unsupported knob type {}".format( node.name(), name, type(knob))) else: try: knob.clearAnimated() except AttributeError: pass try: if isinstance(knob, nuke.Int_Knob): knob.setValue(int(value)) elif isinstance(knob, nuke.Enumeration_Knob): try: knob.setValue(int(value)) except ValueError: knob.setValue(str(value)) elif isinstance(knob, nuke.Array_Knob): knob.setValue(float(value)) else: knob.setValue(value) except TypeError as ee: getLog().warning("Ada: set {}.{}={} TypeError: {}".format( node.name(), name, value, ee)) except ValueError as ee: getLog().warning("Ada: set {}.{}={} ValueError: {}".format( node.name(), name, value, ee))
def serialise_node_knobs(queues): """ Create a graph object, iterate over all the nodes in each queue setting the attributes from the nodes and root format. Args: queues (itertools.groupby): A groupby object of the queue order and the nodes in that queue. Returns: graph_pb2: A graph object that we will later write to disk. """ graph = graph_pb2.Scene() graph.root.fps = nuke.Root()["fps"].value() graph.root.views.extend(nuke.views()) for order, nodes in queues: current_queue = graph.queue.add() current_queue.order = order for node_name in list(nodes): node = nuke.toNode(node_name) knobs_to_serialise = node["knobs_to_serialise"].value() current_node = current_queue.nodes.add() current_node.name = node.name() current_node.full_name = node.fullName() current_node.Class = node.Class() if not knobs_to_serialise: continue knob_list_to_serialise = knobs_to_serialise.split("\n") for knob in knob_list_to_serialise: alias_settings = deconstruct_knobs_to_serialise(knob) if not alias_settings or not node.knobs().get( alias_settings.knob): continue knob_object = node[alias_settings.knob] attribute = current_node.attributes.add() field_names = attribute.DESCRIPTOR.fields_by_name # set the alias name if isinstance(alias_settings, KnobAlias): attribute.type = 0 attribute.alias.name = alias_settings.alias elif isinstance(alias_settings, KnobInput): attribute.type = 1 attribute.alias.name = alias_settings.alias elif isinstance(alias_settings, KnobOutput): attribute.type = 2 attribute.alias.name = alias_settings.alias for field_name in field_names: if hasattr(knob_object, field_name): # we are setting a default knob value type if field_name == "value": value = knob_object.value() if hasattr(knob_object, "evaluate"): value = knob_object.evaluate() setattr(attribute, field_name, str(value)) else: get_knob_object = getattr(knob_object, field_name) if isinstance(get_knob_object(), list): get_repeated = getattr(attribute, field_name) get_repeated.extend(get_knob_object()) else: setattr(attribute, field_name, str(get_knob_object())) return graph
def _render_movie_in_nuke(self, fields, path, output_path, width, height, first_frame, last_frame): """ Use Nuke to render a movie. This assumes we're running _inside_ Nuke. """ output_node = None # create group where everything happens group = nuke.nodes.Group() # now operate inside this group group.begin() try: # create read node read = nuke.nodes.Read(name="source", file=path.replace(os.sep, "/")) read["on_error"].setValue("black") read["first"].setValue(first_frame) read["last"].setValue(last_frame) # now create the slate/burnin node burn = nuke.nodePaste(self._burnin_nk) burn.setInput(0, read) # set the fonts for all text fields burn.node("top_left_text")["font"].setValue(self._font) burn.node("top_right_text")["font"].setValue(self._font) burn.node("bottom_left_text")["font"].setValue(self._font) burn.node("framecounter")["font"].setValue(self._font) burn.node("slate_info")["font"].setValue(self._font) # add the logo burn.node("logo")["file"].setValue(self._logo) # format the burnins version_padding_format = "%%0%dd" % self.get_setting( "version_number_padding") version_str = version_padding_format % fields.get("version", 0) if self.context.task: version = "%s, v%s" % (self.context.task["name"], version_str) elif self.context.step: version = "%s, v%s" % (self.context.step["name"], version_str) else: version = "v%s" % version_str burn.node("top_left_text")["message"].setValue( self.context.project["name"]) burn.node("top_right_text")["message"].setValue( self.context.entity["name"]) burn.node("bottom_left_text")["message"].setValue(version) # and the slate slate_str = "Project: %s\n" % self.context.project["name"] slate_str += "%s: %s\n" % (self.context.entity["type"], self.context.entity["name"]) slate_str += "Name: %s\n" % fields.get("name", "Unnamed").capitalize() slate_str += "Version: %s\n" % version_str if self.context.task: slate_str += "Task: %s\n" % self.context.task["name"] elif self.context.step: slate_str += "Step: %s\n" % self.context.step["name"] slate_str += "Frames: %s - %s\n" % (first_frame, last_frame) burn.node("slate_info")["message"].setValue(slate_str) # create a scale node scale = self._create_scale_node(width, height) scale.setInput(0, burn) # Create the output node output_node = self._create_output_node(output_path) output_node.setInput(0, scale) finally: group.end() if output_node: # Make sure the output folder exists output_folder = os.path.dirname(output_path) self.ensure_folder_exists(output_folder) # Render the outputs, first view only nuke.executeMultiple([output_node], ([first_frame - 1, last_frame, 1], ), [nuke.views()[0]]) # Cleanup after ourselves nuke.delete(group)
def dailiesGenCmd(node): # Process Input Node: inputnode = None for i in range(node.inputs()): inputnode = node.input(i) if inputnode is None: nuke.message('Error:\n' '%s\n' 'Not connected to Read or Write node.' % node.name()) return if not inputnode.Class() in ['Read', 'Write']: nuke.message('Error:\n' '%s\n' 'Connected not to Read or Write node.' % node.name()) return # Process Images: images = '' root_frame_first = nuke.Root().firstFrame() root_frame_last = nuke.Root().lastFrame() if root_frame_first == root_frame_last: root_frame_last += 100 # Get needed views from dailies node if forced: if node.knob('forceviews').value(): views = node.knob('viewsnames').value().split(' ') else: # Get needed views write node: views_knob = inputnode.knob('views') if views_knob is not None: views = inputnode.knob('views').value().split(' ') else: # Get all scene views: views = nuke.views() # Generate input pattern from each view: for view in views: if not len(view): continue # skip empty view, may be after split(' ') if not view in nuke.views(): print('Error: Skipping invalid view: "%s"' % view) continue octx = nuke.OutputContext() octx.setView(1 + nuke.views().index(view)) octx.setFrame(root_frame_first) images1 = inputnode.knob('file').getEvaluatedValue(octx) if images1 is None or images1 == '': nuke.message('Error:\n' '%s\n' 'Files are empty.\n' 'View "%s", frame %d.' % (inputnode.name(), view, root_frame_first)) return octx.setFrame(root_frame_last) images2 = inputnode.knob('file').getEvaluatedValue(octx) if images2 is None or images2 == '': nuke.message('Error:\n' '%s\n' 'Files are empty.\n' 'View "%s", frame %d.' % (inputnode.name(), view, root_frame_last)) return part1, padding, part2 = afcommon.splitPathsDifference(images1, images2) if padding < 1: nuke.message('Error:\n' '%s\Invalid files pattern.\n' 'View "%s".' % (inputnode.name(), view)) return if len(images): images += ' ' images += '%s%s%s' % (part1, '#' * padding, part2) if images == '': nuke.message('Error:\n%s\No valid views found.' % inputnode.name()) return # Get Movie Name: movname = node.knob('movname').value() if movname is None or movname == '': nuke.message('Error:\n%s\nMovie name is not set.' % node.name()) return # Get Movie Folder: movfolder = node.knob('movfolder').getEvaluatedValue() if movfolder is None or movfolder == '': nuke.message('Error:\n%s\nMovie folder is not set.' % node.name()) return # Get Parameters: format = node.knob('format').value() fps = node.knob('fps').value() codec = node.knob('codec').value() template = node.knob('template').getEvaluatedValue() slate = node.knob('slate').getEvaluatedValue() company = node.knob('company').value() project = node.knob('project').value() shot = node.knob('shot').value() version = node.knob('version').value() artist = node.knob('artist').value() activity = node.knob('activity').value() comments = node.knob('comments').value() cach_op = node.knob('cach_op').value() line_clr = node.knob('line_clr').value() draw169 = node.knob('draw169').value() draw235 = node.knob('draw235').value() line169 = node.knob('line169').value() line235 = node.knob('line235').value() lgspath = node.knob('lgspath').getEvaluatedValue() lgfpath = node.knob('lgfpath').getEvaluatedValue() lgsgrav = node.knob('lgsgrav').value() lgfgrav = node.knob('lgfgrav').value() lgssize = int(node.knob('lgssize').value()) lgfsize = int(node.knob('lgfsize').value()) fstart = int(node.knob('fstart').value()) fend = int(node.knob('fend').value()) fffirst = int(node.knob('fffirst').value()) faketime_on = int(node.knob('faketime_on').value()) faketime_str = node.knob('faketime_str').value() encodeonly = node.knob('encodeonly').value() tmpformat = node.knob('tmpformat').value() tmpquality = node.knob('tmpquality').value() autocolorspace = int(node.knob('autocolorspace').value()) asp_in = float(node.knob('asp_in').value()) gamma = float(node.knob('gamma').value()) cach_as = float(node.knob('cach_as').value()) line_as = float(node.knob('line_as').value()) # Command Construction: cmd = os.environ['CGRU_LOCATION'] cmd = os.path.join(cmd, 'utilities') cmd = os.path.join(cmd, 'moviemaker') cmd = os.path.join(cmd, 'makemovie.py') cmd = 'python ' + cmd cmd += ' -f "%s"' % fps cmd += ' -c "%s"' % codec if faketime_on and faketime_str is not None and faketime_str != '': cmd += ' --faketime %d' % \ int(time.mktime(time.strptime(faketime_str, TimeFromat))) if tmpformat is not None and tmpformat != '': cmd += ' --tmpformat "%s"' % tmpformat if tmpquality is not None and tmpquality != '': cmd += ' --tmpquality "%s"' % tmpquality if not autocolorspace: cmd += ' --noautocorr' if gamma != 1.0: cmd += ' -g %03f' % gamma if asp_in > 0.0: cmd += ' --aspect_in %f' % asp_in if fstart != -1: cmd += ' --fs %d' % fstart if fend != -1: cmd += ' --fe %d' % fend if fffirst: cmd += ' --fff' if not encodeonly: cmd += ' -r "%s"' % format if template is not None and template != '': cmd += ' -t "%s"' % template if slate is not None and slate != '': cmd += ' -s "%s"' % slate if company is not None and company != '': cmd += ' --company "%s"' % company if project is not None and project != '': cmd += ' --project "%s"' % project if shot is not None and shot != '': cmd += ' --shot "%s"' % shot if version is not None and version != '': cmd += ' --ver "%s"' % version if artist is not None and artist != '': cmd += ' --artist "%s"' % artist if activity is not None and activity != '': cmd += ' --activity "%s"' % activity if comments is not None and comments != '': cmd += ' --comments "%s"' % comments if draw169 is not None and draw169 != '': cmd += ' --draw169 "%s"' % draw169 if draw235 is not None and draw235 != '': cmd += ' --draw235 "%s"' % draw235 if line169 is not None and line169 != '': cmd += ' --line169 "%s"' % line169 if line235 is not None and line235 != '': cmd += ' --line235 "%s"' % line235 if line_clr is not None and line_clr != '': cmd += ' --line_aspect %f' % line_as cmd += ' --line_color "%s"' % line_clr if cach_op is not None and cach_op != '': cmd += ' --cacher_aspect %f' % cach_as cmd += ' --cacher_opacity "%s"' % cach_op if lgspath is not None and lgspath != '': cmd += ' --lgspath "%s"' % lgspath cmd += ' --lgssize %d' % lgssize cmd += ' --lgsgrav %s' % lgsgrav if lgfpath is not None and lgfpath != '': cmd += ' --lgfpath "%s"' % lgfpath cmd += ' --lgfsize %d' % lgfsize cmd += ' --lgfgrav %s' % lgfgrav if node.knob('stereodub').value(): cmd += ' --stereo' cmd += ' ' + images cmd += ' ' + os.path.join(os.path.abspath(movfolder), movname) return cmd
def copyToProjector(node=None, frame=None, gui=nuke.GUI): if not node: node = nuke.thisNode() if not frame: frame = nuke.root()['frame'].value() if node.Class() not in ['StereoCam', 'StereoCam2', 'Camera', 'Camera2']: m = 'this node is not a supported camera type, unable to convert to projector' if gui: nuke.message(m) nuke.error(m) return saved_frame = nuke.root()['frame'].value() nuke.root()['frame'].setValue(frame) # Turn off all selected nodes, otherwise they mess up the node paste: for n in nuke.selectedNodes(): n.knob('selected').setValue(False) # Now select this node then copy and paste it: node['selected'].setValue(True) nukescripts.node_copypaste() proj = nuke.selectedNode() # Name/label new node: new_name = 'projector_cam' if node.knob('shot') is not None: if node['shot'].getText() != '': new_name += '_%s_' % proj['shot'].getText().replace('.', '_') new_name += 'fr%d_' % nuke.frame() # De-duplicate the new name: counter = 1 while 1: new_name2 = new_name + '%d' % counter if nuke.toNode(new_name2) is None: new_name = new_name2 break counter += 1 proj['name'].setValue(new_name) l = proj['label'].getText() if l != '' and not l.endswith('\\n'): l += '\\n' l += 'frame %d' % nuke.frame() proj['label'].setValue(l) # Offset its position in the DAG: xpos = node['xpos'].value() proj['xpos'].setValue(xpos + 100) ypos = node['ypos'].value() proj['ypos'].setValue(ypos + 100) # Unsplit all knobs (remove views): vs = nuke.views() if len(vs) > 1: for name, knob in proj.knobs().items(): if issubclass(knob.__class__, nuke.Array_Knob): #print 'knob %s: unsplitting view %s' % (knob.name(), vs[1]) knob.unsplitView(view=vs[1]) # Clear animations from all knobs: for name, knob in proj.knobs().items(): if knob.isAnimated(): knob.clearAnimated() # Disable updating: if proj.knob('read_from_file') is not None: proj['read_from_file'].setValue(False) nuke.root()['frame'].setValue(saved_frame)
def __init__(self, afnode, wnode, subblock, prefix, fparams): if VERBOSE == 2: print('Initializing block parameters for "%s"' % wnode.name()) self.wnode = wnode self.valid = True self.subblock = subblock self.prefix = prefix self.framefirst = nuke.root().firstFrame() self.framelast = nuke.root().lastFrame() self.frameinc = 1 self.framespertask = 1 self.framesequential = 1 self.skipexisting = 0 self.maxhosts = -1 self.capacity = -1 self.maxperhost = -1 self.maxruntime = -1 self.hostsmask = None self.hostsmaskexclude = None self.fullrangedepend = 0 self.tmpimage = 1 self.pathsmap = 1 self.imgfiles = [] if afnode is not None: self.framefirst = int(afnode.knob('framefirst').value()) self.framelast = int(afnode.knob('framelast').value()) self.frameinc = int(afnode.knob('frameinc').value()) self.framespertask = int(afnode.knob('framespertask').value()) self.framesequential = int(afnode.knob('framesequential').value()) self.skipexisting = int(afnode.knob('skipexisting').value()) self.maxhosts = int(afnode.knob('maxhosts').value()) self.capacity = int(afnode.knob('capacity').value()) self.maxperhost = int(afnode.knob('maxperhost').value()) self.maxruntime = int(afnode.knob('maxruntime').value()) self.tmpimage = int(afnode.knob('tmpimage').value()) self.pathsmap = int(afnode.knob('pathsmap').value()) self.hostsmask = afnode.knob('hostsmask').value() self.hostsmaskexclude = afnode.knob('hostsmaskexcl').value() if self.skipexisting: self.framespertask = 1 self.writename = str(wnode.fullName()) if wnode.Class() == RenderNodeClassName: afcommon = __import__('afcommon', globals(), locals(), []) # Get images files: if nuke.toNode('root').knob('proxy').value(): fileknob = wnode.knob('proxy') else: fileknob = wnode.knob('file') # Get views: views = wnode.knob('views') if views is not None: views = views.value() if views is None or views == '': views = nuke.views() else: views = views.split(' ') else: views = nuke.views() # Iterate views: for view in views: view = view.strip() if not len(view): continue # skip empty view, may be after split(' ') # Check view exists: if not view in nuke.views(): print('Error: Skipping invalid view: "%s"' % view) continue # if len( self.imgfiles): # self.imgfiles += ';' # Get show files for current view and first and last frames: octx = nuke.OutputContext() octx.setView(1 + nuke.views().index(view)) octx_framefirst = self.framefirst octx_framelast = self.framelast if octx_framefirst < 0: octx_framefirst = 0 if octx_framelast < 0: octx_framelast = 0 # If frame first and frame last are equal no sequence needed if octx_framefirst == octx_framelast: octx.setFrame(octx_framefirst) self.imgfiles.append(fileknob.getEvaluatedValue(octx)) else: # Get files from first and last frames # to calculate frames pattern: octx.setFrame(octx_framefirst) images1 = fileknob.getEvaluatedValue(octx) if images1 is None or images1 == '': nuke.message( 'Error:\n' '%s\n' 'Files are empty.\n' 'View "%s", frame %d.' % (self.writename, view, self.framefirst) ) self.valid = False return octx.setFrame(octx_framelast) images2 = fileknob.getEvaluatedValue(octx) if images2 is None or images2 == '': nuke.message( 'Error:\n' '%s\n' 'Files are empty.\n' 'View "%s", frame %d.' % (self.writename, view, self.framelast) ) self.valid = False return part1, padding, part2 = \ afcommon.splitPathsDifference(images1, images2) if padding < 1: nuke.message( 'Error:\n' '%s\n' 'Invalid files pattern.\n' 'View "%s".' % (self.writename, view) ) self.valid = False return self.imgfiles.append( '%s@%s@%s' % (part1, '#' * padding, part2) ) # Check images folders: for imgfile in self.imgfiles: folder = os.path.dirname(imgfile) if folder != '': if not os.path.isdir(folder): result = nuke.ask( 'Write Node "%s" Directory\n' '%s\n' 'Does not exist.\n' 'Create it?' % (self.writename, folder) ) if result: os.makedirs(folder) if not os.path.isdir(folder): nuke.message( "Can't create folder:\n%s" % folder ) self.valid = False else: self.valid = False elif wnode.Class() == DailiesNodeClassName: if VERBOSE: print('Generating dailies "%s"' % self.writename) else: nuke.message('Node type\n"%s"\nis unsendable.' % self.writename) self.valid = False for par in fparams: if fparams[par] is not None: if hasattr(self, par): setattr(self, par, fparams[par]) self.name = self.writename if subblock: if self.prefix is not None: if self.prefix != '': self.name = self.prefix + self.name self.dependmask = '' self.tasksdependmask = ''
def swap_view(): views = nuke.views() if len(views) == 2: nuke.activeViewer().setView(views[1]) if nuke.activeViewer().view( ) == views[0] else nuke.activeViewer().setView(views[0])
def CLrender(nodes=[]): """ Creates command-line Nuke batch file with different control parameters (frame by frame, skip existing frame, Stereo) """ if nuke.root().knob('name').value() == '': nuke.message('This script is not named. Please save it and try again.') return nodelist = '' if nodes != []: nodelist = ','.join([n.name() for n in nodes if n.Class() == "Write"]) else: Writes = nuke.allNodes("Write") if len(Writes) == 1: nodelist = Writes[0].name() if nodelist == "": nuke.message("Please select Write node(s) !") return class CLrenderDialog(nukescripts.PythonPanel): def __init__(self): nukescripts.PythonPanel.__init__( self, 'Create rendering command line batch file(s) -- (philhub 2011)' ) self.setMinimumSize(600, 300) self.nodesKnob = nuke.String_Knob('nodesExec', 'Node(s) to execute:', nodelist) self.addKnob(self.nodesKnob) self.startKnob = nuke.Int_Knob('startFrame', 'Start frame :') self.addKnob(self.startKnob) self.endKnob = nuke.Int_Knob('endFrame', ' End frame :') self.addKnob(self.endKnob) self.endKnob.clearFlag(nuke.STARTLINE) self.spaceKnob = nuke.Text_Knob('space', '') self.addKnob(self.spaceKnob) self.spaceKnob.setFlag(nuke.STARTLINE) self.limitKnob = nuke.Boolean_Knob('limit', 'Limit Memory to (Go)') self.addKnob(self.limitKnob) self.limitKnob.setFlag(nuke.STARTLINE) self.memKnob = nuke.Int_Knob('mem', '') self.addKnob(self.memKnob) self.memKnob.clearFlag(nuke.STARTLINE) # self.unitKnob = nuke.Text_Knob('unit', 'Go') # self.addKnob(self.unitKnob) # self.unitKnob.clearFlag(nuke.STARTLINE) self.limitcpuKnob = nuke.Boolean_Knob('limitcpu', 'Limit Cores to') self.addKnob(self.limitcpuKnob) self.limitcpuKnob.clearFlag(nuke.STARTLINE) self.cpuKnob = nuke.Int_Knob('cpu', '') self.addKnob(self.cpuKnob) self.cpuKnob.clearFlag(nuke.STARTLINE) self.spaceKnob2 = nuke.Text_Knob('space2', '') self.addKnob(self.spaceKnob2) self.spaceKnob2.setFlag(nuke.STARTLINE) self.threadsKnob = nuke.Int_Knob('threads', 'Number of BAT files :') self.addKnob(self.threadsKnob) self.threadsKnob.setFlag(nuke.STARTLINE) self.threadWhyKnob = nuke.Text_Knob( 'threadWhy', '(to distrib on multiple cores/boxes)') self.addKnob(self.threadWhyKnob) self.threadWhyKnob.clearFlag(nuke.STARTLINE) self.fbfKnob = nuke.Boolean_Knob( 'fbf', 'Frame by Frame ? (to avoid some insanes increasing render time)' ) self.addKnob(self.fbfKnob) self.fbfKnob.setFlag(nuke.STARTLINE) self.skipKnob = nuke.Boolean_Knob('skip', 'Skip existing Frames ?') self.addKnob(self.skipKnob) self.skipKnob.setFlag(nuke.STARTLINE) self.stereoKnob = nuke.Boolean_Knob('stereo', 'Stereo ?') self.addKnob(self.stereoKnob) self.stereoKnob.setFlag(nuke.STARTLINE) self.backupKnob = nuke.Boolean_Knob( 'backup', "Create a comp's backup ? (and renders from it)") self.addKnob(self.backupKnob) self.openFolderKnob = nuke.Boolean_Knob('openFolder', "open folder ?") self.addKnob(self.openFolderKnob) self.openFolderKnob.setFlag(nuke.STARTLINE) self.spaceKnob2 = nuke.Text_Knob('space', '') self.addKnob(self.spaceKnob2) self.spaceKnob2.setFlag(nuke.STARTLINE) self.backupKnob.setFlag(nuke.STARTLINE) self.okButton = nuke.Script_Knob("OK") self.addKnob(self.okButton) self.okButton.setFlag(nuke.STARTLINE) self.cancelButton = nuke.Script_Knob("Cancel") self.addKnob(self.cancelButton) self.infosKnob = nuke.PyScript_Knob('infos', "infos") self.infosKnob.setCommand( '''import webbrowserwebbrowser.open("http://www.nukepedia.com/python/render/cmdlinerender/")''' ) self.addKnob(self.infosKnob) p = CLrenderDialog() p.startKnob.setValue(int(nuke.knob("first_frame"))) p.endKnob.setValue(int(nuke.knob("last_frame"))) p.memKnob.setValue(8) p.cpuKnob.setValue(2) p.threadsKnob.setValue(1) p.fbfKnob.setValue(1) p.skipKnob.setValue(0) p.stereoKnob.setValue(0) p.backupKnob.setValue(1) p.openFolderKnob.setValue(1) result = p.showModalDialog() if not result: return nuke.scriptSave('') start = p.startKnob.value() end = p.endKnob.value() threads = p.threadsKnob.value() mem = p.memKnob.value() cpu = p.cpuKnob.value() fbf = p.fbfKnob.value() skip = p.skipKnob.value() stereo = p.stereoKnob.value() if threads < 1: return flags = " -x -i " if stereo: views = ','.join(nuke.views()) else: views = nuke.views()[0] flags += " -view " + views if nodelist != '': flags += " -X " + nodelist if p.limitKnob.value(): flags += " -c " + str(mem) + "G" if p.limitcpuKnob.value(): flags += " -m " + str(cpu) comp_dirpath = nuke.value("root.name") exe = '"' + nuke.env[ 'ExecutablePath'] + '"' # for BAT file, " avoid error with names with spaces if p.backupKnob.value(): bkp_dirpath = os.path.dirname(comp_dirpath) + '/backup_from_CLrender/' if not os.path.exists(bkp_dirpath): os.makedirs(bkp_dirpath) bkp_filepath = bkp_dirpath + os.path.basename(comp_dirpath) shutil.copy(comp_dirpath, bkp_filepath) comp_dirpath = '"' + bkp_filepath + '"' # for BAT file, " avoid error with names with spaces else: comp_dirpath = '"' + comp_dirpath + '"' # for BAT file, " avoid error with names with spaces for thread in range(threads): bat_name = nuke.value("root.name").replace( '.nk', '_' + nodelist.replace(",", "-") + "_x" + str(threads) + "x" + str(start + thread) + "-" + str(end) + '.bat') if fbf and not (skip): cmd = r"FOR /l %%I IN (" + ",".join( [str(start + thread), str(threads), str(end)]) + r") DO (" + " ".join( [exe, flags, r"-F %%I-%%I", comp_dirpath]) + ")" bat_name = bat_name.replace('.bat', '_FrameByFrame.bat') elif skip: cmd = r"FOR /l %%I IN (" + ",".join( [str(start + thread), str(threads), str(end)]) + r") DO (" + " ".join([ exe, "-t", os.path.realpath(__file__), comp_dirpath, nodelist, "%%I", views ]) + ")" bat_name = bat_name.replace('.bat', '_SkipExisting.bat') else: cmd = " ".join([ exe, flags, '-F', '"' + str(start + thread) + "-" + str(end) + 'x' + str(threads) + '"', comp_dirpath ]) if stereo: bat_name = bat_name.replace('.bat', '_STEREO.bat') print "command : " + cmd print "saved to : " + bat_name try: file = open(bat_name, 'w') #file.write("mode con cols=500 lines=500") file.write("\nCOLOR 4f\n") file.write("\n") file.write(cmd) file.write("\n\nCOLOR 2f\n") file.write("pause") finally: file.close() if p.openFolderKnob.value(): openCompFolder()
def rrSubmit_CreateAllJob(jobList, noLocalSceneCopy): newJob = rrJob() rrSubmit_fillGlobalSceneInfo(newJob) nList = getAllWriteNodes() mainNode = True nViews = nuke.views() useStereoFlag = False if len(nViews) == 2: useStereoFlag = True newJob.imageStereoR = nViews[0] newJob.imageStereoL = nViews[1] for node in nList: if node["disable"].value(): continue pathScripted = "" writeNode = node if isGizmo(node): with node: gList = nuke.allNodes("Write") + nuke.allNodes("DeepWrite") for gnode in gList: if gnode["disable"].value(): continue pathScripted = gnode["file"].value() if (pathScripted == None) or (len(pathScripted) < 3): continue writeNode = gnode if isScriptedOutput(pathScripted, True): noLocalSceneCopy[0] = True else: pathScripted = writeNode["file"].value() if (pathScripted == None) or (len(pathScripted) < 3): continue if mainNode: if writeNode["use_limit"].value(): newJob.seqStart = writeNode["first"].value() newJob.seqEnd = writeNode["last"].value() newJob.imageFileName = nuke.filename(writeNode) if newJob.seqStart == newJob.seqEnd and (newJob.imageFileName.find("#") < 0): newJob.imageSingleOutput = True if useStereoFlag: if newJob.imageFileName.find("%V") >= 0: newJob.imageFileName = string.replace(newJob.imageFileName, "%V", "<Stereo>") elif newJob.imageFileName.find("%v") >= 0: newJob.imageFileName = string.replace(newJob.imageFileName, "%v", "<Stereo>") newJob.imageStereoR = newJob.imageStereoR[0] newJob.imageStereoL = newJob.imageStereoL[0] else: useStereoFlag = False mainNode = False else: newJob.maxChannels = newJob.maxChannels + 1 if useStereoFlag: newJob.channelFileName.append( string.replace(string.replace(nuke.filename(writeNode), "%v", "<Stereo>"), "%V", "<Stereo>") ) else: newJob.channelFileName.append( string.replace(string.replace(nuke.filename(writeNode), "%v", nViews[0][0]), "%V", nViews[0]) ) newJob.channelExtension.append("") if not useStereoFlag: if (newJob.imageFileName.find("%V") >= 0) or (newJob.imageFileName.find("%v") >= 0): for vn in range(1, len(nViews)): newJob.maxChannels = newJob.maxChannels + 1 newJob.channelFileName.append( string.replace(string.replace(newJob.imageFileName, "%v", nViews[vn][0]), "%V", nViews[vn]) ) newJob.channelExtension.append("") newJob.imageFileName = string.replace( string.replace(newJob.imageFileName, "%v", nViews[0][0]), "%V", nViews[0] ) # if there is an .avi outout, place it as main output to RR knows that this job can only be send to one client at once for C in range(0, newJob.maxChannels): if newJob.channelFileName[C].endswith(".avi") or newJob.channelFileName[C].endswith(".mov"): tempName = newJob.channelFileName[C] newJob.channelFileName[C] = newJob.imageFileName newJob.imageFileName = tempName break newJob.layer = "** All **" newJob.isActive = True jobList.append(newJob)
def dailiesGenCmd( node): # Process Input Node: inputnode = None for i in range( node.inputs()): inputnode = node.input(i) if inputnode is None: nuke.message('Error:\n%s\nNot connected to Read or Write node.' % node.name()) return if not inputnode.Class() in ['Read','Write']: nuke.message('Error:\n%s\nConnected not to Read or Write node.' % node.name()) return # Process Images: images = '' root_frame_first = nuke.Root().firstFrame() root_frame_last = nuke.Root().lastFrame() if root_frame_first == root_frame_last: root_frame_last += 100 # Get needed views from dailies node if forced: if node.knob('forceviews').value(): views = node.knob('viewsnames').value().split(' ') else: # Get needed views write node: views_knob = inputnode.knob('views') if views_knob is not None: views = inputnode.knob('views').value().split(' ') else: # Get all scene views: views = nuke.views() # Generate input pattern from each view: for view in views: if not len(view): continue # skip empty view, may be after split(' ') if not view in nuke.views(): print('Error: Skipping invalid view: "%s"' % view) continue octx = nuke.OutputContext() octx.setView( 1 + nuke.views().index(view)) octx.setFrame( root_frame_first) images1 = inputnode.knob('file').getEvaluatedValue( octx) if images1 is None or images1 == '': nuke.message('Error:\n%s\nFiles are empty.\nView "%s", frame %d.' % (inputnode.name(), view, root_frame_first)) return octx.setFrame( root_frame_last) images2 = inputnode.knob('file').getEvaluatedValue( octx) if images2 is None or images2 == '': nuke.message('Error:\n%s\nFiles are empty.\nView "%s", frame %d.' % (inputnode.name(), view, root_frame_last)) return part1, padding, part2 = afcommon.splitPathsDifference( images1, images2) if padding < 1: nuke.message('Error:\n%s\Invalid files pattern.\nView "%s".' % (inputnode.name(), view)) return if len(images): images += ' ' images += part1 + '#'*padding + part2 if images == '': nuke.message('Error:\n%s\No valid views founded.' % inputnode.name()) return # Get Movie Name: movname = node.knob('movname' ).value() if movname is None or movname == '': nuke.message('Error:\n%s\nMovie name is not set.' % node.name()) return # Get Movie Folder: movfolder = node.knob('movfolder').getEvaluatedValue() if movfolder is None or movfolder == '': nuke.message('Error:\n%s\nMovie folder is not set.' % node.name()) return # Get Parameters: format = node.knob('format' ).value() fps = node.knob('fps' ).value() codec = node.knob('codec' ).value() template = node.knob('template').getEvaluatedValue() slate = node.knob('slate' ).getEvaluatedValue() company = node.knob('company' ).value() project = node.knob('project' ).value() shot = node.knob('shot' ).value() version = node.knob('version' ).value() artist = node.knob('artist' ).value() activity = node.knob('activity').value() comments = node.knob('comments').value() cach_op = node.knob('cach_op' ).value() line_clr = node.knob('line_clr').value() draw169 = node.knob('draw169' ).value() draw235 = node.knob('draw235' ).value() line169 = node.knob('line169' ).value() line235 = node.knob('line235' ).value() lgspath = node.knob('lgspath' ).getEvaluatedValue() lgfpath = node.knob('lgfpath' ).getEvaluatedValue() lgsgrav = node.knob('lgsgrav' ).value() lgfgrav = node.knob('lgfgrav' ).value() lgssize = int(node.knob('lgssize').value()) lgfsize = int(node.knob('lgfsize').value()) fstart = int(node.knob('fstart').value()) fend = int(node.knob('fend').value()) fffirst = int(node.knob('fffirst').value()) faketime_on = int(node.knob('faketime_on').value()) faketime_str = node.knob('faketime_str').value() encodeonly = node.knob('encodeonly').value() tmpformat = node.knob('tmpformat').value() tmpquality = node.knob('tmpquality').value() autocolorspace = int(node.knob('autocolorspace').value()) asp_in = float(node.knob('asp_in' ).value()) gamma = float(node.knob('gamma').value()) cach_as = float(node.knob('cach_as' ).value()) line_as = float(node.knob('line_as' ).value()) # Command Construction: cmd = os.environ['CGRU_LOCATION'] cmd = os.path.join( cmd, 'utilities') cmd = os.path.join( cmd, 'moviemaker') cmd = os.path.join( cmd, 'makemovie.py') cmd = 'python ' + cmd cmd += ' -f "%s"' % fps cmd += ' -c "%s"' % codec if faketime_on and faketime_str is not None and faketime_str != '': cmd += ' --faketime %d' % int(time.mktime( time.strptime( faketime_str, TimeFromat))) if tmpformat is not None and tmpformat != '': cmd += ' --tmpformat "%s"' % tmpformat if tmpquality is not None and tmpquality != '': cmd += ' --tmpquality "%s"' % tmpquality if not autocolorspace: cmd += ' --noautocorr' if gamma != 1.0: cmd += ' -g %03f' % gamma if asp_in > 0.0: cmd += ' --aspect_in %f' % asp_in if fstart != -1: cmd += ' --fs %d' % fstart if fend != -1: cmd += ' --fe %d' % fend if fffirst : cmd += ' --fff' if not encodeonly: cmd += ' -r "%s"' % format if template is not None and template != '': cmd += ' -t "%s"' % template if slate is not None and slate != '': cmd += ' -s "%s"' % slate if company is not None and company != '': cmd += ' --company "%s"' % company if project is not None and project != '': cmd += ' --project "%s"' % project if shot is not None and shot != '': cmd += ' --shot "%s"' % shot if version is not None and version != '': cmd += ' --ver "%s"' % version if artist is not None and artist != '': cmd += ' --artist "%s"' % artist if activity is not None and activity != '': cmd += ' --activity "%s"' % activity if comments is not None and comments != '': cmd += ' --comments "%s"' % comments if draw169 is not None and draw169 != '': cmd += ' --draw169 "%s"' % draw169 if draw235 is not None and draw235 != '': cmd += ' --draw235 "%s"' % draw235 if line169 is not None and line169 != '': cmd += ' --line169 "%s"' % line169 if line235 is not None and line235 != '': cmd += ' --line235 "%s"' % line235 if line_clr is not None and line_clr != '': cmd += ' --line_aspect %f' % line_as cmd += ' --line_color "%s"' % line_clr if cach_op is not None and cach_op != '': cmd += ' --cacher_aspect %f' % cach_as cmd += ' --cacher_opacity "%s"' % cach_op if lgspath is not None and lgspath != '': cmd += ' --lgspath "%s"' % lgspath cmd += ' --lgssize %d' % lgssize cmd += ' --lgsgrav %s' % lgsgrav if lgfpath is not None and lgfpath != '': cmd += ' --lgfpath "%s"' % lgfpath cmd += ' --lgfsize %d' % lgfsize cmd += ' --lgfgrav %s' % lgfgrav if node.knob('stereodub').value(): cmd += ' --stereo' cmd += ' ' + images cmd += ' ' + os.path.join( os.path.abspath( movfolder), movname) return cmd