Example #1
0
    def fuel(template):
        """
        Fuel an empty script with a template and set the basic things
            that are required. Views should be handled here but inherited
            from the template graph file.

        Args:
            template (str): Path to template nuke script.

        """
        getLog().info("Ada: Fuel begin.")

        nuke.scriptOpen(template)
        template = nuke.Ada.template.location

        try:
            getLog().info("Ada: Reading template: {0}".format(template))
            nuke.scriptReadFile(template)

        except RuntimeError as err:
            getLog().warning("Ada: '{0}'".format(err))

        start = nuke.Ada.script_frame_range.start
        end = nuke.Ada.script_frame_range.end

        root = nuke.Root()
        root["first_frame"].setValue(start)
        root["last_frame"].setValue(end)

        getLog().info("Ada: setting root range: start: {0}, end: {1}".format(
            start, end))

        getLog().info("Ada: Fuel end.")
Example #2
0
    def addWriteConnectToTimecode(self):
        timecode = nuke.toNode('AddTimeCode1')
        if timecode:
            timex = timecode.xpos()
            timey = timecode.ypos()
            nuke.scriptReadFile(
                "W:\Production\Comp_Library\Comp_Tools\CMLWrite_DNXHR.nk")
            new = nuke.toNode('WriteMov_DNXHR')
            new.setXpos(timex + 100)
            new.setYpos(timey)
            new.setInput(0, timecode)
        else:
            wNode = nuke.toNode('WriteMov')
            wNodex = wNode.xpos()
            wNodey = wNode.ypos()
            wNodeIn = wNode.input(0)

            tNode = nuke.createNode('AddTimeCode')
            tNode.setXpos(wNodex)
            tNode.setYpos(wNodey - 100)
            tNode.setInput(0, wNodeIn)

            tNodes = nuke.toNode('AddTimeCode1')
            tNodex = tNodes.xpos()
            tNodey = tNodes.ypos()
            nuke.scriptReadFile(
                "W:\Production\Comp_Library\Comp_Tools\CMLWrite_DNXHR.nk")
            new = nuke.toNode('WriteMov_DNXHR')
            new.setXpos(tNodex + 100)
            new.setYpos(tNodey)
            new.setInput(0, tNodes)
Example #3
0
def importTemplate(templateName, templateType):

    #set the script name according to template type
    if templateType == "ENVIR":
        filePath = "C:\Users\priyansh shama\Documents\Nuke\Template\envir.nk"
        tempFilePath = filePath.replace("envir.nk", "envir_temp.nk")
    elif templateType == "CHAR":
        filePath = "C:\Users\priyansh shama\Documents\Nuke\Template\char.nk"
        tempFilePath = filePath.replace("char.nk", "char_temp.nk")
    else:
        filePath = "C:\Users\priyansh shama\Documents\Nuke\Template\crowd.nk"
        tempFilePath = filePath.replace("crowd.nk", "crowd_temp.nk")

    #copy the template file to a temp file
    shutil.copy(filePath, tempFilePath)

    #open the script in the give path to replace the node name with template type
    # TEMPLATE_Read to ENVIR_Read
    for line in fileinput.input(tempFilePath, inplace=1):
        sys.stdout.write(line.replace("TEMPLATE", templateName))

    #import script
    nuke.scriptReadFile(tempFilePath)

    #remove temp file
    os.remove(tempFilePath)
Example #4
0
def buildCompScript():
    templates = files

    for i, template in enumerate(templates):
        nuke.scriptReadFile(template)
        nuke.selectAll()
        node = nuke.selectedNodes("BackdropNode")[0]

        if i > 0:
            bdNodes = node.getNodes()
            nodePrevX = node.xpos()
            nodePrevY = node.ypos()
            node.setYpos(previousNode.ypos() + 500)
            node.setXpos(previousNode.xpos())

            for n in bdNodes:
                if n.ypos() > nodePrevY:
                    n.setYpos(node.ypos() + (n.ypos() - nodePrevY))
                else:
                    n.setYpos(node.ypos() + (n.ypos() + nodePrevY))
                if n.xpos() > nodePrevX:
                    n.setXpos(node.xpos() + (n.xpos() - nodePrevX))
                else:
                    n.setXpos(node.xpos() + (n.xpos() + nodePrevX))

        previousNode = node
