本文整理匯總了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]
示例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
#############################################
示例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
#############################################
示例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
示例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
示例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
示例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)
示例8: process
# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def process(self, context):
import nuke
context.data["selection"] = nuke.selectedNodes()
示例9: decryptomatte_selected
# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def decryptomatte_selected(ask=False):
decryptomatte_nodes(nuke.selectedNodes(), ask)
示例10: selectNodes
# 需要導入模塊: import nuke [as 別名]
# 或者: from nuke import selectedNodes [as 別名]
def selectNodes(self):
selectNodes = nuke.selectedNodes()
if selectNodes:
self.upLocalizationPolicy(selectNodes)
else:
nuke.message("請選擇節點")
示例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)
示例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)
示例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']))
示例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)
示例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