當前位置: 首頁>>代碼示例>>Python>>正文


Python nuke.selectedNodes方法代碼示例

本文整理匯總了Python中nuke.selectedNodes方法的典型用法代碼示例。如果您正苦於以下問題:Python nuke.selectedNodes方法的具體用法?Python nuke.selectedNodes怎麽用?Python nuke.selectedNodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nuke的用法示例。


在下文中一共展示了nuke.selectedNodes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: maintained_selection

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def maintained_selection():
    """Maintain selection during context

    Example:
        >>> with maintained_selection():
        ...     node['selected'].setValue(True)
        >>> print(node['selected'].value())
        False
    """
    previous_selection = nuke.selectedNodes()
    try:
        yield
    finally:
        # unselect all selection in case there is some
        current_seletion = nuke.selectedNodes()
        [n['selected'].setValue(False) for n in current_seletion]
        # and select all previously selected nodes
        if previous_selection:
            [n['selected'].setValue(True) for n in previous_selection] 
開發者ID:getavalon,項目名稱:core,代碼行數:21,代碼來源:lib.py

示例2: decryptomatte_nodes

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def decryptomatte_nodes(nodes, ask):
    gizmos = []

    for node in nodes:
        if node.Class() == "Cryptomatte":
            gizmos.append(node)
    if not gizmos:
        return

    if not ask or nuke.ask(('Replace %s Cryptomatte gizmos with expression nodes? '
        'Replaced Gizmos will be disabled and selected.') % (len(gizmos))):

        for gizmo in gizmos:
            _decryptomatte(gizmo)

        for node in nuke.selectedNodes():
            node.knob("selected").setValue(False)

        for gizmo in gizmos:
            gizmo.knob("selected").setValue(True)


#############################################
# Decryptomatte helpers
############################################# 
開發者ID:weijer,項目名稱:NukeToolSet,代碼行數:27,代碼來源:cryptomatte_utilities.py

示例3: decryptomatte_nodes

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def decryptomatte_nodes(nodes, ask):
    """ Replaces Cryptomatte gizmos with equivelant nodes. """
    gizmos = [n for n in nodes if n.Class() == "Cryptomatte"]
    if not gizmos:
        return

    if not ask or nuke.ask(('Replace %s Cryptomatte gizmos with expression nodes? '
        'Replaced Gizmos will be disabled and selected.') % len(gizmos)):

        for gizmo in gizmos:
            _decryptomatte(gizmo)

        for node in nuke.selectedNodes():
            node.knob("selected").setValue(False)

        for gizmo in gizmos:
            gizmo.knob("selected").setValue(True)


#############################################
# Decryptomatte helpers
############################################# 
開發者ID:Psyop,項目名稱:Cryptomatte,代碼行數:24,代碼來源:cryptomatte_utilities.py

示例4: process

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def process(self):
        from nukescripts import autoBackdrop

        instance = None

        if (self.options or {}).get("useSelection"):

            nodes = nuke.selectedNodes()
            if not nodes:
                nuke.message("Please select nodes that you "
                             "wish to add to a container")
                return

            elif len(nodes) == 1:
                # only one node is selected
                instance = nodes[0]

        if not instance:
            # Not using selection or multiple nodes selected
            bckd_node = autoBackdrop()
            bckd_node["tile_color"].setValue(int(self.node_color, 16))
            bckd_node["note_font_size"].setValue(24)
            bckd_node["label"].setValue("[{}]".format(self.name))

            instance = bckd_node

        # add avalon knobs
        lib.set_avalon_knob_data(instance, self.data)
        lib.add_publish_knob(instance)

        return instance 
開發者ID:getavalon,項目名稱:core,代碼行數:33,代碼來源:pipeline.py

示例5: reset_selection

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def reset_selection():
    """Deselect all selected nodes
    """
    for node in nuke.selectedNodes():
        node["selected"] = False 
開發者ID:getavalon,項目名稱:core,代碼行數:7,代碼來源:lib.py

示例6: duplicate_node

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def duplicate_node(self, node, to_file=None):
        """Slightly convoluted but reliable(?) way duplicate a node, using
        the same functionality as the regular copy and paste.
        Could almost be done tidily by doing:
        for knobname in src_node.knobs():
            value = src_node[knobname].toScript()
            new_node[knobname].fromScript(value)
        ..but this lacks some subtly like handling custom knobs
        to_file can be set to a string, and the node will be written to a
        file instead of duplicated in the tree
        """
        import nuke

        # Store selection
        orig_selection = nuke.selectedNodes()

        # Select only the target node
        [n["selected"].setValue(False) for n in nuke.selectedNodes()]
        node["selected"].setValue(True)

        # If writing to a file, do that, restore the selection and return
        if to_file is not None:
            nuke.nodeCopy(to_file)
            [n["selected"].setValue(False) for n in orig_selection]
            return

        # Copy the selected node and clear selection again
        nuke.nodeCopy("%clipboard%")
        node["selected"].setValue(False)

        if to_file is None:
            # If not writing to a file, call paste function, and the new node
            # becomes the selected
            nuke.nodePaste("%clipboard%")
            new_node = nuke.selectedNode()

        # Restore original selection
        [n["selected"].setValue(False) for n in nuke.selectedNodes()]
        [n["selected"].setValue(True) for n in orig_selection]

        return new_node 
開發者ID:bumpybox,項目名稱:pyblish-bumpybox,代碼行數:43,代碼來源:extract_review.py