Example #5
0
 def createTimelineFromDroppedClip(self, clipPath):
     nuke.scriptClear()
     nuke.scriptReadFile('/Users/ant/.nuke/Python/Startup/cut_detection/cutDetector.nk')
     self.inputNode = nuke.toNode('InputClip')
     self.cutDetector = nuke.toNode('CutDetector')
     self.inputNode['file'].fromUserText(clipPath)
     self.first = self.inputNode['first'].value()
     self.last = self.inputNode['last'].value()
     nuke.execute("CutDetector.CurveTool1", self.first, self.last)
Example #6
0
def buildCompScript(layerOrderFile, compScriptFile, isRunningFromScript):

    #imported nuke here as importing it outside was breaking argparse
    if not isRunningFromScript:
        import nuke

    #kept here if script is run from the comp itself
    if not os.path.isfile(layerOrderFile):
        print "Could not find layer_order.yml in " + shotDir
        sys.exit()

    if isRunningFromScript:
        # get nuke script to build
        nuke.scriptOpen(compScriptFile)

    # arrange templates in the given nuke script in vertical order
    templates = getTemplateList(layerOrderFile)

    for i, template in enumerate(templates):
        nuke.scriptReadFile(template)
        nuke.selectAll()
        node = nuke.selectedNodes("BackdropNode")[0]
        dotNode = nuke.selectedNodes('Dot')[0]
        if i > 0:
            bdNodes = node.getNodes()
            nodePrevX = node.xpos()
            nodePrevY = node.ypos()
            node.setYpos(previousNode.ypos() + 500)
            node.setXpos(previousNode.xpos())

            for n in bdNodes:
                if n.ypos() > nodePrevY:
                    n.setYpos(node.ypos() + (n.ypos() - nodePrevY))
                else:
                    n.setYpos(node.ypos() + (n.ypos() + nodePrevY))
                if n.xpos() > nodePrevX:
                    n.setXpos(node.xpos() + (n.xpos() - nodePrevX))
                else:
                    n.setXpos(node.xpos() + (n.xpos() + nodePrevX))

            if i > 1:
                dotNode.setInput(0, previousDotNode.dependent()[0])
            else:
                dotNode.setInput(0, previousDotNode)

        previousNode = node
        previousDotNode = dotNode

        if isRunningFromScript:
            #save nuke script
            nuke.scriptSave(compScriptFile)

        # remove temp files
        for template in templates:
            if "temp" in template:
                os.remove(template)
Example #7
0
 def createTimelineFromDroppedClip(self, clipPath):
     nuke.scriptClear()
     nuke.scriptReadFile(
         '/Users/ant/.nuke/Python/Startup/cut_detection/cutDetector.nk')
     self.inputNode = nuke.toNode('InputClip')
     self.cutDetector = nuke.toNode('CutDetector')
     self.inputNode['file'].fromUserText(clipPath)
     self.first = self.inputNode['first'].value()
     self.last = self.inputNode['last'].value()
     nuke.execute("CutDetector.CurveTool1", self.first, self.last)
Example #8
0
    def __init__(self, startnode, name):
        module_path = os.path.dirname(os.path.realpath(__file__)) + '/stylizeModule.nk'
        nuke.scriptReadFile(module_path)
        self.startnode = startnode
        self.img_name = name
        self.__GetNewModule()
        self.__RenameModule()

        x_bias = startnode['xpos'].getValue()-self.node_lst[0]['xpos'].getValue()
        y_bias = startnode['ypos'].getValue() - self.node_lst[0]['ypos'].getValue()
        self.Transform(x_bias + 34, y_bias + 200)
Example #9
0
def open_file(filepath):
    filepath = filepath.replace("\\", "/")

    # To remain in the same window, we have to clear the script and read
    # in the contents of the workfile.
    nuke.scriptClear()
    nuke.scriptReadFile(filepath)
    nuke.Root()["name"].setValue(filepath)
    nuke.Root()["project_directory"].setValue(os.path.dirname(filepath))
    nuke.Root().setModified(False)
    return True
Example #10
0
 def writeNode(self):
     old = nuke.toNode('WriteMov_DNXHR')
     oldx = old.xpos()
     oldy = old.ypos()
     oldin = old.input(0)
     nuke.delete(old)
     nuke.scriptReadFile(
         "W:\Production\Comp_Library\Comp_Tools\CMLWrite_DNXHR.nk")
     new = nuke.toNode('WriteMov_DNXHR')
     new.setXpos(oldx)
     new.setYpos(oldy)
     new.setInput(0, oldin)
