def _source_roto_template(self, step_name, proj_format): """ Prompts user if they want to import the set Roto template for the New File. """ if step_name == "Roto": roto_template = nuke.ask( "Source the default Nuke template for the <i style='color:magenta'><b><br>SSVFX Roto</b></i> workflow?" ) if not roto_template: pass else: tk = self.parent.engine.sgtk roto_template_script = tk.templates["workfile_templates"] fields = {} roto_template_script_path = os.path.normpath( roto_template_script.apply_fields(fields) + "\\pipeline_task\\roto\\roto_rgb_template.nk") roto_template_script_path = roto_template_script_path.replace( "/", os.path.sep) if os.path.exists(roto_template_script_path): nuke.tprint("Importing Roto template:", roto_template_script_path) nuke.scriptSource(roto_template_script_path) nuke.zoom(0.0) try: nuke.Root().knob('format').setValue(proj_format) except: nuke.tprint("!!! No proj_format called %s" % proj_format)
def goToActiveNthNode(nth): av = nuke.activeViewer() if nth - 1 < 0: avn = av.node().input(9) else: avn = av.node().input(nth - 1) nuke.zoom(1, [avn.xpos(), avn.ypos()])
def listbookmarks(): bm=[] zoomBy=1 #find bookmark nodes for n in nuke.allNodes(): n['selected'].setValue( False ) if n['icon'].value() == 'bookmark.png': n['selected'].setValue( True ) #select nodes for clarity bmLabel=nuke.selectedNode()['label'].value() if bmLabel: bm_name='"'+bmLabel+'"' # '"'<-lets it list correctly else: bm_name='"'+n.name()+'"' # '"'<-allows it to be sorted correctly with above bm.append(bm_name) if 0==len(bm): nuke.message('no bookmarks found') else: bookmarkList=str(sorted(bm)) #clean up list name pattern = re.compile('[\[\]\']') bookmarkList = pattern.sub('', bookmarkList) pattern = re.compile('[\,]') bookmarkList = pattern.sub(' ', bookmarkList) #let user choose bookmark panel = nuke.Panel ('BookMarks',200) panel.addEnumerationPulldown('go to',bookmarkList) panel.addSingleLineInput('zoom',zoomBy) panel.addBooleanCheckBox('also open node', False) panel.addButton("Cancel") panel.addButton("Zoom to") panel.addButton("Open") result=panel.show() if result: goto= panel.value('go to') zoomf= panel.value('zoom') alwaysOpen= panel.value('also open node') #select only relevent node for n in nuke.allNodes(): if goto == n.name() or goto == n['label'].value(): n['selected'].setValue( True ) else: n['selected'].setValue( False ) #set nuke to highlight chosen node, get xy pos and zoom into area and open if selected. if result ==1: nuke.zoom(float(zoomf),(nuke.selectedNode().xpos(),nuke.selectedNode().ypos())) if alwaysOpen: nuke.show(nuke.selectedNode()) elif result ==2: nuke.show(nuke.selectedNode()) else: pass
def process(self, context, plugin): # Get the errored instances failed = [] for result in context.data["results"]: if (result["error"] is not None and result["instance"] is not None and result["instance"] not in failed): failed.append(result["instance"]) # Apply pyblish.logic to get the instances for the plug-in instances = pyblish.api.instances_by_plugin(failed, plugin) nodes_to_select = [] for instance in instances: cls_instance = plugin() nodes_to_select.extend(cls_instance.get_plugin_nodes()) # Deselect all nodes. for node in nuke.allNodes(): node["selected"].setValue(False) # Selecting nodes for node in nodes_to_select: node["selected"].setValue(True) # Zoom to node xC = node.xpos() + node.screenWidth() / 2 yC = node.ypos() + node.screenHeight() / 2 nuke.zoom(3, [xC, yC])
def shuffleNameCollect(): nodes = nuke.selectedNodes() info = [] if nodes == []: pass elif nodes != []: for node in nodes: if node.Class() == "Shuffle1" or node.Class() == "Shuffle": info.append(node.knob("in").value()) if info != []: node = nuke.selectedNode() path = node.metadata('input/filename') spliteado = (os.path.splitext( os.path.basename(path))[0]).split("_") killframes = spliteado.pop() newfilename = ("_").join(spliteado) sticky = nuke.nodes.StickyNote( label='#########' + newfilename + '#########' + '\n' + (', ' '\n'.join(info)), note_font_size=80, ) nuke.show(sticky) nuke.zoom(0.5, [sticky.xpos(), sticky.ypos()]) else: nuke.message("please select a shuffle node")
def activePointsTo3D(): # Make a list of all PointsTo3D pt3_nodes = [] active_viewer = nuke.activeViewer().activeInput() # Use opened panel to determine which PointsTo3D to affect for name in nuke.openPanels(): node = nuke.toNode(name) if node.Class() == "PointsTo3D": pt3_nodes.append(node) # If there's no PointsTo3D properties open, check if viewer is looking at one if len(pt3_nodes) == 0: node = nuke.activeViewer().node().input(active_viewer) if node.Class() == "PointsTo3D": node.showControlPanel() pt3_nodes.append(node) # If there's still no eligible PointsTo3D, check selected nodes if len(pt3_nodes) == 0: for node in nuke.selectedNodes(): if node.Class() == "PointsTo3D": node.showControlPanel() pt3_nodes.append(node) # At this point we're just gonna make one if len(pt3_nodes) == 0: node = nuke.nodes.PointsTo3D() node.setInput(0, nuke.activeViewer().node().input(active_viewer)) node.showControlPanel() nuke.zoom(3, [node.xpos(), node.ypos()]) pt3_nodes.append(node) # Return the PointsTo3D nodes list return pt3_nodes
def reset(self): """Reset field.""" for unit in self._units: unit.reset() # Zoom on the field nuke.zoom(0)
def jump_to_the_edge_node(place): print(place) edge_node = get_edge_node(place) if edge_node is None: return nuke.zoom(1, (float(edge_node.xpos()), float(edge_node.ypos())))
def process(self, context, plugin): # Get the errored instances failed = [] for result in context.data["results"]: if (result["error"] is not None and result["instance"] is not None and result["instance"] not in failed): failed.append(result["instance"]) # Apply pyblish.logic to get the instances for the plug-in instances = pyblish.api.instances_by_plugin(failed, plugin) all_xC = list() all_yC = list() # maintain selection with anlib.maintained_selection(): # collect all failed nodes xpos and ypos for instance in instances: bdn = instance[0] xC = bdn.xpos() + bdn.screenWidth() / 2 yC = bdn.ypos() + bdn.screenHeight() / 2 all_xC.append(xC) all_yC.append(yC) self.log.info("all_xC: `{}`".format(all_xC)) self.log.info("all_yC: `{}`".format(all_yC)) # zoom to nodes in node graph nuke.zoom(2, [min(all_xC), min(all_yC)])
def jump_to_edge_node(which): # print "jump to edge node: {}".format(get_edge_node(which).name()) edge_node = get_edge_node(which) if edge_node is None: return nuke.zoom(1, [float(edge_node.xpos()), float(edge_node.ypos())])
def centerOnTarget(selNode): for node in nuke.selectedNodes(): node['selected'].setValue(0) selNode['selected'].setValue(True) x = selNode['xpos'].value() y = selNode['ypos'].value() nuke.zoom(1, (x, y)) selNode['selected'].setValue(False)
def zoom(direction, factor=0.5): z = nuke.zoom() value = z * factor if direction == '+': v = z + value elif direction == '-': v = z - value nuke.zoom(v, nuke.center())
def center_selected_node(self): selected_cell = QtWidgets.QTableWidget.selectedItems(self.read_files_list) selected_cell_text = selected_cell[0].text() selected_node = nuke.toNode(selected_cell_text) if selected_node != None: nuke.zoom(2, [float(selected_node.xpos()), float(selected_node.ypos())]) else: nuke.message('Please select a NODE name.')
def update(self): nuke.selectAll() nuke.invertSelection() a.nodeList[self.things.currentRow()].knob('selected').setValue(True) node = nuke.selectedNode() xC = node.xpos() + node.screenWidth()/2 yC = node.ypos() + node.screenHeight()/2 nuke.zoom( 2, [ xC, yC ])
def update(self): nuke.selectAll() nuke.invertSelection() a.nodeList[self.things.currentRow()].knob('selected').setValue(True) node = nuke.selectedNode() xC = node.xpos() + node.screenWidth() / 2 yC = node.ypos() + node.screenHeight() / 2 nuke.zoom(2, [xC, yC])
def wiredZoomAnchor(): n = nuke.thisNode() if n.inputs(): ni = n.input(0) nuke.zoom(nuke.zoom(), [ ni.xpos() + ni.screenWidth() / 2, ni.ypos() + ni.screenHeight() / 2 ])
def editorEvent(self, event, model, option, index): """ :param event: :type event: QEvent :param model: :type model: NodeModel :param option: :type option: QStyleOptionViewItem :param index: :type index: QModelIndex :return: :rtype: bool """ idx = index.model().mapToSource(index) item = model.sourceModel().itemFromIndex(idx) row = item.get_parent_row() if event.type() != QMouseEvent.MouseButtonRelease: return False if type(row) == ClassRow: if event.button() == Qt.MouseButton.LeftButton: if item.get_header() == 'Disable': if 'disable' in row.get_node_rows()[0].get_node().knobs().keys(): # assuming if one child NodeRow has a disable knob # all child rows for that ClassRow do as well if item.checkState() == Qt.Checked: check_state = Qt.Unchecked else: check_state = Qt.Checked item.setCheckState(check_state) for node_row in row.get_node_rows(): node_row.get_item('Disable').setCheckState(check_state) node_row.get_node().knob('disable').setValue(check_state == Qt.Checked) return True elif type(row) == NodeRow: if event.button() == Qt.MouseButton.LeftButton: if item.get_header() == 'Node': node = item.get_parent_row().get_node() nuke.zoom(3, (node.xpos() + (node.screenWidth()/2), node.ypos() + (node.screenHeight()/2))) return True elif item.get_header() == 'Disable': if 'disable' in row.get_node().knobs().keys(): if item.checkState() == Qt.Checked: check_state = Qt.Unchecked else: check_state = Qt.Checked item.setCheckState(check_state) row.get_item('Disable').setCheckState(check_state) row.get_node().knob('disable').setValue(check_state == Qt.Checked) return True return False
def centerNodeInNodeGraph(node): try: xpos = node["xpos"].value() ypos = node["ypos"].value() factor = 1.0 nukescripts.clear_selection_recursive() node["selected"].setValue(True) nuke.zoom(factor, (xpos, ypos)) except: pass
def import_pictures(self, sequence_dir, sep): all_read_file = [read_node['file'].getValue() for read_node in nuke.allNodes('Read')] all_read_file = list(set(all_read_file)) start_frame, end_frame = self.get_frame_range(sequence_dir, sep) read_file_name = self.get_frame_profile(sequence_dir, sep) if read_file_name: read_file_name = read_file_name.replace('\\', '/') if all((start_frame, end_frame)) and read_file_name not in all_read_file: read_node = nuke.nodes.Read(file=read_file_name) self.fix_read_node(read_node, start_frame, end_frame) nuke.zoom(1, [read_node.xpos(), read_node.ypos()])
def go_node(self): # init the sender sender = self.sender() # get the node name nodeName = sender.property("nodeName") # point into the node node = nuke.toNode(nodeName) # get the xC and yC values xC = node.xpos() + node.screenWidth() / 2 yC = node.ypos() + node.screenHeight() / 2 # focus on the node (distance 2) nuke.zoom(2, [xC, yC])
def load_dag_pos(preset): # Load dag zoom and position from specified preset number viewer = nuke.activeViewer() if not viewer: nuke.message('Error: please create a viewer to store the dag positions on...') return viewer = viewer.node() if 'dagpos' not in viewer.knobs(): nuke.message('No preset positions created yet...') return dagpos_knob = viewer['dagpos'] dagpos_vals = dagpos_knob.getValue().split(':')[preset-1] zoom, xpos, ypos = dagpos_vals.split(',') nuke.zoom(float(zoom), [float(xpos), float(ypos)])
def jopsBookmarkRestore(index): zoomNameString = "jops_bookmark_"+str(index)+"_zoom" posNameString = "jops_bookmark_"+str(index)+"_pos" try: z = nuke.root()[zoomNameString] p = nuke.root()[posNameString] if z.enabled(): zoom = z.getValue() xpos = p.x() ypos = p.y() pos = [xpos, ypos] nuke.zoom(zoom, pos) except (SyntaxError, NameError): pass
def sb_loadDagPosition(num): ''' Read value from knob and focus DAG. ''' if num<1 or num>10: nuke.message("Currently support for position 1-10.") return try: dagKnob = nuke.root()["sb_dagPosition"] dagPosValues = dagKnob.value().split(";")[num-1] zoom, xpos, ypos = dagPosValues.split(",") nuke.zoom(float(zoom), [float(xpos), float(ypos)]) except Exception as e: nuke.message("sb DAGPosition couldn't load position values.\n\nERROR: {0}.".format(e))
def save_dag_pos(preset): # Save current dag zoom and position as a preset on the active viewer zoom = nuke.zoom() pos = nuke.center() viewer = nuke.activeViewer() if not viewer: nuke.message( 'Error: please create a viewer to store the dag positions on...') return else: viewer = viewer.node() if 'dagpos' not in viewer.knobs(): viewer.addKnob( nuke.String_Knob( 'dagpos', 'dagpos', '0,0,0:0,0,0:0,0,0:0,0,0:0,0,0:0,0,0:0,0,0:0,0,0:0,0,0:0,0,0')) dagpos_knob = viewer['dagpos'] dagpos_knob.setFlag(nuke.STARTLINE) dagpos_knob.setEnabled(False) else: dagpos_knob = viewer['dagpos'] dagpos_vals = dagpos_knob.getValue().split(':') dagpos_vals.pop(preset - 1) new_dagpos = ','.join([str(zoom), str(pos[0]), str(pos[1])]) dagpos_vals.insert(preset - 1, new_dagpos) dagpos_knob.setValue(':'.join(dagpos_vals))
def cyclebookmarks(prt=False): '''Cycles between existent bookmarks''' global bookmarks if prt: print bookmarks if bookmarks is None: bookmarks = iter([ n for n in nuke.allNodes() if n['icon'].value() == 'bookmark.png' ]) if prt: print bookmarks try: n = bookmarks.next() n['selected'].setValue(True) if prt: print n['label'].value() except: bookmarks = iter([ n for n in nuke.allNodes() if n['icon'].value() == 'bookmark.png' ]) goTo = nuke.zoom(1, (n.xpos(), n.ypos()))
def zooomTo(item): ''' zooom to item ''' try: zooomLevel=item.split(",") zooomLevel[3] = zooomLevel[3].replace("\n", "") nuke.zoom(float(zooomLevel[1]), [float(zooomLevel[2]), float(zooomLevel[3])]) print "zooom to %s" % zooomLevel[0] print zooomLevel[1] print zooomLevel[2] print zooomLevel[3] except Exception, e: pass
def wiredZoomNext(anchor_name=""): if anchor_name == "": anchor_name = nuke.thisNode().knob("anchor").value() anchor = nuke.toNode(anchor_name) showing_knob = anchor.knob("showing") showing_value = showing_knob.value() i = 0 for ni in nuke.allNodes("NoOp"): if ni.knob("identifier") and ni.knob("anchor"): if ni.knob("identifier").value() == "wired" and ni.knob( "anchor").value() == anchor_name: if i == showing_value: nuke.zoom(nuke.zoom(), [ni.xpos(), ni.ypos()]) showing_knob.setValue(i + 1) return i += 1 showing_knob.setValue(0) nuke.message("Couldn't find any more similar wired stamps.")
def zoomToNode(self): log("zoomToNode '%s'" % self.zoomTargetNode) if (not self.zoomTargetNode): return node = nuke.toNode(self.zoomTargetNode) if (not node): return x = node['xpos'].value() y = node['ypos'].value() log(" target x %g y %g" % (x, y)) if (abs(x) < 10000 and abs(y) < 10000): nuke.zoom(nuke.zoom(), [x, y]) self.zoomTargetNode = None
def zoomToNode (self) : log ("zoomToNode '%s'" % self.zoomTargetNode) if (not self.zoomTargetNode) : return node = nuke.toNode(self.zoomTargetNode) if (not node) : return x = node['xpos'].value() y = node['ypos'].value() log (" target x %g y %g" % (x, y)) if (abs(x) < 10000 and abs(y) < 10000) : nuke.zoom (nuke.zoom(), [x, y]) self.zoomTargetNode = None
def node_under_cursor(): dag_widget = get_DAG_widget() dag_center = QtCore.QPoint(*nuke.center()) cursor_pos = QtGui.QCursor().pos() dag_widget_center = QtCore.QPoint((dag_widget.size().width()/ 2), (dag_widget.size().height()/2) ) cursor_pos_in_dag = dag_widget.mapFromGlobal(cursor_pos) new_node_pos = ((cursor_pos_in_dag - dag_widget_center) / nuke.zoom() + dag_center) return list(new_node_pos.toTuple())
def singleClick(): global currentRow currentRow = widget.ui.nuke_write_table.currentRow() n = widget.ui.nuke_write_table.currentItem() nodename = widget.ui.nuke_write_table.item(currentRow, 1).text() print nodename deselect() nuke.toNode(nodename)['selected'].setValue(True) node = nuke.selectedNode() nuke.zoom(1, [node.xpos(), node.ypos()]) nuke.show(node) if widget.ui.nuke_write_table.currentColumn() == 0: disable = QtGui.QTableWidgetItem() if n.text() == "on": disable.setIcon(nukecrossicon) disable.setText("off") nuke.toNode(nodename)['disable'].setValue(True) elif n.text() == "off": disable.setIcon(nukecheckicon) disable.setText("on") nuke.toNode(nodename)['disable'].setValue(False) widget.ui.nuke_write_table.setItem(currentRow, 0, disable) elif widget.ui.nuke_write_table.currentColumn() == 1: global previousName previousName = widget.ui.nuke_write_table.currentItem().text() elif widget.ui.nuke_write_table.currentColumn() == 2: filename = widget.ui.job_name.text() pathname = widget.ui.image_folder.text() nodepath = pathname + "/" + nodename nodepath = nodepath.replace("/", "\\") if os.path.isdir(nodepath) is False: os.makedirs(nodepath)
def run(self): # Store the current dag size and zoom original_zoom = nuke.zoom() original_center = nuke.center() # Calculate the total size of the DAG min_x, min_y, max_x, max_y = self.bbox zoom = self.zoom min_x -= int(self.margins / zoom) min_y -= int(self.margins / zoom) max_x += int(self.margins / zoom) max_y += int(self.margins / zoom) # Get the Dag Widget dag = self.dag # Check the size of the current widget, excluding the right side (because of minimap) capture_width = dag.width() - self.ignore_right capture_height = dag.height() # Calculate the number of tiles required to cover all image_width = int((max_x - min_x) * zoom) image_height = int((max_y - min_y) * zoom) horizontal_tiles = int(ceil(image_width / float(capture_width))) vertical_tiles = int(ceil(image_height / float(capture_height))) # Create a pixmap to store the results pixmap = QtGui.QPixmap(image_width, image_height) painter = QtGui.QPainter(pixmap) painter.setCompositionMode(painter.CompositionMode_SourceOver) # Move the dag so that the top left corner is in the top left corner, screenshot, paste in the pixmap, repeat for tile_x in range(horizontal_tiles): center_x = (min_x + capture_width / zoom * tile_x ) + (capture_width + self.ignore_right) / zoom / 2 for tile_y in range(vertical_tiles): center_y = (min_y + capture_height / zoom * tile_y) + capture_height / zoom / 2 nuke.executeInMainThread(nuke.zoom, (zoom, (center_x, center_y))) time.sleep(self.delay) nuke.executeInMainThread(grab_dag, (dag, painter, capture_width * tile_x, capture_height * tile_y)) time.sleep(self.delay) painter.end() nuke.executeInMainThread(nuke.zoom, (original_zoom, original_center)) save_sucessful = pixmap.save(self.path) if not save_sucessful: raise IOError("Failed to save PNG: %s" % self.path) self.successful = True
def sb_saveDagPosition(num): ''' Save DAG position in a text knob (Root node).''' if num<1 or num>10: nuke.message("Currently support for position 1-10.") return try: n = nuke.selectedNodes()[0] except IndexError: nuke.message("Select a node.") return zoom = nuke.zoom() xpos = n["xpos"].value() ypos = n["ypos"].value() try: dagKnob = nuke.root()["sb_dagPosition"] except NameError: conf = nuke.ask("sb DAGPosition needs to save position data in the Root node. Click Yes to continue.\n\nNote: This dialog will only pop up the first time you save a position.") if not conf: return dagKnob = nuke.String_Knob("sb_dagPosition", "sb DAGPosition") nuke.root().addKnob(dagKnob) dagKnob.setValue("0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0;0,0,0") dagKnob.setFlag(nuke.STARTLINE) dagKnob.setEnabled(False) nuke.root()["name"].setFlag(0) try: dagValues = dagKnob.value().split(";") dagValues.pop(num-1) newVal = ",".join( [str(zoom), str(xpos), str(ypos)] ) dagValues.insert(num-1, newVal) dagKnob.setValue(";".join(dagValues)) except Exception as e: nuke.message("sb DAGPosition couldn't save position values.\n\nERROR: {0}.".format(e)) return False
def cyclebookmarks( prt=False ): '''Cycles between existent bookmarks''' global bookmarks if prt: print bookmarks if bookmarks is None: bookmarks = iter([n for n in nuke.allNodes() if n['icon'].value() == 'bookmark.png']) if prt: print bookmarks try: n = bookmarks.next() n['selected'].setValue( True ) if prt: print n['label'].value() except: bookmarks = iter([n for n in nuke.allNodes() if n['icon'].value() == 'bookmark.png']) goTo = nuke.zoom(1,(n.xpos(),n.ypos()))
def registerPos(description): ''' write item into nuke.ZOOOMDATA item must be next to last item which is the keyword for ending zooomdata ''' description=description.replace(" ", "_") if description !="": x = nuke.center()[0] y = nuke.center()[1] zooom = nuke.zoom() #format new zooomItem for nuke.ZOOOMDATA newZooomItem = "#"+description+",%d" % zooom +",%d" % x+",%d"% y +"\n" #create start and end if not set yet if len(nuke.ZOOOMDATA)==0: nuke.ZOOOMDATA.append(zooomStart+"\n") nuke.ZOOOMDATA.append(zooomEnd) nuke.ZOOOMDATA.insert( (len(nuke.ZOOOMDATA)-1), newZooomItem) else: pass
def quickSave(slot): z = nuke.zoom() x = nuke.center()[0] y = nuke.center()[1] quickSaves[slot] = [z, x, y]
def knobChanged( self, knob ): #update if knob.name()=="update": #reset for btn in nuke.errors_footageBtn: self.removeKnob(btn) nuke.errors_footageBtn=[] errors=[] nuke.errors_nodes=[] nuke.errors_missingFrames=[] with nuke.root(): all = nuke.allNodes() for n in all: if n.Class()!="Read": if n.hasError(): errors.append(n.name()) if n not in nuke.errors_nodes: nuke.errors_nodes.append(n) else: for frame in range(int(n["first"].getValue()), int(n["last"].getValue())+1): try: f = nukescripts.replaceHashes(n['file'].value() ) % (frame) except: f = "" if not os.path.isfile(f): errors.append(f) if f not in nuke.errors_missingFrames: nuke.errors_missingFrames.append(f) if n not in nuke.errors_nodes: nuke.errors_nodes.append(n) for errorNode in nuke.errors_nodes: self.en = nuke.PyScript_Knob(errorNode.name(), errorNode.name()) self.addKnob(self.en) nuke.errors_footageBtn.append(self.en) nuke.errors_lenErrors=len(errors) if nuke.errors_lenErrors==0: col="green" else: col="red" countErrors = '<span style="color:{col}">{countErr}</span>'.format(col=col, countErr=nuke.errors_lenErrors) self.errorCount.setValue(countErrors) #write if knob.name()=="write": if self.outputPath.getValue()!="": try: script = os.path.basename(nuke.root().name()) output= os.path.dirname(self.outputPath.getValue()) + "/errorReport_%s" % script.replace(".nk",".txt") errorOutput = open(output,'w') date = time.strftime("%d-%m-%Y %H:%M:%S", time.gmtime()) header="error report \nscript name: {scriptname}\nscript path: {scriptPath}\ndate: {date}\nnumber of errors: {countErrors}\n------------------------------".format(scriptname=script, scriptPath=nuke.root().name(), date=date, countErrors=nuke.errors_lenErrors) errorOutput.write(header) #all read nodes errorOutput.write("\nread nodes\n\n") for n in nuke.errors_nodes: if n.Class()=="Read": errorOutput.write("read node: %s\n" % n.name()) #all missing frames errorOutput.write("\n----------\nmissing frames\n\n") for f in nuke.errors_missingFrames: errorOutput.write("missing frame: %s\n" % f) #all other nodes errorOutput.write("\n----------\nother nodes\n\n") for n in nuke.errors_nodes: if n.Class()!="Read": errorOutput.write("node: %s\n" % n.name()) nuke.message("successfully written error report to:\n\n%s" % output) except: nuke.message("some error occured. The report could not be written.") else: nuke.message("Please enter a output path for the error report.") #all other error nodes else: allNodes=nuke.allNodes() pKnob=knob.name() for n in allNodes: if n.name() == pKnob: nuke.zoom( 1, [ n.xpos(), n.ypos() ]) nukescripts.clear_selection_recursive() n.setSelected(True)
def quickRestore(slot): try: nuke.zoom(quickSaves[slot][0], [quickSaves[slot][1], quickSaves[slot][2]]) except: return
def createNukeCornerPinNode(coordinatesArray): global frameHeight global frameOffset cornerPinNode = nuke.nodes.CornerPin2D(label='imported_Mocha-AE_Track') cornerPinNode['enable1'].setValue('true') cornerPinNode['enable2'].setValue('true') cornerPinNode['enable3'].setValue('true') cornerPinNode['enable4'].setValue('true') # LOWER LEFT track1 = cornerPinNode['to1'] track1.setAnimated() track1keysX = [] track1keysY = [] for j in coordinatesArray[0]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track1keysX.append((tFrame, tX)) track1keysY.append((tFrame, tY)) #print "track1keysX: %s" % len(track1keysX) #print "track1keysY: %s" % len(track1keysY) # LOWER RIGHT track2 = cornerPinNode['to2'] track2.setAnimated() track2keysX = [] track2keysY = [] for j in coordinatesArray[1]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track2keysX.append((tFrame, tX)) track2keysY.append((tFrame, tY)) #print "track2keysX: %s" % len(track1keysX) #print "track2keysY: %s" % len(track1keysY) # UPPER RIGHT track3 = cornerPinNode['to3'] track3.setAnimated() track3keysX = [] track3keysY = [] for j in coordinatesArray[3]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track3keysX.append((tFrame, tX)) track3keysY.append((tFrame, tY)) #print "track3keysX: %s" % len(track3keysX) #print "track3keysY: %s" % len(track3keysY) # UPPER LEFT track4 = cornerPinNode['to4'] track4.setAnimated() track4keysX = [] track4keysY = [] for j in coordinatesArray[2]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track4keysX.append((tFrame, tX)) track4keysY.append((tFrame, tY)) #print "track4keysX: %s" % len(track4keysX) #print "track4keysY: %s" % len(track4keysY) track1animX = track1.animation(0) track1animX.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track1keysX]) track1animY = track1.animation(1) track1animY.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track1keysY]) track2animX = track2.animation(0) track2animX.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track2keysX]) track2animY = track2.animation(1) track2animY.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track2keysY]) track3animX = track3.animation(0) track3animX.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track3keysX]) track3animY = track3.animation(1) track3animY.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track3keysY]) track4animX = track4.animation(0) track4animX.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track4keysX]) track4animY = track4.animation(1) track4animY.addKey( [nuke.AnimationKey(frame, value) for (frame, value) in track4keysY]) nuke.show(cornerPinNode) nuke.zoom(1, (cornerPinNode.xpos(), cornerPinNode.ypos())) return
def createNukeCornerPinNode(coordinatesArray): global frameHeight global frameOffset cornerPinNode = nuke.nodes.CornerPin2D(label='imported_Mocha-AE_Track') cornerPinNode['enable1'].setValue('true') cornerPinNode['enable2'].setValue('true') cornerPinNode['enable3'].setValue('true') cornerPinNode['enable4'].setValue('true') # LOWER LEFT track1 = cornerPinNode['to1'] track1.setAnimated() track1keysX = [] track1keysY = [] for j in coordinatesArray[0]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track1keysX.append( (tFrame,tX) ) track1keysY.append( (tFrame,tY) ) #print "track1keysX: %s" % len(track1keysX) #print "track1keysY: %s" % len(track1keysY) # LOWER RIGHT track2 = cornerPinNode['to2'] track2.setAnimated() track2keysX = [] track2keysY = [] for j in coordinatesArray[1]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track2keysX.append( (tFrame,tX) ) track2keysY.append( (tFrame,tY) ) #print "track2keysX: %s" % len(track1keysX) #print "track2keysY: %s" % len(track1keysY) # UPPER RIGHT track3 = cornerPinNode['to3'] track3.setAnimated() track3keysX = [] track3keysY = [] for j in coordinatesArray[3]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track3keysX.append( (tFrame,tX) ) track3keysY.append( (tFrame,tY) ) #print "track3keysX: %s" % len(track3keysX) #print "track3keysY: %s" % len(track3keysY) # UPPER LEFT track4 = cornerPinNode['to4'] track4.setAnimated() track4keysX = [] track4keysY = [] for j in coordinatesArray[2]: tFrame = int(j[0]) + frameOffset tX = float(j[1]) tY = frameHeight - float(j[2]) track4keysX.append( (tFrame,tX) ) track4keysY.append( (tFrame,tY) ) #print "track4keysX: %s" % len(track4keysX) #print "track4keysY: %s" % len(track4keysY) track1animX = track1.animation(0) track1animX.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track1keysX]) track1animY = track1.animation(1) track1animY.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track1keysY]) track2animX = track2.animation(0) track2animX.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track2keysX]) track2animY = track2.animation(1) track2animY.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track2keysY]) track3animX = track3.animation(0) track3animX.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track3keysX]) track3animY = track3.animation(1) track3animY.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track3keysY]) track4animX = track4.animation(0) track4animX.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track4keysX]) track4animY = track4.animation(1) track4animY.addKey([nuke.AnimationKey(frame, value) for (frame,value) in track4keysY]) nuke.show(cornerPinNode) nuke.zoom(1, (cornerPinNode.xpos(), cornerPinNode.ypos() ) ) return
def jopsBookmarkSave(index, mode='dag'): tabNameString = "DAG_Bookmarks" try: nuke.root()[tabNameString] except (SyntaxError, NameError): nuke.root().addKnob(nuke.Tab_Knob(tabNameString)) for ind in range(1,10): zoomNameString = "jops_bookmark_"+str(ind)+"_zoom" posNameString = "jops_bookmark_"+str(ind)+"_pos" xyKnob = nuke.XY_Knob(posNameString, str(ind)) zoomKnob = nuke.Double_Knob(zoomNameString, "") zoomKnob.setFlag(nuke.NO_ANIMATION) zoomKnob.setFlag(nuke.DISABLED) xyKnob.setFlag(nuke.NO_ANIMATION) xyKnob.setFlag(nuke.DISABLED) zoomKnob.clearFlag(nuke.STARTLINE) nuke.root().addKnob(xyKnob) nuke.root().addKnob(zoomKnob) nuke.root().addKnob(nuke.Text_Knob("j_ops_bookmarks_note", "", "<i>DAG bookmarks are part of the J_Ops toolset available on Nukepedia</i>")) xpos = 0.0 ypos = 0.0 zoom = 0.0 selectedList = [] if mode == 'node': if nuke.selectedNodes(): xposList = [] yposList = [] for anode in nuke.selectedNodes(): xposList.append(anode["xpos"].getValue()) yposList.append(anode["ypos"].getValue()) xpos = sum(xposList, 0.0) / len(xposList) ypos = sum(yposList, 0.0) / len(yposList) else: return else: if nuke.selectedNodes(): for anode in nuke.selectedNodes(): selectedList.append(anode) anode["selected"].setValue(0.0) tempNode = nuke.createNode("Dot", inpanel=False) xpos = tempNode["xpos"].getValue() ypos = tempNode["ypos"].getValue() nuke.delete(tempNode) zoom = nuke.zoom() zoomNameString = "jops_bookmark_"+str(index)+"_zoom" posNameString = "jops_bookmark_"+str(index)+"_pos" nuke.root()[zoomNameString].clearFlag(nuke.DISABLED) nuke.root()[zoomNameString].setValue(zoom) nuke.root()[posNameString].clearFlag(nuke.DISABLED) nuke.root()[posNameString].setValue(xpos,0) nuke.root()[posNameString].setValue(ypos,1) if selectedList: for anode in selectedList: anode["selected"].setValue(1.0)