试试下面的一个。将此代码用于具有特定名称的节点:
def removeOverride():
nuke.toNode("Remove1")['operation'].setValue('keep')
nuke.toNode("Remove1")['channels'].setValue('rgb')
nuke.addOnUserCreate(removeOverride(), nodeClass='Remove')
# use UpperCamelCasing for any class name ('Blur','Read','Remove')
同样对于创建的任何后续节点,请使用以下代码:
def removeOverride():
for node in nuke.allNodes():
if node.Class() == "Remove":
node["operation"].setValue("keep")
node["channels"].setValue("rgb")
removeOverride()
# OR
nuke.addOnUserCreate(removeOverride(), nodeClass='Remove')
并且最后一个使用nuke.selectedNodes()
andnuke.thisNode()
方法的配置适用于 DAG 中的选定节点:
def removeOverride():
thisNode = nuke.thisNode()
rootDAG = nuke.root()
with rootDAG:
allNodesSelected = nuke.selectedNodes()
try:
allNodesSelected.remove(thisNode)
except:
pass
for node in allNodesSelected:
node["operation"].setValue("keep")
node["channels"].setValue("rgb")
return allNodesSelected
nuke.addOnUserCreate(removeOverride(), nodeClass='Remove')