Example #11
0
File: nk.py Project: tws0002/Nuke-2
def create_node(filename, context):
    if not filename.lower().endswith('.nk'):
        return None
    n = nuke.nodes.Group(label=filename.encode('utf-8'))
    n.setName('Group_import_1')
    with n:
        nuke.scriptReadFile(filename.encode('utf-8'))
    k = nuke.PyScript_Knob('expand',
                           '展开组'.encode('utf-8'),
                           'nuke.thisNode().expand()')
    n.addKnob(k)
    context['is_created'] = True
    return [n]
Example #12
0
    def import_file(self, filePath):
        if filePath[-4:] == '.abc' and os.path.exists(filePath):
            readGeo = nuke.createNode('ReadGeo2', 'file {%s}' % (filePath))
            sceneView = readGeo['scene_view']
            allItems = sceneView.getAllItems()

            if allItems:
                sceneView.setImportedItems(allItems)
                sceneView.setSelectedItems(allItems)
            else:
                nuke.delete(readGeo)
                nuke.createNode('Camera2',
                                'file {%s} read_from_file True' % (filePath))
            return True
        elif filePath[-3] == '.nk' and os.path.exists(filePath):
            nuke.scriptReadFile(filePath)
            return True
        return False
Example #13
0
def open_file(filepath):
    filepath = filepath.replace("\\", "/")

    # To remain in the same window, we have to clear the script and read
    # in the contents of the workfile.
    nuke.scriptClear()
    nuke.scriptReadFile(filepath)
    nuke.Root()["name"].setValue(filepath)
    nuke.Root()["project_directory"].setValue(os.path.dirname(filepath))
    nuke.Root().setModified(False)

    # Since we clear the current script and read in contents of the file path
    # instead of loading the script (to stay within the same window), there are
    # no callbacks emitted by Nuke. To accommodate callbacks on loading we
    # introduce this signal.
    api.emit("workio.open_file")

    return True
Example #14
0
def setupshot():
    for n in nuke.allNodes('NoOp'):
        if n.name() == 'SETUP':
            print "PERFORMING INITIAL SHOT SETUP..."
            nuke.delete(n)
            nuke.delete(nuke.toNode('ModifyMetaData1'))
            nuke.delete(nuke.toNode('ModifyMetaData2'))
            nuke.root()['first_frame'].setValue(
                nuke.toNode('Read1')['first'].getValue() + 16)
            nuke.root()['last_frame'].setValue(
                nuke.toNode('Read1')['last'].getValue() - 16)

            pf = nuke.toNode('MAE_PLATE_FORMATTER_v2')

            nuke.delete(nuke.toNode('MAE_PLATE_FORMATTER_v2'))
            nuke.scriptReadFile(
                os.path.join(os.environ['IH_PATH_SERVER'], '13th_Floor',
                             '_pipeline', 'nuke', 'ToolSets', 'mae_shared',
                             'mae_plate_formatter.nk'))
Example #15
0
def updateMovNode():
    cNode = nuke.toNode('WriteMov_DNXHR')
    movoutputnode = nuke.toNode('MovOutput')
    if cNode:
        stamp = cNode['Date'].value()
        mTime = os.path.getmtime(
            "W:\Production\Comp_Library\Comp_Tools\CMLWrite_DNXHR.nk")
        nodeStamp = datetime.fromtimestamp(mTime)
        strStamp = str(nodeStamp)
        if stamp < strStamp:
            nuke.delete(cNode)
            nuke.scriptReadFile(
                "W:\Production\Comp_Library\Comp_Tools\CMLWrite_DNXHR.nk")
            cNode = nuke.toNode('WriteMov_DNXHR')
            cNode.setInput(0, movoutputnode)
            cNode.setXpos(movoutputnode.xpos())
            cNode.setYpos(movoutputnode.ypos() + 200)
            print 'current node is not latest'
        else:
            print 'current node is the latest'