示例7: process

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def process(self, instance):
        import os

        import nuke

        if not instance.data["publish"]:
            return

        file_path = instance.data["output_path"]
        directory = os.path.dirname(file_path)

        # Create workspace if necessary
        if not os.path.exists(directory):
            os.makedirs(directory)

        # Export gizmo
        # Deselect all nodes
        for node in nuke.selectedNodes():
            node["selected"].setValue(False)

        instance[0]["selected"].setValue(True)

        nuke.nodeCopy(file_path)

        data = ""
        with open(file_path, "r") as f:
            data = f.read()

        data = data.replace("set cut_paste_input [stack 0]\n", "")
        data = data.replace("push $cut_paste_input\n", "")
        data = data.replace("Group {\n", "Gizmo {\n")

        with open(file_path, "w") as f:
            f.write(data) 
開發者ID:bumpybox,項目名稱:pyblish-bumpybox,代碼行數:36,代碼來源:extract_group.py

示例8: process

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def process(self, context):
        import nuke
        context.data["selection"] = nuke.selectedNodes() 
開發者ID:bumpybox,項目名稱:pyblish-bumpybox,代碼行數:5,代碼來源:collect_selection.py

示例9: decryptomatte_selected

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def decryptomatte_selected(ask=False):
    decryptomatte_nodes(nuke.selectedNodes(), ask) 
開發者ID:weijer,項目名稱:NukeToolSet,代碼行數:4,代碼來源:cryptomatte_utilities.py

示例10: selectNodes

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def selectNodes(self):
        selectNodes = nuke.selectedNodes()
        if selectNodes:
            self.upLocalizationPolicy(selectNodes)
        else:
            nuke.message("請選擇節點") 
開發者ID:weijer,項目名稱:NukeToolSet,代碼行數:8,代碼來源:setLocallisation.py

示例11: toggleInput

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def toggleInput():
    sel = nuke.selectedNodes()
    if len(sel):
        toggleVal = not bool(sel[0].knob('hide_input').getValue())
        for node in sel:
            if node.knob('hide_input') != None:
                node.knob('hide_input').setValue(toggleVal)
    else:
        nodes = nuke.allNodes()
        toggleVal = not bool(nodes[0].knob('hide_input').getValue())
        for node in nodes:
            if node.knob('hide_input') != None:
                node.knob('hide_input').setValue(toggleVal) 
開發者ID:weijer,項目名稱:NukeToolSet,代碼行數:15,代碼來源:toggle_input.py

示例12: shuffle

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def shuffle():
    for selected_node in nuke.selectedNodes():
        if selected_node.Class() == 'Read':
            all_channels = selected_node.channels()
            all_channels = list(set([i.split('.')[0] for i in all_channels]))
            for channel in all_channels:
                shuffle_node = nuke.createNode('Shuffle', inpanel=False)
                shuffle_node['name'].setValue(channel+'_'+selected_node['name'].getValue())
                shuffle_node['in'].setValue(channel)
                shuffle_node.setInput(0, selected_node)
                shuffle_node['postage_stamp'].setValue(1) 
開發者ID:weijer,項目名稱:NukeToolSet,代碼行數:13,代碼來源:ListShuffle.py

示例13: doIt

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def doIt(self):
        nodesToProcess = nuke.selectedNodes() if self.nodeSelectionChoice.currentIndex() == 1 else nuke.allNodes()
        processFunction = makeNodesAbsolute if self.commandTypeChoice.currentIndex() == 1 else makeNodesRelative

        filteredNodes = self.filterByNodeType(nodesToProcess)
        
        choosenKnobTypes = self.collectChoosenTypes(self.supportedKnobTypes)
        
        result = processFunction(filteredNodes,choosenKnobTypes)

        self.warningsText.setText("\n\n".join(result['warnings']))
        self.resultsText.setText("\n".join(result['replacements'])) 
開發者ID:weijer,項目名稱:NukeToolSet,代碼行數:14,代碼來源:relativeFilePath.py

示例14: open_selected_nodes_in_file_browser

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def open_selected_nodes_in_file_browser():
    """opens selected node in filebrowser
    """
    nodes = nuke.selectedNodes()
    for node in nodes:
        open_node_in_file_browser(node) 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:8,代碼來源:__init__.py

示例15: create_auto_crop_writer

# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def create_auto_crop_writer():
    """creates a write node for every selected node, and sets the autocrop flag
    to auto crop the output for fast reading
    """
    # get selected nodes and deselect them
    nodes = nuke.selectedNodes()
    [node.setSelected(False) for node in nodes]

    write_nodes = []

    for node in nodes:
        write_node = nuke.createNode('Write')
        file_path = node['file'].value()
        filename_with_number_seq, ext = os.path.splitext(file_path)
        filename, number_seq = os.path.splitext(filename_with_number_seq)

        write_node['file'].setValue(
            filename + '_auto_cropped' + number_seq + ext
        )
        write_node['channels'].setValue('all')
        write_node['autocrop'].setValue(True)
        write_node.setXpos(node.xpos() + 100)
        write_node.setYpos(node.ypos())

        # connect it to the original node
        write_node.setInput(0, node)
        write_node.setSelected(False)

        # store the write node
        write_nodes.append(write_node)

    # connect the write nodes to afanasy if afanasy exists
    try:
        afanasy = nuke.createNode('afanasy')
        for i, node in enumerate(write_nodes):
            afanasy.setInput(i, node)
    except RuntimeError:
        pass 
開發者ID:eoyilmaz,項目名稱:anima,代碼行數:40,代碼來源:__init__.py


注:本文中的nuke.selectedNodes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。