コード例 #1
0
    def beforeRenderCallback():
        """
        Prepare to render from a DA_WriteMovieSlices node.
        """
        slice_number = nuke.thisNode().knob('slice').value()
        output_fpath = nuke.thisParent().knob('file').value()

        if not len(output_fpath) > 0:
            raise RuntimeError('No output filepath has been specified!')

        base = os.path.basename(output_fpath)

        prefix = base[:base.index('.')]
        suffix = base[base.index('.'):]

        slice_name = 'slice_%s' % int(slice_number)

        destdir = os.path.join(os.path.dirname(output_fpath), prefix, slice_name)
        destfile = prefix + '_' + slice_name + suffix

        if not os.path.exists(destdir):
            os.makedirs(destdir)

        nuke.thisNode().knob('file').setValue(os.path.join(destdir, destfile))
        nuke.thisNode().knob('first').setValue(nuke.thisParent().knob('first').value())
        nuke.thisNode().knob('last').setValue(nuke.thisParent().knob('last').value())
コード例 #2
0
def shotVersion(node=nuke.thisParent()):
    if namingConvention(node) is "knobs":
        return node['v_num'].value()
    else:
        # Using regular expression to search through the filename for "_v##"
        for match in re.findall(r'_v\d{2,}', nuke.root().name().split("/")[-1]):
            return match.replace("_", "")
コード例 #3
0
def encryptomatte_add_manifest_id(deserialize=False):

    node = nuke.thisNode()
    parent = nuke.thisParent()
    name = parent.knob('matteName').value()
    id_hex = parent.knob('idHex').value()
    manifest_key = parent.knob('manifestKey').value()
    metadata = node.metadata()
    manifest = metadata.get(manifest_key + 'manifest', "{}")

    if deserialize:
        import json
        d = json.loads(manifest)
        d[name] = hex_id
        new_manifest = json.dumps(d)
        return new_manifest
    else:
        last_item = '"{name}":"{id_hex}"'.format(name=name, id_hex=id_hex)
        last_item += '}'

        last_bracket_pos = manifest.rfind('}')
        existing_items = manifest[:last_bracket_pos].rstrip()
        if not existing_items.endswith(',') and not existing_items.endswith(
                '{'):
            return existing_items + ',' + last_item
        else:
            return existing_items + last_item
コード例 #4
0
def encryptomatte_add_manifest_id(deserialize = False):

    node = nuke.thisNode()
    parent = nuke.thisParent()
    name = parent.knob('matteName').value()
    id_hex = parent.knob('idHex').value()
    manifest_key = parent.knob('manifestKey').value()
    metadata = node.metadata()
    manifest = metadata.get(manifest_key + 'manifest', "{}")

    if deserialize:
        import json
        d = json.loads(manifest)
        d[name] = hex_id
        new_manifest = json.dumps(d)
        return new_manifest
    else:
        last_item = '"{name}":"{id_hex}"'.format(name=name, id_hex=id_hex)
        last_item += '}'

        last_bracket_pos = manifest.rfind('}')
        existing_items = manifest[:last_bracket_pos].rstrip()
        if not existing_items.endswith(',') and not existing_items.endswith('{'):
            return existing_items + ',' + last_item
        else:
            return existing_items + last_item
コード例 #5
0
def shotVersion(node=nuke.thisParent()):
    if namingConvention(node) is "knobs":
        return node['v_num'].value()
    else:
        # Using regular expression to search through the filename for "_v##"
        for match in re.findall(r'_v\d{2,}',
                                nuke.root().name().split("/")[-1]):
            return match.replace("_", "")
コード例 #6
0
def postVer(node=nuke.thisParent()):
    if namingConvention(node) is "knobs":
        return ""
    else:
        postVer = scriptName().split(shotVersion(node))[-1]
        if postVer.startswith("."):
            return ""
        else:
            return postVer.split(".")[0]
コード例 #7
0
def postVer(node=nuke.thisParent()):
    if namingConvention(node) is "knobs":
        return ""
    else:
        postVer = scriptName().split(shotVersion(node))[-1]
        if postVer.startswith("."):
            return ""
        else:
            return postVer.split(".")[0]
コード例 #8
0
    def __traverseNetwork(cls, node, nodeType, direction, nodeCache):
        """
        Auxiliar to the traverseNetwork method.

        :param node: The node to start the recursion from.
        :type node: nuke.Node
        :param nodeType: The type of the node to be found in the node tree.
        :type nodeType: str
        :param direction: The direction to traverse the network. values: input or output.
        :type direction: str
        :param nodeCache: A list of nodes that has been revised.
        :type nodeCache: list
        """
        # Create a cache for nodes that have been process
        if not node or node in nodeCache:
            return []

        nodeCache.append(node)

        nodesFound = []
        if node.Class() == nodeType.capitalize():
            nodesFound.append(node)

        nodes = node.dependencies(
        ) if direction == 'input' else node.dependent()

        for nod in nodes:
            if direction == 'output':
                for n in nod.dependencies():
                    if n in nodeCache:
                        continue
                    nodesFound += cls.__traverseNetwork(
                        n, nodeType, 'input', nodeCache)

            nodesFound += cls.__traverseNetwork(nod, nodeType, direction,
                                                nodeCache)

        if nuke.thisParent():
            nodesFound += cls.__traverseNetwork(nuke.thisParent(), nodeType,
                                                direction, nodeCache)

        return nodesFound