Example #16
0
    def _nuke_execute(self, operation, file_path, **kwargs):
        """
        The Nuke specific scene operations.
        """
        if file_path:
            file_path = file_path.replace("/", os.path.sep)

        if operation == "current_path":
            # return the current script path
            return nuke.root().name().replace("/", os.path.sep)
        elif operation == "open":
            # open the specified script into the current window
            if nuke.root().modified():
                raise TankError("Script is modified!")
            # See shotgunsoftware/tk-multi-snapshot/pull/23
            for node in nuke.allNodes():
                nuke.delete(node)
            nuke.scriptReadFile(file_path)
        elif operation == "save":
            # save the current script:
            nuke.scriptSave()
def AutoScriptImport(keep=True):
    path = os.getenv('AUTOSCRIPTIMPORTPATH')
    #set the path manually below if you do not want to use env variables
    #path = "path/to/the/folder"
    if path == None:
        msg = "AutoScriptPath path not set!, use:\nos.environ['AUTOIMPORTPATH'] = '/path/to/your/folder' on menu.py"
        if nuke.GUI:
            nuke.message(msg)
        raise TypeError, msg
    if not os.path.exists(path):
        msg =  'AutoScriptPath do not exists: ' + path
        if nuke.GUI:
            nuke.message(msg)
        raise TypeError, msg
    dirList=os.listdir(path)
    for fname in dirList:
        ext = os.path.splitext(fname)
        if ext[1] == ".nk":
            nuke.scriptReadFile(path+fname)
            if not keep: #delete the files
                os.remove(os.path.join(path,fname))
Example #18
0
    def func(cls, *args, **kwargs):
        ret = cls.orig(*args, **kwargs)

        if ret is None or not cls.current_options:
            return ret

        group = nuke.nodes.Group()
        with group:
            nuke.scriptReadFile(cls.current_options['script'].encode('utf-8'))
            write_nodes = nuke.allNodes('Write')
            assert write_nodes
            if len(write_nodes) != 1:
                nuke.message('注意: 预合成中发现了多个输出节点, 可能导致渲染出错'.encode('utf-8'))
            precomp_name = cls.current_options['precomp_name']
            name = '_'.join(i for i in ('Write',
                                        precomp_name.upper().replace(' ', '_'),
                                        '1') if i)
            for n in write_nodes:
                n.setName(name.encode('utf-8'))
                # Disable exr hash check
                # precomp node will change the value
                # so we need a assert node.
                assert_node = nuke.nodes.Assert()
                assert_node['expression'].setExpression(
                    '[knob {}.checkHashOnRead 0]\n'
                    '[return 1]'.format(n.name()).encode('utf-8'))
                edit.insert_node(assert_node, n.input(0))
            nuke.tcl(b"export_as_precomp",
                     cls.current_options['script'].encode('utf-8'))
            if cls.current_precomp_node:
                cls.current_precomp_node.reload()
            else:
                LOGGER.warning(
                    'Not found precomp node after `precomp_selected`')

        nuke.delete(group)
        cls.current_options = None
        cls.current_precomp_node = None

        return ret
Example #19
0
def buildCompScript(layerOrderFile, compScriptFile):
    # get nuke script to build
    nuke.scriptOpen(compScriptFile)

    # arrange templates in the given nuke script in vertical order
    templates = getTemplateList(layerOrderFile)

    for i, template in enumerate(templates):
        nuke.scriptReadFile(template)
        nuke.selectAll()
        node = nuke.selectedNodes("BackdropNode")[0]
        dotNode = nuke.selectedNodes('Dot')[0]
        if i > 0:
            bdNodes = node.getNodes()
            nodePrevX = node.xpos()
            nodePrevY = node.ypos()
            node.setYpos(previousNode.ypos() + 500)
            node.setXpos(previousNode.xpos())

            for n in bdNodes:
                if n.ypos() > nodePrevY:
                    n.setYpos(node.ypos() + (n.ypos() - nodePrevY))
                else:
                    n.setYpos(node.ypos() + (n.ypos() + nodePrevY))
                if n.xpos() > nodePrevX:
                    n.setXpos(node.xpos() + (n.xpos() - nodePrevX))
                else:
                    n.setXpos(node.xpos() + (n.xpos() + nodePrevX))

            if i > 1:
                dotNode.setInput(0, previousDotNode.dependent()[0])
            else:
                dotNode.setInput(0, previousDotNode)

        previousNode = node
        previousDotNode = dotNode

        # save nuke script
        nuke.scriptSave(compScriptFile)
