# Copyright (c) 2009 The Foundry Visionmongers Ltd. All Rights Reserved.
import nuke_internal as nuke
[docs]def color_nodes():
"""Set all selected nodes to be the same colour as the first selected node."""
nodes = nuke.selectedNodes(recursive=True)
if nodes is None:
nuke.message("No node selected")
return
n = nodes[0]
c = n.knob("tile_color")
c = nuke.getColor(c.value())
n.knob("tile_color").setValue(c)
# get other nodes:
for i in nodes:
i.knob("tile_color").setValue(c)
nuke.modified(True)
[docs]def node_delete(popupOnError = False):
nodes = nuke.dependentNodes(nuke.EXPRESSIONS | nuke.LINKINPUTS | nuke.HIDDEN_INPUTS, nuke.selectedNodes(recursive=True), False)
link_nodes = nuke.dependentNodes(nuke.LINKNODE_INPUTS, nuke.selectedNodes(recursive=True), False)
def construct_nodes_str(nodes):
l = ""
for i in nodes:
if i.Class() != "Viewer":
l = l + i.fullName() + ", "
l = l[0:len(l)-2]
return l
nodes_str = construct_nodes_str(nodes)
link_nodes_str = construct_nodes_str(link_nodes)
if len(link_nodes_str) > 0:
if not nuke.ask("The nodes you are deleting are used by the following nodes:\n" + link_nodes_str + \
"\nThese nodes will be unlinked. Are you sure you want to delete?"):
return
if len(nodes_str) > 0:
if not nuke.ask("The nodes you are deleting are used by expressions in:\n" + nodes_str + \
"\nAre you sure you want to delete?"):
return
nuke.nodeDelete(popupOnError)