def __init__(self): super(DailiesSettingPanel, self).__init__('Dailies Setting') self.file_knob = nuke.File_Knob('source', 'image') self.source_list = nuke.Multiline_Eval_String_Knob( 'source_list', 'sources') self.source_list.setEnabled(False) self.remove_first = nuke.Int_Knob('remove_first', 'remove first line:') self.remove_last = nuke.Int_Knob('remove_last', 'remove last line:') self.remove_first.setValue(1) self.remove_last.setValue(1) self.remove_last.clearFlag(nuke.STARTLINE) self.remove_button = nuke.PyScript_Knob('remove', 'remove') self.message = nuke.Text_Knob('message', '', ' ') self.create_button = nuke.PyScript_Knob('create', 'create node tree') self.render_button = nuke.PyScript_Knob('render', 'render dailies') self.create_button.setFlag(nuke.STARTLINE) self.addKnob(self.file_knob) self.addKnob(self.source_list) self.addKnob(self.remove_first) self.addKnob(self.remove_last) self.addKnob(self.remove_button) self.addKnob(self.create_button) self.addKnob(self.render_button) self.addKnob(self.message) self.sources = {} self.render_infos = {} self.control_funcs = {} self.bypass_callback = False
def __init__(self): nukescripts.PythonPanel.__init__(self,"b_procedural_backdrop") #CREATE KNOBS self.note_size = nuke.Int_Knob("Note Size:") self.note_size.clearFlag(nuke.STARTLINE) self.frame_display = nuke.String_Knob("Label:") self.frame_display.clearFlag(nuke.STARTLINE) self.align = nuke.Enumeration_Knob("Align", "Align", ["left","center","right"]) self.color = nuke.Enumeration_Knob("Color", "Color", ["green","pink","dark","yellow","grey","random"]) self.color.clearFlag(nuke.STARTLINE) self.axis = nuke.Enumeration_Knob("Axis", "Axis", ["horizontal","vertical"]) self.multi = nuke.Text_Knob("Multi") self.axis.clearFlag(nuke.STARTLINE) self.amount = nuke.Int_Knob("Amount:") self.note_size.clearFlag(nuke.STARTLINE) self.spacing = nuke.Int_Knob("Spacing:") self.spacing.clearFlag(nuke.STARTLINE) self.author = nuke.Text_Knob("by Boris Martinez") #SET DEFAULTS self.set_note_size_default_value() self.spacing_default_value() #ADD KNOBS for i in (self.note_size , self.frame_display,self.align,self.color,self.multi,self.amount,self.axis,self.spacing,self.author): self.addKnob(i)
def __setup_knobs(self): self.__output_path_knob = nuke.File_Knob('output_path', 'Output Path') self.addKnob(self.__output_path_knob) self.__file_formats_knob = nuke.Enumeration_Knob('format', 'Format', ['png', 'jpg']) self.addKnob(self.__file_formats_knob) self.__start_frame_knob = nuke.Int_Knob('start_frame', 'Start Frame') self.addKnob(self.__start_frame_knob) self.__end_frame_knob = nuke.Int_Knob('end_frame', 'End Frame') self.addKnob(self.__end_frame_knob) self.__output_channels_knob = nuke.Channel_Knob('output_channels', 'Output Channels') self.__output_channels_knob.setFlag(nuke.ENDLINE) self.__output_channels_knob.setValue('rgba') self.addKnob(self.__output_channels_knob) self.__use_proxy_knob = nuke.Boolean_Knob('use_proxy', 'Use Proxy') self.__use_proxy_knob.setFlag(nuke.ENDLINE) self.addKnob(self.__use_proxy_knob) self.__render_button_knob = nuke.PyScript_Knob('render', 'Render') self.__render_button_knob.setFlag(nuke.STARTLINE) self.addKnob(self.__render_button_knob) self.addKnob(nuke.Text_Knob('copyright', 'www.ngreen.org'))
def addrangetab(): """Get the selected nodes in the DAG""" selnodes = nuke.selectedNodes() for i in selnodes: """Retrives node Class and the Root range""" _class = i.Class() _first = int(nuke.root().knob("first_frame").value()) _last = int(nuke.root().knob("last_frame").value()) """Set Knobs parameters""" rTab = nuke.Tab_Knob("rangetab", "Range") rIn = nuke.Int_Knob("range_in", "In") rOut = nuke.Int_Knob("range_out", "Out") rSetIn = nuke.Script_Knob("set_in", "Use Current", "knob this.range_in [frame]") rSetOut =nuke.Script_Knob("set_out", "Use Current", "knob this.range_out [frame]") rUse = nuke.Script_Knob("set_range", "Set Range", "in this.disable {set_expression {frame<this.range_in || frame>this.range_out}}") rTab = nuke.Tab_Knob("rangetab", "Range") """Adds Knobs to each node""" i.addKnob(rTab) i.addKnob(rIn) i.addKnob(rSetIn) i.addKnob(rOut) i.addKnob(rSetOut) i.addKnob(rUse) """Set default range values""" v = i['range_in'] v.setValue(_first) v = i['range_out'] v.setValue(_last)
def Interval_frame_read_zwz(): a = nukescripts.PythonPanel('Interval_frame_Read') a.addKnob( nuke.Text_Knob( 'Expression: (frame-X)*Y+X\nIf x and y values for empty return null!' )) a.addKnob(nuke.Int_Knob('X:')) a.addKnob(nuke.Int_Knob('Y:')) finishedDialog = a.showModalDialog() oldfilepath = int(a.knobs()['X:'].getValue()) newfilepath = int(a.knobs()['Y:'].getValue()) nuke.selectAll() AllNode = nuke.selectedNodes() for donode in AllNode: donode.setSelected(0) if oldfilepath and newfilepath: for donode in AllNode: if donode.Class() == 'Read': donode.knob('frame').setValue( '(frame-%s)*%s+%s' % (oldfilepath, newfilepath, oldfilepath)) else: for donode in AllNode: if donode.Class() == 'Read': donode.knob('frame').setValue('')
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Merge Transforms') # CREATE KNOBS self.first = nuke.Int_Knob('first', 'First Frame') self.first.setValue(int(nuke.root()['first_frame'].value())) self.last = nuke.Int_Knob('last', 'Last Frame') self.last.setValue(int(nuke.root()['last_frame'].value())) self.forceCP = nuke.Boolean_Knob('force_cp', 'Force Merge as CornerPin') self.forceCP.setFlag(nuke.STARTLINE) self.forceCP.setTooltip( 'Tool will merge transforms a a new Transform if possible, or Cornerpin if necessary.' '\nChecking this box will force a corner pin output') self.forceMatrix = nuke.Boolean_Knob('force_matrix', 'CornerPin as extra_matrix') self.forceMatrix.setTooltip( "Uses the cornerpin's extra_matrix to recreate the transform rather than the corners" ) self.forceMatrix.setEnabled(False) self.forceMatrix.setFlag(nuke.STARTLINE) # ADD KNOBS for k in (self.first, self.last, self.forceCP, self.forceMatrix): self.addKnob(k)
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) plugin = plugin() for instance in instances: node = instance[0] node.addKnob(nuke.Tab_Knob("Deadline")) knob = nuke.Int_Knob("deadlineChunkSize", "Chunk Size") knob.setValue(1) node.addKnob(knob) knob = nuke.Int_Knob("deadlinePriority", "Priority") knob.setValue(50) node.addKnob(knob) knob = nuke.String_Knob("deadlinePool", "Pool") node.addKnob(knob) knob = nuke.String_Knob("deadlineLimits", "Limits") node.addKnob(knob) knob = nuke.Int_Knob("deadlineConcurrentTasks", "Concurrent Tasks") knob.setValue(1) node.addKnob(knob)
def __init__(self): nukescripts.PythonPanel.__init__(self, "GQ_Tools") ## KNOBS ## # Node Disable # self.classInput = nuke.String_Knob("classInput", "Type") self.classSelect = nuke.PyScript_Knob('classSelect', 'Select Type') self.enableAll = nuke.PyScript_Knob("enableAll", "Enable All") self.enableAll.setFlag(nuke.STARTLINE) self.disableHeavy = nuke.PyScript_Knob("disableHeavy", "Disable Heavy") self.disableDivider = nuke.Text_Knob("") # Read Properties # self.readBefore = nuke.Enumeration_Knob( 'readBefore', "Before", ['hold', "loop", "bounce", "black"]) self.readAfter = nuke.Enumeration_Knob( 'readAfter', "Before", ['hold', "loop", "bounce", "black"]) self.readAfter.clearFlag(nuke.STARTLINE) self.setBeforeAfter = nuke.PyScript_Knob("setBeforeAfter", "Set Before + After") self.readStart = nuke.Int_Knob('readStart', "Start", 100) self.readEnd = nuke.Int_Knob('readEnd', "End", 200) self.readEnd.clearFlag(nuke.STARTLINE) self.setStartEnd = nuke.PyScript_Knob("setStartEnd", "Set Start + End") self.startAt = nuke.Int_Knob('startAt', "Start At") self.setStartAt = nuke.PyScript_Knob("setStartAt", "Set Start At") self.readDivider = nuke.Text_Knob("") ## LAYOUT ## # Node Disable # self.addKnob(self.classInput) self.addKnob(self.classSelect) self.addKnob(self.enableAll) self.addKnob(self.disableHeavy) self.addKnob(self.disableDivider) # Read Properties # self.addKnob(self.readBefore) self.addKnob(self.readAfter) self.addKnob(self.setBeforeAfter) self.addKnob(self.readStart) self.addKnob(self.readEnd) self.addKnob(self.setStartEnd) self.addKnob(self.startAt) self.addKnob(self.setStartAt) self.readStart.setValue(int(nuke.Root()['first_frame'].getValue())) self.readEnd.setValue(int(nuke.Root()['last_frame'].getValue()))
def forEach(): forbidden = ['RotoPaint', 'Roto'] for n in nuke.selectedNodes(): feMsg = 'Nodes from type ' + n.Class( ) + ' are not supported yet. Please remove them from the selection before creating the ForEach node.' if n.Class() in forbidden: nuke.message(feMsg) return False feGroup = nuke.collapseToGroup() feGroup.setName("forEach") for n in feGroup.nodes(): n.setSelected(False) nuke.allNodes("Input", feGroup)[0].setSelected(True) feTab = feGroup.addKnob(nuke.Tab_Knob("forEach")) feGroup.addKnob(nuke.Int_Knob("n_inputs", "number of inputs")) feGroup.addKnob(nuke.Boolean_Knob("manual", "manual loop")) feGroup.addKnob(nuke.Int_Knob("init", "from:")) feGroup.addKnob(nuke.Int_Knob("end", "to:")) feGroup['n_inputs'].setValue(1) feGroup['n_inputs'].setTooltip( "determines the number of inputs (arrows) the node has got.") feGroup["manual"].setTooltip( "If in manual mode forEach will run from init to end.") feGroup["init"].setTooltip( "The init value of the loop. In pseudocode, this would correspond to for(i=init; i<=end; i++)" ) feGroup["end"].setTooltip( "The end value of the loop. In pseudocode, this would correspond to for(i=init; i<=end; i++)" ) feGroup["end"].setValue(10) feGroup["manual"].setFlag(nuke.STARTLINE) feGroup["init"].clearFlag(nuke.STARTLINE) feGroup["init"].setEnabled(False) feGroup["end"].clearFlag(nuke.STARTLINE) feGroup["end"].setEnabled(False) feGroup.knob("knobChanged").setValue( "with nuke.thisNode():\n knob = nuke.thisKnob();\n if(knob.name() == 'n_inputs'):\n n_inps = len(nuke.allNodes('Input'));\n n_knob = int(float(knob.value()))-1;\n\n if n_knob != n_inps:\n for i in range(n_inps-1, n_knob, cmp(n_knob, n_inps)):\n if(n_inps < n_knob):\n nuke.nodes.Input();\n elif n_knob > -1:\n nuke.delete(nuke.allNodes('Input')[0]);\n elif(knob.name() == 'manual'):\n nuke.thisNode()['init'].setEnabled(knob.value());\n nuke.thisNode()['end'].setEnabled(knob.value());" ) feGroup.addKnob(nuke.PyScript_Knob("run_btn", "explode loop")) feGroup['run_btn'].setTooltip( "transforms the forEach group into clones created by the loop.") feGroup['run_btn'].setCommand( "from types import *\n\ndef is_numeric(n):\n try: \n float(n);\n return True;\n except TypeError:\n return False;\n\nfeGroup = nuke.thisNode();\nfePadding = feGroup.knob('padd').getValue();\nfeCY = int(feGroup.ypos() + feGroup.screenHeight()/2);\nfeCX = int(feGroup.xpos() + feGroup.screenWidth()/2);\nfeW = 0; feH = 0;\nfe_horiz = (feGroup.knob('layout').value() == 'horizontal');\n\nfe_manual = feGroup['manual'].value();\n\nfeInputs_num = feGroup.inputs() if not fe_manual else (int(feGroup['end'].value()) - int(feGroup['init'].value()));\nfeInputs = feGroup.dependencies();\nfeInputs.sort(lambda a,b: cmp(a.xpos() if fe_horiz else a.ypos(), b.xpos() if fe_horiz else b.ypos()));\n\nif fe_manual: feInputs += [fakeInp for fakeInp in xrange(feInputs_num - len(feInputs))];\n\n#expand group:\nfeGroup = feGroup.expand();\n\n#create a clone for every input\nfor i, feInput in enumerate(feInputs):\n if i>0: nuke.cloneSelected();\n\n feGroup = nuke.selectedNodes();\n\n feEach = nuke.nodes.NoOp();\n feEach.setName('each');\n \n feI = nuke.String_Knob('i', 'instance #');\n feEach.addKnob(feI);\n feI.setValue(str(i));\n feI.setTooltip('Use [python {forEach_i()}] inside an expression of a node created by the forEach node to access the iterator of the for loop (i). For this to work you need to keep the each-nodes.');\n feI.setEnabled(False);\n \n # find first node:\n for feC in feGroup:\n if feC.isSelected():\n feClone = feC;\n else:\n break;\n \n if feClone.maxInputs > 0: feClone.setInput(0, feEach);\n\n if not fe_manual or not is_numeric(feInput): feEach.setInput(0, feInput);\n if fe_horiz: \n feEach.setYpos(feCY);\n else:\n feEach.setXpos(feCX);\n\n feEach.setSelected(True);\n feGroup = nuke.selectedNodes();\n \n for j,node in enumerate(feGroup): #walk thru all nodes within & position\n if fe_horiz:\n feW = max(feW, node.screenWidth() + fePadding);\n else:\n feH = max(feH, node.screenHeight() + fePadding);\n\n if fe_horiz: \n node.setXpos(int(feCX - feW * (feInputs_num/2) + feW * i));\n else: \n node.setYpos(int(feCY - feH * (feInputs_num/2) + feH * i));\n feEach.setYpos(feClone.ypos()-feClone.screenHeight()-feEach.screenHeight()-40);\n feEach.setSelected(False);\n\n#clean up\nnuke.selectAll();\nnuke.invertSelection();\n\n#i-function\ndef forEach_i():\n n = nuke.thisNode();\n if n.name() != 'Root':\n while (n.Class() != 'NoOp' or not n.name().startswith('each')) and len(n.dependencies()) > 0:\n n = n.dependencies()[0];\n return int(n['i'].value()) if n.knob('i') != None else -1;\n else:\n return -1;" ) feGroup['run_btn'].setFlag(nuke.STARTLINE) feGroup.addKnob(nuke.Tab_Knob("display", "display options")) feGroup.addKnob( nuke.Enumeration_Knob("layout", "preferred layout", ["horizontal", "vertical"])) feGroup.addKnob(nuke.Double_Knob("padd", "padding")) feGroup['padd'].setTooltip("determines the space between branches.") feGroup['padd'].setValue(300) return True
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Corner Pin To Matrix') # ANALYZE NUKE SCRIPT TO GATHER VALUES camera_nodes = [] nodes_with_matrix = [] for node in nuke.allNodes(): if 'Camera' in node.Class(): camera_nodes.append(node.name()) elif node.Class() in ['Transform', 'CornerPin2D', 'Tracker4', 'Card2', 'Card3D']: nodes_with_matrix.append(node.name()) camera_nodes.sort() nodes_with_matrix.sort() try: node = nuke.selectedNode() except ValueError: node = None # CREATE KNOBS self.first = nuke.Int_Knob('first', 'First Frame') self.first.setValue(int(nuke.root()['first_frame'].value())) self.last = nuke.Int_Knob('last', 'Last Frame') self.last.setValue(int(nuke.root()['last_frame'].value())) self.last.clearFlag(nuke.STARTLINE) self.node = nuke.Enumeration_Knob('original_node', 'Node to Convert', nodes_with_matrix) if node and node.name() in nodes_with_matrix: self.node.setValue(node.name()) self.camera = nuke.Enumeration_Knob('camera_node', 'Camera', camera_nodes) # In cases where no node was selected in the first place, the current node is the first entry in the list node = nuke.toNode(self.node.value()) if not node or node.Class() not in ['Card2', 'Card3D']: self.camera.setVisible(False) options = ['Roto', 'RotoPaint', 'CornerPin', 'CornerPin (Matrix only)', 'Transform (No Perspective)', 'Tracker', 'SplineWarp'] self.destination = nuke.Enumeration_Knob('target', 'Convert to', options) self.force_ref = nuke.Boolean_Knob('force_reference', '') self.force_ref.setTooltip("Forces the resulting node to leave the reference frame untouched") self.force_ref.setFlag(nuke.STARTLINE) self.reference = nuke.Int_Knob('reference', 'Reference Frame') self.reference.clearFlag(nuke.STARTLINE) self.reference.setEnabled(False) self.reference.setValue(nuke.frame()) self.invert = nuke.Boolean_Knob('invert', 'Invert Matrix') # ADD KNOBS for k in (self.first, self.last, self.node, self.camera, self.destination, self.force_ref, self.reference, self.invert): self.addKnob(k)
def createJobSystemTab(node): #### create knobs tabKnob = nuke.Tab_Knob('JobSystem') jobKnob = nuke.EvalString_Knob('job') shotKnob = nuke.EvalString_Knob('shot') versionKnob = nuke.Int_Knob('version') takeKnob = nuke.Int_Knob('take') labelKnob = nuke.EvalString_Knob('usr_label', 'label') extKnob = nuke.EvalString_Knob('ext') buttonKnob = nuke.PyScript_Knob('Create Ouptut') #### set some defaults for the knobs jobKnob.setValue(os.environ.get('JOB')) shotKnob.setValue(os.environ.get('SHOT')) versionKnob.setValue(1) takeKnob.setValue(1) labelKnob.setValue('look') extKnob.setValue('exr') #### the python script to run when the user presses the 'Create dirs' button script = """ job = nuke.thisNode()['job'].value() shot = nuke.thisNode()['shot'].value() version = nuke.thisNode()['version'].value() take = nuke.thisNode()['take'].value() label = nuke.thisNode()['usr_label'].value() ext = nuke.thisNode()['ext'].value() user = os.environ.get('USER') #### build up the shot name shotName = '%s_v%02d_%s_%s' % (shot, int(version), user, label) #### grab base render directory from environment baseDir = os.environ.get('PIC') if baseDir == None: baseDir = '/tmp/MasterClass' fullPath = os.path.join(baseDir,shotName) try: os.makedirs(fullPath) nuke.message('Created dir %s' % fullPath) except OSError: nuke.message('WARNING: err creating dir %s' % dir) pass fileName = '%s.%s.%s' % (shotName, '%04d', ext) fname = os.path.join(baseDir,shotName,fileName) #### set the file knob to the new file name nuke.thisNode()['file'].setValue(fname) """ buttonKnob.setValue(script) #### add knobs to node for k in [tabKnob, jobKnob, shotKnob, versionKnob, takeKnob,labelKnob, buttonKnob, extKnob]: node.addKnob(k)
def __init__(self, initalStart, initialEnd): """Constructor that takes 2 arguments for the initial start and end frame numbers""" nukescripts.PythonPanel.__init__(self, "Set frame range", "uk.co.thefoundry.FramePanel") self.fromFrame = nuke.Int_Knob("fromFrame", "from:") self.addKnob(self.fromFrame) self.fromFrame.setValue(int(initalStart)) self.toFrame = nuke.Int_Knob("toFrame", "to:") self.addKnob(self.toFrame) self.toFrame.setValue(int(initialEnd))
def test_transfer_flags(self): from edit import transfer_flags all_flags = [pow(2, n) for n in range(31)] src = nuke.Int_Knob('src') dst = nuke.Int_Knob('dst') for i in all_flags: if random.randint(0, 1): src.setFlag(i) else: src.clearFlag(i) transfer_flags(src, dst) for i in all_flags: self.assertEqual(src.getFlag(i), dst.getFlag(i))
def ueReadAsset(node, cmd=None, name=None, inpanel=True): n = nuke.createNode(node, inpanel=inpanel) if name is not None: n.setName(name) if cmd == None: cmd = node n.addKnob( nuke.PyScript_Knob( "ueOpen" + cmd, " Browse Elements ", "import ueNuke.Open\nueNuke.Open.ueOpen" + cmd + "()")) n.addKnob(nuke.String_Knob("proj", "project")) n.addKnob(nuke.String_Knob("grp", "group")) n.addKnob(nuke.String_Knob("asst", "asset")) n.addKnob(nuke.String_Knob("elclass", "class")) n.addKnob(nuke.String_Knob("eltype", "type")) n.addKnob(nuke.String_Knob("elname", "name")) n.addKnob(nuke.Int_Knob("vers", "version")) n.addKnob(nuke.String_Knob("elpass", "pass")) n.knob("file").setValue("[python get" + cmd + "Path()]") n.knob("label").setValue("[value proj]:[value grp]:[value asst]\n"+\ "[value elname]:[value eltype]:[value elclass] v[value vers]") return n
def addCTGradeControl(): node = nuke.thisNode() tab = nuke.Tab_Knob('GradeControl') node.addKnob(tab) ref = nuke.Int_Knob('reference_frame', 'Reference Fame') frame = nuke.PyScript_Knob( 'set_frame', 'Set Current Frame', 'nuke.thisNode()["reference_frame"].setValue(nuke.frame())') node['label'].setValue('Ref [value reference_frame]') grade = nuke.PyScript_Knob( 'create_grade', 'Create Grade Node', ''' node = nuke.thisNode() node_name = nuke.thisNode()['name'].value() grade = nuke.createNode('Grade') grade['whitepoint'].setSingleValue(False) grade['white'].setSingleValue(False) grade['whitepoint'].setExpression('{0}.intensitydata.r({0}.reference_frame)'.format(node_name), channel=0) grade['whitepoint'].setExpression('{0}.intensitydata.g({0}.reference_frame)'.format(node_name), channel=1) grade['whitepoint'].setExpression('{0}.intensitydata.b({0}.reference_frame)'.format(node_name), channel=2) grade['whitepoint'].setExpression('{0}.intensitydata.a({0}.reference_frame)'.format(node_name), channel=3) grade['white'].setExpression('{0}.intensitydata.r'.format(node_name), channel=0) grade['white'].setExpression('{0}.intensitydata.g'.format(node_name), channel=1) grade['white'].setExpression('{0}.intensitydata.b'.format(node_name), channel=2) grade['white'].setExpression('{0}.intensitydata.a'.format(node_name), channel=3) ''') grade.setFlag(0x1000) node.addKnob(ref) node.addKnob(frame) node.addKnob(grade) node['reference_frame'].setValue(nuke.frame())
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Snapshotr', 'uk.co.thefoundry.ssPanel') if self.DEV > 0: print "\n* Debug mode ON" print "* rootDir inside ssPanel __init__ = " + self.rootDir print "* snapsDir inside ssPanel __init__ = " + self.snapsDir self.btn_snap_fullres = nuke.PyScript_Knob('Full') self.btn_snap_instant = nuke.PyScript_Knob('Instant') self.btn_open_webview = nuke.PyScript_Knob('Open') self.commentField = nuke.String_Knob('Comment:') self.divider = nuke.Text_Knob('') self.markNode = nuke.Boolean_Knob('Mark node ') self.timerValue = nuke.Int_Knob('Autosnap: ') self.addKnob(self.commentField) self.addKnob(self.btn_snap_instant) self.addKnob(self.btn_snap_fullres) self.addKnob(self.btn_open_webview) self.addKnob(self.timerValue) self.addKnob(self.divider) self.addKnob(self.markNode) self.timerValue.setValue(60) # 60 minutes by default scriptPath = nuke.toNode('root').knob('name').value() scriptName = scriptPath.split("/")[-1] if cmn.check_script(name=scriptName) is None: nuke.message( "Please save your script in the following format:\nshot.task.artist.v00.00.nk" ) raise BaseException def snapAutosave(): """ Create auto snapshot, start timer to trigger this (every 60min by default) """ try: c_var = cmn.init_common_vars(snapsDir=self.snapsDir) print "\n~ autosaving snapshot..." cmn.create_snapshot_dirs(rootDir=self.rootDir, snapsDir=self.snapsDir, snapPath=c_var["snapPath"], markNode=self.markNode) cmn.create_snapshot_script( scriptPath=c_var["scriptPath"], snapScriptName=c_var["snapScriptName"], upversion=False) cmn.create_snapshot_comment( snapCommentFile=c_var["snapCommentFile"], commentText="#autosnap") cmn.create_snapshot_screenshot( DEV=self.DEV, snapImageFile=c_var["snapImageFile"]) finally: timer = int(self.timerValue.value()) * 60000 QtCore.QTimer.singleShot(timer, snapAutosave) snapAutosave()
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Estimator', 'uk.co.thefoundry.estimatorPanel') self.runBtn = nuke.PyScript_Knob('Run') self.precisionValue = nuke.Int_Knob('Frames to calculate: ') self.divider = nuke.Text_Knob('') self.pathBool = nuke.Boolean_Knob('Show full path') self.disabledBool = nuke.Boolean_Knob('Estimate disabled nodes') self.sortedBool = nuke.Boolean_Knob('Sort by size') self.addKnob(self.precisionValue) self.addKnob(self.runBtn) self.addKnob(self.divider) self.addKnob(self.pathBool) self.addKnob(self.disabledBool) self.addKnob(self.sortedBool) self.precisionValue.setValue(10) self.disabledBool.setValue(1) self.prj_first_frame = int( nuke.toNode('root').knob('first_frame').value()) self.prj_last_frame = int( nuke.toNode('root').knob('last_frame').value()) self.prj_length = abs(self.prj_last_frame - self.prj_first_frame) global DEV DEV = 0
def __init__(self): '''RV Render UI''' log("RvRenderPanel init") nukescripts.PythonPanel.__init__(self, 'RvRenderPanel', 'com.tweaksoftware.RenderPanel') self.outputNode = nuke.String_Knob('outputNode', 'Output Node') self.outputNode.setValue("") self.addKnob(self.outputNode) self.useSelected = nuke.Boolean_Knob('useSelected', 'Use Selected') self.useSelected.setValue(True) self.addKnob(self.useSelected) minFrame = nuke.root().knob('first_frame').value() maxFrame = nuke.root().knob('last_frame').value() log(" minf %d maxf %d" % (minFrame, maxFrame)) n = nuke.toNode(self.outputNode.value()) log(" n %s" % n) if (n): minFrame = n.firstFrame() maxFrame = n.lastFrame() log(" minf %d maxf %d" % (minFrame, maxFrame)) # self.startFrame = nuke.Int_Knob ('firstFrame', '<img src=":qrc/images/FrameRangeLock.png">', self.__getRange() ) self.firstFrame = nuke.Int_Knob('firstFrame', 'First Frame') self.firstFrame.setTooltip('First frame of range to render') self.firstFrame.setValue(int(minFrame)) self.addKnob(self.firstFrame) self.lastFrame = nuke.Int_Knob('lastFrame', 'Last Frame') self.lastFrame.setTooltip('Last frame of range to render') self.lastFrame.setValue(int(maxFrame)) self.lastFrame.clearFlag(nuke.STARTLINE) self.addKnob(self.lastFrame) # Don't understand this, but nuke on windows complains if this knob is not present # self.frameRange = nuke.String_Knob('range', 'range') self.frameRange.setVisible(False) self.addKnob(self.frameRange) self.updateFromRoot() self.updateFromSelection()
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Merge Transforms') # CREATE KNOBS self.first = nuke.Int_Knob('first', 'First Frame') self.first.setValue(int(nuke.root()['first_frame'].value())) # ADD KNOBS self.addKnob(self.first)
def FromNuke2MayaExporter(): allSelectedNodes = nuke.selectedNodes() firstFrame = nuke.root().knob('first_frame').getValue() lastFrame = nuke.root().knob('last_frame').getValue() if len(allSelectedNodes) == 1: selectedNode = allSelectedNodes[0] selectedNodeType = selectedNode.Class() channelMatch = {'transform.tx':'translate:0', 'transform.ty':'translate:1', 'transform.tz':'translate:2', 'transform.rx':'rotate:0', 'transform.ry':'rotate:1', 'transform.rz':'rotate:2', 'transform.sx':'scaling:0', 'transform.sy':'scaling:1', 'transform.sz':'scaling:2', 'transform.rotateOrder':'rot_order', 'camera.fl':'focal', 'camera.horizontalFilmAperture':'haperture', 'camera.verticalFilmAperture':'vaperture'} objectTypeOk = ['Camera', 'Camera2'] cameraName = selectedNode.name() if selectedNodeType in objectTypeOk: exportPath = os.environ["HOME"].replace('\\', '/') + '/Desktop/' a = nukescripts.PythonPanel('File to Export') a.addKnob(nuke.Int_Knob('Start-Frame:')) a.knobs()['Start-Frame:'].setValue(int(firstFrame)) a.addKnob(nuke.Int_Knob('End-Frame:')) a.knobs()['End-Frame:'].setValue(int(lastFrame)) a.addKnob(nuke.File_Knob('Export-File:')) a.knobs()['Export-File:'].setValue(exportPath+cameraName + '.fm2n') finishedDialog = a.showModalDialog() startFrame = int(a.knobs()['Start-Frame:'].getValue()) lastFrame = int(a.knobs()['End-Frame:'].getValue()) filename = a.knobs()['Export-File:'].getValue() filename = filename.replace('\\', '/') filenameParts = filename.split('.') if filenameParts[len(filenameParts)-1] != 'fm2n': filename = filename + ".fm2n" exportData(selectedNode, channelMatch, firstFrame, lastFrame, filename) else: nuke.message("ERROR: The Node you have selected is not a Camera.") else: nuke.message("ERROR: You have more then one Node selected")
def _add_node_metadata(self, node, path, sg_publish_data): """ Bakes the additional metadata on the read node creating a SGTK tab on the node. This currently only stores fields that are in `additional_publish_fields` setting of our app. :param node: Node to store the additional metadata on. :param path: Path to file on disk. :param sg_publish_data: Shotgun data dictionary with all the standard publish fields. """ import nuke loader_app = self.parent additional_publish_fields = loader_app.get_setting( "additional_publish_fields") sgtk_tab_knob = nuke.Tab_Knob("sgtk_tab", "SGTK") node.addKnob(sgtk_tab_knob) for publish_field in additional_publish_fields: new_knob = None # create a pretty name for the knob knob_name = publish_field.replace("sg_", "") knob_name = knob_name.replace("_", " ") knob_name = knob_name.title() try: knob_value = sg_publish_data[publish_field] if isinstance(knob_value, str): new_knob = nuke.String_Knob(publish_field, knob_name) elif isinstance(knob_value, int): new_knob = nuke.Int_Knob(publish_field, knob_name) elif knob_value is None: # instead of creating a knob with an incorrect type # don't create a knob in this case since there is no value self.parent.logger.info( "Ignoring creation of {} knob since the value is {}". format(publish_field, knob_value)) else: self.parent.logger.warning( "Unable to create {} knob for type {}".format( publish_field, type(knob_value))) if new_knob: # make the knob read only new_knob.setFlag(nuke.READ_ONLY) new_knob.setValue(knob_value) node.addKnob(new_knob) except KeyError: self.parent.logger.warning( "%s not found in PublishedFile. Please check the SG Schema." % publish_field)
def _addPostKnobs(self): # Background render stuff self._bgRender = nuke.Boolean_Knob("bg_render", "Render in background") self._state.setKnob(self._bgRender, False) self._bgRender.setFlag(nuke.STARTLINE) self.addKnob(self._bgRender) # Terminal Render self._termRender = nuke.Boolean_Knob("terminal_render", "Render in Terminal") self._state.setKnob(self._termRender, False) self._termRender.setFlag(nuke.STARTLINE) self.addKnob(self._termRender) if self._bgRender.value() or self._termRender.value(): self.bg_render_knobs = True else: self.bg_render_knobs = False self._numInstances = nuke.Int_Knob("num_instances", "Instance Number") self._numInstances.setVisible(self.bg_render_knobs) self._state.setKnob(self._numInstances, 1) self.addKnob(self._numInstances) self._numThreads = nuke.Int_Knob("num_threads", "Thread limit") self._numThreads.setVisible(self.bg_render_knobs) self._state.setKnob(self._numThreads, max(nuke.NUM_CPUS / 2, 1)) self.addKnob(self._numThreads) self._maxMem = nuke.String_Knob("max_memory", "Memory limit") self._state.setKnob( self._maxMem, str(max(nuke.memory("max_usage") / 2097152, 16)) + "M") self._maxMem.setVisible(self.bg_render_knobs) self.addKnob(self._maxMem) self._chunkSize = nuke.Int_Knob("chunk_size", "Chunk Size") self._chunkSize.setVisible(False) self._state.setKnob(self._chunkSize, 4) self.addKnob(self._chunkSize)
def _update_node_metadata(self, node, path, sg_publish_data): """ Bakes/Updates the additional metadata on the read node creating a SGTK tab on the node. This currently only stores fields that are in `additional_publish_fields` setting of our app. :param node: Node to store the additional metadata on. :param path: Path to file on disk. :param sg_publish_data: Shotgun data dictionary with all the standard publish fields. """ additional_publish_fields = self.parent.get_setting( "additional_publish_fields") if not node.knob("sgtk_tab"): sgtk_tab_knob = nuke.Tab_Knob("sgtk_tab", "SGTK") node.addKnob(sgtk_tab_knob) for publish_field in additional_publish_fields: try: knob_value = sg_publish_data[publish_field] # create the knob if the field has a value now if knob_value and not node.knob(publish_field): new_knob = None # create a pretty name for the knob knob_name = publish_field.replace("sg_", "") knob_name = knob_name.replace("_", " ") knob_name = knob_name.title() if isinstance(knob_value, str): new_knob = nuke.String_Knob(publish_field, knob_name) elif isinstance(knob_value, int): new_knob = nuke.Int_Knob(publish_field, knob_name) else: self.parent.logger.warning( "Unable to create {} knob for type {}".format( publish_field, type(knob_value))) if new_knob: # make the knob read only new_knob.setFlag(nuke.READ_ONLY) new_knob.setValue(knob_value) node.addKnob(new_knob) # else just update it elif knob_value and node.knob(publish_field): # make the knob read only node.knob(publish_field).setFlag(nuke.READ_ONLY) node.knob(publish_field).setValue(knob_value) except KeyError: self.parent.logger.warning( "%s not found in PublishedFile. Please check the SG Schema." % publish_field)
def main(): cam = nuke.selectedNode() if cam.Class() == 'Camera2': frameKnob = nuke.Int_Knob('holdFrame') cam.addKnob(frameKnob) cam['holdFrame'].setValue(int(nuke.frame())) for knob in cam.knobs(): if cam[knob].isAnimated(): cam[knob].setExpression('curve(holdFrame)') label = cam['label'].value() label += ('\nHOLDFRAME [value holdFrame]') cam['label'].setValue(label)
def __init__(self): PythonPanel.__init__(self, 'C1 Preferences') # C1 Preferences self.email = None self.localDir = None self.projectDir = None # custom regex definitions for validation engine self.regex = {} self.projectStructure = {'root': {}} self.scriptDir = { 'root': os.path.join(os.path.join(os.path.realpath(__file__), os.pardir), os.pardir), 'c1_tools': os.path.join(os.path.realpath(__file__), os.pardir) } # define knobs self.inp_email = nuke.String_Knob('email', 'C1 Initials: ') self.inp_localDir = nuke.String_Knob('localDir', 'Local Working Directory: ') self.btn_localDir = nuke.PyScript_Knob("Set Working Dir") self.loginButton = nuke.PyScript_Knob("Login") self.cancelButton = nuke.PyScript_Knob("Cancel") # Project Map Tab self.projectMapTab = nuke.Tab_Knob("Project Map") self.setProjectButton = nuke.File_Knob('projectDir', 'Project Location') self.inp_projectLocation = nuke.String_Knob( 'projectDir', '<b><font size="3" color="red">Remote Project Directory</font></b>' ) self.inp_projectName = nuke.String_Knob('projectName', 'Project Name') self.inp_projectNum = nuke.Int_Knob('projectNum') # self.inp_projectNum.clearFlag( nuke.STARTLINE ) self.inp_projectCode = nuke.String_Knob('projectCode', 'Project Code') self.inp_projectCode.clearFlag(nuke.STARTLINE) # add knobs self.addKnob(self.inp_localDir) self.addKnob(self.btn_localDir) self.addKnob(self.inp_email) self.addKnob(self.loginButton) self.addKnob(self.cancelButton) # Project Map Tab self.addKnob(self.projectMapTab) self.addKnob(self.setProjectButton) self.addKnob(self.inp_projectName) self.addKnob(self.inp_projectNum) self.addKnob(self.inp_projectCode) # retrieve previous login from login.txt self.retrieveLogin() return
def addMoTab(): newTab = nuke.Tab_Knob('Mo_tab') cpToMatrixKnob = nuke.PyScript_Knob( "CornerPinToMatrix", 'CornerPin To Matrix', 'from Mo_RotoTools import cpToMatrixInNode\ncpToMatrixInNode()') cpToMatrixKnob.setFlag(nuke.STARTLINE) stablizeKnob = nuke.PyScript_Knob( "stablizeFromRotoLayer", 'Stablize From Roto Layer', 'from Mo_RotoTools import stablizeFromRotoLayer\nstablizeFromRotoLayer(nuke.thisNode())' ) dieBeforeKnob = nuke.PyScript_Knob( "dieBefore", 'Die Before', 'from Mo_RotoTools import dieBefore\ndieBefore()') singleFrameKnob = nuke.PyScript_Knob( "singleFrame", 'Single Frame', 'from Mo_RotoTools import singleFrame\nsingleFrame()') dieAfterKnob = nuke.PyScript_Knob( "dieAfter", 'Die After', 'from Mo_RotoTools import dieAfter\ndieAfter()') tracking = nuke.Text_Knob('tracking', 'Tracking') LifeTime = nuke.Text_Knob('lifetime', 'Life Time') fromValueKnob = nuke.Int_Knob('fromValue', 'From') toValueKnob = nuke.Int_Knob('toValue', 'To') toValueKnob.clearFlag(nuke.STARTLINE) node = nuke.thisNode() node.addKnob(newTab) node.addKnob(LifeTime) node.addKnob(dieBeforeKnob) node.addKnob(singleFrameKnob) node.addKnob(dieAfterKnob) node.addKnob(fromValueKnob) node.addKnob(toValueKnob) node.addKnob(tracking) node.addKnob(cpToMatrixKnob) node.addKnob(stablizeKnob) node.knob('fromValue').setExpression('lifetime_start') node.knob('toValue').setExpression('lifetime_end')
def __init__(self): nukescripts.PythonPanel.__init__(self, "sb Bake World Position") self.ff = nuke.Int_Knob("ff", "first frame") self.lf = nuke.Int_Knob("lf", "last frame") self.div1 = nuke.Text_Knob("divider1", "") self.rot_order = nuke.Enumeration_Knob( "rot_order", "rotation order", ["current", "XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"]) self.euler_filter = nuke.Boolean_Knob("euler_filter", "euler filter") self.euler_filter.setFlag(nuke.STARTLINE) self.use_matrix = nuke.Boolean_Knob("use_matrix", "use matrix") self.use_matrix.setFlag(nuke.STARTLINE) self.div2 = nuke.Text_Knob("divider2", "") self.bake_btn = nuke.PyScript_Knob("bake", "Bake nodes") for i in [ self.ff, self.lf, self.div1, self.rot_order, self.euler_filter, self.use_matrix, self.div2, self.bake_btn ]: self.addKnob(i) self.ff.setValue(nuke.root().firstFrame()) self.lf.setValue(nuke.root().lastFrame()) self.euler_filter.setValue(True)
def __init__(self): nukescripts.PythonPanel.__init__(self, 'Frame Server Status', 'FSPanel') # multiline text field to display workers self.host = nuke.Text_Knob('host', 'Host:', gethostname()) self.hostWorkers = nuke.Multiline_Eval_String_Knob( 'hostWorkers', 'Workers on host', '') self.hostRunning = nuke.Int_Knob('hostRunning', 'Workers on host') self.div1 = nuke.Text_Knob('div1', '') self.slavesWorkers = nuke.Multiline_Eval_String_Knob( 'slavesWorkers', 'Workers on slaves', '') # data data data self.slavesRunning = nuke.String_Knob('slavesRunning', 'Slaves running') self.numOfSlaves = nuke.Int_Knob('numOfSlaves', 'Total Slaves') self.numOfWorkers = nuke.Int_Knob('numOfWorkers', 'Total Workers') self.workersPerSlave = nuke.Int_Knob('workersPerSlave', 'Workers per Slaves') # buttons to refresh/copy self.refresh = nuke.PyScript_Knob('refresh', 'Refresh') self.showCommand = nuke.PyScript_Knob('showCommand', 'Copy workers\' list command') # add knobs for knob in [ self.refresh, self.slavesRunning, self.numOfSlaves, self.workersPerSlave, self.div1 ]: knob.setFlag(0x1000) for knob in [ self.host, self.hostWorkers, self.hostRunning, self.div1, self.slavesWorkers, self.slavesRunning, self.numOfSlaves, self.numOfWorkers, self.workersPerSlave, self.refresh, self.showCommand ]: self.addKnob(knob)
def start_pong(): stop_pong() # Make game box gamebox = nuke.toNode("PONG") if gamebox is None: gamebox = nuke.nodes.BackdropNode(bdwidth=1000, bdheight=500) p1s = nuke.Int_Knob('p1_score', 'player 1 score') p2s = nuke.Int_Knob('p2_score', 'player 2 score') gamebox.addKnob(p1s) gamebox.addKnob(p2s) gamebox['tile_color'].setValue(1) ball = nuke.toNode("ball") if ball is None: ball = nuke.nodes.Dot() # Make paddles player1, player2 = nuke.toNode("player1"), nuke.toNode("player2") if player1 is None: player1 = nuke.nodes.BackdropNode(bdwidth=40, bdheight=100, name="player1") player1.setXpos(gamebox.xpos()) if player2 is None: player2 = nuke.nodes.BackdropNode(bdwidth=40, bdheight=100, name="player2") player2.setXpos((gamebox.xpos() + (gamebox.screenWidth() - 40))) global pong pong = Game(gamebox=gamebox, ball=ball, player1=player1, player2=player2) pong.start()
def _addPostKnobs(self): # Background render stuff self._bgRender = nuke.Boolean_Knob("bg_render", "Render in background") self._state.setKnob(self._bgRender, False) self._bgRender.setFlag(nuke.STARTLINE) self.addKnob(self._bgRender) self._numThreads = nuke.Int_Knob("num_threads", "Thread limit") self._numThreads.setVisible(self._bgRender.value()) self._state.setKnob(self._numThreads, max(nuke.NUM_CPUS / 2, 1)) self.addKnob(self._numThreads) self._maxMem = nuke.String_Knob("max_memory", "Memory limit") self._state.setKnob( self._maxMem, str(max(nuke.memory("max_usage") / 2097152, 16)) + "M") self._maxMem.setVisible(self._bgRender.value()) self.addKnob(self._maxMem)