Example #20
0
def restoreCheckpoint(nukeScript, nodeName, date):
    log("restoreCheckpoint %s %s %s" % (nukeScript, nodeName, date))

    #  We ask on rv side now, since otherwise dialog can come up behind rv.
    #
    # ans = nuke.ask ("Restore checkpoint: %s, %s ?" % (nodeName, date))
    # log ("    ans %s" % ans)

    log("    reading checkpoint script")
    nuke.Undo().begin("Restore %s, %s" % (nodeName, date))
    try:
        nukescripts.misc.clear_selection_recursive()

        try:
            v = nuke.activeViewer().node().name()
        except:
            v = None

        if (rvmon):
            rvmon.restoreBegin()

        nodes = nuke.root().nodes()
        for n in nodes:
            #log ("    deleting %s %s %s" % (n.name(), type(n).__name__, n.Class()))
            nuke.delete(n)
        nuke.scriptReadFile(nukeScript)

        if (v):
            n = nuke.toNode(v)
            if (n):
                nuke.show(n)

        if (rvmon):
            rvmon.restoreComplete()

        log("    checkpoint restore complete")

    except Exception, msg:
        nuke.message("Checkpoint restore failed:\n%s" % (msg, ))
Example #21
0
def restoreCheckpoint (nukeScript, nodeName, date) :
    log ("restoreCheckpoint %s %s %s" % (nukeScript, nodeName, date))

    #  We ask on rv side now, since otherwise dialog can come up behind rv.
    #
    # ans = nuke.ask ("Restore checkpoint: %s, %s ?" % (nodeName, date))
    # log ("    ans %s" % ans)

    log ("    reading checkpoint script")
    nuke.Undo().begin("Restore %s, %s" % (nodeName, date))
    try :
        nukescripts.misc.clear_selection_recursive()

        try :
            v = nuke.activeViewer().node().name()
        except :
            v = None

        if (rvmon) :
            rvmon.restoreBegin()

        nodes = nuke.root().nodes()
        for n in nodes:
            #log ("    deleting %s %s %s" % (n.name(), type(n).__name__, n.Class()))
            nuke.delete(n)
        nuke.scriptReadFile (nukeScript)

        if (v) :
            n = nuke.toNode(v)
            if (n) :
                nuke.show (n)

        if (rvmon) :
            rvmon.restoreComplete()

        log ("    checkpoint restore complete")

    except Exception, msg:
        nuke.message("Checkpoint restore failed:\n%s" % (msg,))
    def import_selection(self):
        if hasattr(self, 'selected_item'):
            print self.selected_item.data()
            template_path = self.selected_item.data().get('path').get('local_path')

            for n in nuke.allNodes():
                if n.Class()=='Viewer':
                    x = n.xpos()
                    y = n.ypos()

            nuke.scriptReadFile(template_path)
            nuke.selectConnectedNodes()
            nodes = nuke.selectedNodes()

            for n in nodes:
                n.setXYpos(x, y)

            for n in nodes:
                n.autoplace()

            nuke.message('Template imported!')
            self.close()
Example #23
0
def add_template(template_name):
    root_menu = nuke.menu('Nuke')
    template_menu = 'Toolkit/{}/{}'.format(user_name, template_name)
    if not root_menu.findItem(template_menu):
        if not os.path.isdir('{}/{}'.format(TOOLKIT_ROOT, user_name)):
            os.makedirs('{}/{}'.format(TOOLKIT_ROOT, user_name))
        nuke.nodeCopy('{}/{}/{}.nk'.format(TOOLKIT_ROOT, user_name,
                                           template_name))
        root_menu.addCommand(
            'Toolkit/{}/{}/{}'.format(user_name, template_name, template_name),
            lambda: nuke.scriptReadFile('{}/{}/{}.nk'.format(
                TOOLKIT_ROOT, user_name, template_name)))
        root_menu.addCommand(
            'Toolkit/{}/{}/remove'.format(user_name, template_name),
            lambda: remove_template(template_name))
Example #24
0
def add_user_template(menu, root_folder):
    folders = [
        folder for folder in os.listdir(root_folder)
        if os.path.isdir('{}/{}'.format(root_folder, folder))
    ]
    for folder in folders:
        templates = [
            i for i in os.listdir('{}/{}'.format(root_folder, folder))
            if i.endswith('.nk')
        ]
        if templates:
            submenu = menu.addMenu(folder)
            for template in templates:
                template_name = copy.deepcopy(
                    os.path.basename(template).split('.')[0])
                submenu.addCommand(
                    '{}/{}'.format(template_name, template_name),
                    lambda: nuke.scriptReadFile('{}/{}/{}'.format(
                        root_folder, folder, template)))
                submenu.addCommand('{}/remove'.format(template_name),
                                   lambda: remove_template(template_name))
        add_user_template(submenu, '{}/{}'.format(root_folder, folder))