コード例 #9
0
def encryptomatte_add_manifest_id():
    node = nuke.thisNode()
    parent = nuke.thisParent()
    name = parent.knob('matteName').value()
    id_hex = parent.knob('idHex').value()
    manifest_key = parent.knob('manifestKey').value()
    metadata = node.metadata()
    manifest = metadata.get(manifest_key + 'manifest', "{}")

    # Add another item, with closing bracket
    last_item = '"%s":"%s"}' % (name, id_hex)
    last_bracket_pos = manifest.rfind('}')
    existing_items = manifest[:last_bracket_pos].rstrip()
    if not existing_items.endswith(',') and not existing_items.endswith('{'):
        existing_items += ','
    existing_items += last_item
    return existing_items
コード例 #10
0
def encryptomatte_add_manifest_id():
    node = nuke.thisNode()
    parent = nuke.thisParent()
    name = parent.knob('matteName').value()
    id_hex = parent.knob('idHex').value()
    manifest_key = parent.knob('manifestKey').value()
    metadata = node.metadata()
    manifest = metadata.get(manifest_key + 'manifest', "{}")

    # Add another item, with closing bracket
    last_item = '"%s":"%s"}' % (name, id_hex)
    last_bracket_pos = manifest.rfind('}')
    existing_items = manifest[:last_bracket_pos].rstrip()
    if not existing_items.endswith(',') and not existing_items.endswith('{'):
        existing_items += ','
    existing_items += last_item
    return existing_items
コード例 #11
0
def bakeGroup(group):
    '''
    Make a copy of the not massive group
    Remove sutff inside the group we don't need
    Remove knobs we don't keed
    Bake the expressions in the group
    '''

    if not nuke.ask(
            'Are you sure you want to bake? This may take a long time...\n\n1 minute per 100 cards is normal.'
    ):
        return

    with group:
        with nuke.thisParent():
            for n in nuke.selectedNodes():
                n.setSelected(False)

            # change temp dir if needed
            # defaulting to nuke's temp dir, not sure how kosher this is
            tmpDirRoot = os.environ.get('NUKE_TEMP_DIR')

            # give cloned node unique filename so that nuke won't use a cached version
            groupFileBase = str(uuid.uuid4())
            tmpDir = '%s/CrowdControl' % (tmpDirRoot)

            try:
                os.mkdir(tmpDir)
            except:
                pass
            tmpPath = '%s/%s.nk' % (tmpDir, groupFileBase)

            group.setSelected(True)
            nuke.nodeCopy(tmpPath)

            for n in nuke.selectedNodes():
                n.setSelected(False)

            nuke.nodePaste(tmpPath)
            newGroup = nuke.selectedNode()

            #remove callbacks
            newGroup.knob('knobChanged').setValue('')
            newGroup.knob('onCreate').setValue('')

            #link up the inputs
            for i in range(group.inputs()):
                inputNode = group.input(i)
                if inputNode is not None:
                    newGroup.setInput(i, inputNode)

            #Bake the group internals
            cards = []
            for n in newGroup.nodes():
                if n.Class() == 'Card':
                    cards.append(n)
            bakeSelectedNodes(newGroup, set(cards))
            keepSceneAndRemoveCrowdGeneratingNodes(newGroup)

            #Rename
            newGroupName = '%s_baked' % (group.name())
            newGroup.setName(newGroupName)

            #disable the dynamic knobs
            knobsToKeep = []
            knobsToKeep.append(newGroup['versionInfo'])

            newGroup['displayAOVs'].setValue(True)
            newGroup['displayPercentage'].setValue(100)

            values = []
            for key in newGroup.knobs().keys():
                if newGroup.knob(key) not in knobsToKeep:
                    try:
                        newGroup.knob(key).setEnabled(False)
                    except:
                        #not a user knob
                        pass
            versionInfo = newGroup['versionInfo'].value()
            versionInfo = versionInfo.replace('\'s', '\'s baked with')
            newGroup['versionInfo'].setValue(versionInfo)

            # pity the fool who doesn't use default node graph preferences
            prefs = nuke.toNode('preferences')
            gridWidth = prefs['GridWidth'].value()
            gridHeight = prefs['GridHeight'].value()

            # position the baked groupp set off from original group
            newGroup.setXpos(int(group.xpos() + gridWidth))
            newGroup.setYpos(int(group.ypos() + gridHeight * 2))

            bakeTileColor(newGroup)
コード例 #12
0
def namingConvention(node=nuke.thisParent()):
    if node['verControl'].value() == False:
        return "knobs"
    else:
        return "root"
コード例 #13
0
def qtPath(node=nuke.thisParent()):
    try:
        return outputPath() + shotName(node)
    except (AttributeError, TypeError):
        return "break"
コード例 #14
0
def shotName(node=nuke.thisParent()):
    if namingConvention(node) is "knobs":
        return sceneName() + "_" + sequence() + shotNumber(
        ) + "_" + descriptor() + "_" + shotVersion(node) + postVer(node)
    else:
        return nuke.root().name().split("/")[-1].split(".")[0]
コード例 #15
0
def shotName(node=nuke.thisParent()):
    if namingConvention(node) is "knobs":
        return sceneName() + "_" + sequence() + shotNumber() + "_" + descriptor() + "_" + shotVersion(node) + postVer(node)
    else: 
        return nuke.root().name().split("/")[-1].split(".")[0] 
コード例 #16
0
def qtPath(node=nuke.thisParent()):
    try:
        return outputPath() + shotName(node)
    except (AttributeError, TypeError):
        return "break"
コード例 #17
0
def namingConvention(node=nuke.thisParent()):
    if node['verControl'].value() == False:
        return "knobs"
    else:
        return "root"