Small improvement to Pr_Suite for Nuke

Small improvement to Pr_Suite for Nuke

One of the most tool I use constantly in Nuke is Pr_Suite_v1.1, created by Parimal VFX. What is included in the suite can be found on the linked website so I will not go into details. What this is about is some small improvement I made over the time I use it.

OpenFolder.py located in Pr_Suite > python > Prpy

OpenFolder.py does exactly what its name implies. It opens folder of selected read/write node, or nuke script location directly from Nuke. The biggest flaw I found is it doesn’t work with relative file path.

  • Works with nodes with relative file path.
  • Launches with default file manager instead of hard coded to gnome.
  • Works with gizmos/groups that contains file knob within it.
  • Open all paths from multiple selected nodes.
def open_folder(path):
    """
    Open folder based on OS.
    :param path: Directory path
    :type path: str
    :return: None
    :rtype: None
    """
    if platform.system() == "Windows":
        os.startfile(os.path.abspath(path))
    elif platform.system() == "Darwin":
        subprocess.Popen(["open", path])
    elif platform.system() == "Linux":
        subprocess.check_call(["xdg-open", path])
    else:
        nuke.message("Unsupported OS")


def open_read_file():
    """
    Open folder for selected node with file knob.
    :return: None
    :rtype: None
    """
    read_path = []
    for node in nuke.selectedNodes():
        for knob in node.knobs():
            current_knob = node[knob]
            if current_knob.Class() == 'File_Knob':
                if current_knob.evaluate() is not None:
                    if os.path.dirname(current_knob.evaluate()) not in read_path:
                        read_path.append(os.path.dirname(current_knob.evaluate()))
    if len(read_path) > 4:
        if nuke.ask('About to open ' + str(len(read_path)) + " paths, continue?"):
            for path in read_path:
                open_folder(path)
    else:
        for path in read_path:
            open_folder(path)

ReadFromWrite.py located in Pr_Suite > Python > Prpy

With “Shift + R” as its shortcut key, it creates a Read node based on the selected Write node. It doesn’t work with a write gizmo from a pipeline, which can be expected. The following improvements are

  • Works with gizmos/groups that contains write node in it.
  • Put the read node right beside the gizmo/group itself.
  • Can select multiple write nodes and create read nodes beside each of them.
def read_from_write():
    """
    Create Read node from selected Write node.
    :return: None
    :rtype: None
    """
    selected = nuke.selectedNodes()
    writeNodes = []
    for node in selected:
        if node.Class() == 'Write':
            writeNodes.append(node)
        else:
            hasWrite = False
            for inNode in nuke.allNodes(group=node):
                if inNode.Class() == 'Write':
                    hasWrite = True
            if hasWrite:
                writeNodes.append(node)

    if len(writeNodes) < 1:
        nuke.message("Please select a Write node.")
    else:
        writeList = []
        for n in writeNodes:
            writeValues = []
            if n.Class() == 'Write':
                writeValues.append(n)
                writeValues.append(n.xpos())
                writeValues.append(n.ypos())
                writeList.append(writeValues)
            else:
                for inGroup in nuke.allNodes(group=n):
                    if inGroup.Class() == 'Write':
                        writeValues.append(inGroup)
                        writeValues.append(n.xpos())
                        writeValues.append(n.ypos())
                        writeList.append(writeValues)

        for write in writeList:
            if write[0]["use_limit"].value() is True:
                first_frame = write[0]["first"].value()
                last_frame = write[0]["last"].value()
            else:
                first_frame = nuke.Root()["first_frame"].value()
                last_frame = nuke.Root()["last_frame"].value()

            writeNode = nuke.nodes.Read(
                file=nuke.filename(write[0]),
                first=first_frame,
                last=last_frame,
                origfirst=nuke.Root()["first_frame"].value(),
                origlast=nuke.Root()["last_frame"].value())
            writeNode.setXpos(write[1]+100)
            writeNode.setYpos(write[2])

ShufferEXRPasses.py located in Pr_Suite > python > Prpy

This script gives you a pop up Window for you to select the passes you want, and shuffle all of them out neatly. Small complain I have for this is it adds the channel name to the shuffle node’s label. Which is nice but I don’t want them hardcoded, in case I want to change the channel to something else. Note that there’s already another python script in Pr_Suite 1.1 to add ‘[value in]’ in a shuffle’s label, so it reflects whatever the in channel is. But why not add it in the ShuffleEXRPasses

            for layer in extract:
                shuffle = nuke.nodes.Shuffle(label='[value in]')
                shuffle["in"].setValue(layer)
                shuffle.setInput(0, self.node)

Leave a Reply

Your email address will not be published. Required fields are marked *