Example #25
0
def nk_read_nodes():
	"""
	Read nodes from file
	"""
	f = nuke.getFilename("Select nuke script to source nodes")
	nuke.scriptReadFile(f)
Example #26
0
 def __init__(self, template_path):
     self.template = template_path
     nuke.scriptReadFile(self.template)
Example #27
0
parser.add_option("", "--length", action="store")
parser.add_option("", "--notes", action="store")
parser.add_option("", "--artist", action="store")
parser.add_option("", "--onlyDump", action="store_true")

options, args = parser.parse_args()

for required_attr in [
        "nukeTemplatePath", "vignettePath", "outputPath", "outputFormat",
        "project", "shot", "version", "length", "notes", "artist"
]:
    if not getattr(options, required_attr):
        parser.error("No --%s specified." % required_attr)

# read template
nuke.scriptReadFile(options.nukeTemplatePath)

vignette = nuke.toNode("vignette")
vignette["file"].fromUserText(os.path.abspath(options.vignettePath))

input_project = nuke.toNode("input_project")
input_project["message"].setValue(options.project)

input_shot = nuke.toNode("input_shot")
input_shot["message"].setValue(options.shot)

input_version = nuke.toNode("input_version")
input_version["message"].setValue(options.version)

input_length = nuke.toNode("input_length")
input_length["message"].setValue(options.length)
Example #28
0
    def knobChanged(self, knob):
        if knob is self.projKnob:
            self.refresh_panel_with_project('proj_' + self.projKnob.value())
            self.refresh_version_panel(self.projKnob.value(),
                                       self.epsKnob.value(),
                                       self.shotKnob.value(), self.account)
            self.version_check(self.projKnob.value(), self.epsKnob.value(),
                               self.shotKnob.value(), self.account,
                               self.verKnob.value())

        if knob.name() == 'showPanel':
            if self.in_task == 'have':
                '''
                Set default value with current task if this script in task
                '''
                # get task info from fileName
                self.cur_task_info = self.get_task_info_from_file(
                    os.path.basename(self.current_file_path))
                # set Project Value
                self.projKnob.setValue(self.cur_task_info[0])
                # refresh Panel
                self.refresh_panel_with_project('proj_' +
                                                self.projKnob.value())
                # set default Panels
                self.epsKnob.setValue(self.cur_task_info[1])
                self.shotKnob.setValue(self.cur_task_info[2])
                self.refresh_version_panel(self.projKnob.value(),
                                           self.epsKnob.value(),
                                           self.shotKnob.value(), self.account)

                self.verKnob.setValue(
                    self.vernum_check.findall(self.current_file_path)[0])

                self.version_check(self.projKnob.value(), self.epsKnob.value(),
                                   self.shotKnob.value(), self.account,
                                   self.verKnob.value())
            else:
                self.refresh_panel_with_project('proj_' +
                                                self.projKnob.value())
                self.refresh_version_panel(self.projKnob.value(),
                                           self.epsKnob.value(),
                                           self.shotKnob.value(), self.account)
                self.version_check(self.projKnob.value(), self.epsKnob.value(),
                                   self.shotKnob.value(), self.account,
                                   self.verKnob.value())

        if knob is self.epsKnob:
            self.shotKnob.setValues(
                getData.get_shot_list(self.jsData,
                                      'proj_' + self.projKnob.value(),
                                      self.epsKnob.value()))
            self.refresh_version_panel(self.projKnob.value(),
                                       self.epsKnob.value(),
                                       self.shotKnob.value(), self.account)

        if knob is self.shotKnob:
            self.refresh_version_panel(self.projKnob.value(),
                                       self.epsKnob.value(),
                                       self.shotKnob.value(), self.account)

        if knob is self.verKnob or knob is self.shotKnob or knob is self.epsKnob:
            self.version_check(self.projKnob.value(), self.epsKnob.value(),
                               self.shotKnob.value(), self.account,
                               self.verKnob.value())

        if knob is self.openFileButton:
            nuke.scriptOpen(self.get_filepath_from_knob())
            self.hide()

        if knob is self.createMainVersionButton:
            self.next_mainversion(self.current_file_path)
            self.hide()

        if knob is self.upSubVersionButton:
            self.next_subversion(self.current_file_path)
            self.hide()

        if knob is self.createFirstVersionButton:
            first_version_path = self.get_filepath_from_knob()
            nuke.scriptSaveAs(first_version_path)
            temp_file_match = re.compile(
                r'^%s_%s_%s_cmp_yourName_v\d{3,6}.nk$' %
                (self.projKnob.value(), self.epsKnob.value(),
                 self.shotKnob.value()))
            ver_dict = getData.script_version_info(self.projKnob.value(),
                                                   self.epsKnob.value(),
                                                   self.shotKnob.value(),
                                                   self.account)
            if ver_dict['nukeScriptList']:
                # when have script already in this direction
                for script in ver_dict['nukeScriptList']:
                    # when have template file
                    if temp_file_match.match(script):
                        try:
                            nuke.scriptReadFile(
                                os.path.dirname(first_version_path) + '/' +
                                script)
                        except RuntimeError:
                            pass
                        for node in nuke.allNodes(filter='Write'):
                            if node.Class() == 'Write':
                                temp_file_name = node['file'].getValue()
                                node['file'].setValue(
                                    temp_file_name.replace(
                                        'yourName', self.account))
                        nuke.scriptSave()
            self.hide()

        if knob is self.upMainVersionButton:
            self.next_mainversion(self.current_file_path)
            self.hide()
