当前位置: 首页>>代码示例>>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;未经允许,请勿转载。