Example #29
0
parser.add_option("", "--sequence", action="store")
parser.add_option("", "--scene", action="store")
parser.add_option("", "--shot", action="store")
parser.add_option("", "--version", action="store")
parser.add_option("", "--notes", action="store")
parser.add_option("", "--artist", action="store")
parser.add_option("", "--onlyDump", action="store_true")

options, args = parser.parse_args()

for required_attr in ["nukeTemplatePath", "inputPath", "fps", "outputPath", "resolution", "codec"]:
    if not getattr(options, required_attr):
        parser.error("No --%s specified." % required_attr)

# read template
nuke.scriptReadFile(options.nukeTemplatePath)

input_frames = nuke.toNode("input_frames")
input_frames["file"].fromUserText(os.path.abspath(options.inputPath))
input_frames["first"].setValue(options.frameStart);
input_frames["last"].setValue(options.frameEnd);

input_project = nuke.toNode("input_project")
input_project["message"].setValue(options.project) 

input_sequence = nuke.toNode("input_sequence")
input_sequence["message"].setValue(options.sequence) 

input_scene = nuke.toNode("input_scene")
input_scene["message"].setValue(options.scene) 
Example #30
0
 def checkWriteNodeDNXHR(self):
     if nuke.toNode('WriteMov_DNXHR'):
         print "WriteMov_DNXHR Node Already Exists"
     else:
         nuke.scriptReadFile(
             "W:\Production\Comp_Library\Comp_Tools\CMLWrite_DNXHR.nk")
Example #31
0
mode = options.mode
nuke_node_path = options.nukeNodePath
input_resolution = options.inputResolution
output_resolution = options.outputResolution
output_path = options.outputPath
first = options.frameStart
last = options.frameEnd
onlyDump = options.onlyDump

# use Nuke-style instead of hashes
input_path = nukescripts.replaceHashes(input_path)
input_path = os.path.abspath(input_path)

if nuke_node_path:
    # read undistort node
    nuke.scriptReadFile(nuke_node_path)
    tde_node = nuke.root().nodes()[0]

# read the input
read_plate = nuke.nodes.Read(name="plate_in")
read_plate["file"].fromUserText(input_path)
read_plate["first"].setValue(first)
read_plate["last"].setValue(last)
read_plate["colorspace"].setValue("Cineon")
last_node = read_plate

input_format = find_format(input_resolution)
if not input_format:
    parser.error("Can't find matching format for inputRresolution %s" % input_resolution)

output_format = find_format(output_resolution)
Example #32
0
 def checkNodeCMLpath(self):
     if nuke.toNode('CMLPath'):
         print "CMLPath Node Already Exists"
     else:
         nuke.scriptReadFile(
             "W:\Production\Comp_Library\Comp_Tools\CMLPath.nk")