[英]How to iterate through more than one nuke node class using nuke.allNodes() in a for loop?
nuke.allNodes() can filter for one specific node class ie nuke.allNodes("Transform"). nuke.allNodes()可以过滤一种特定的节点类,即nuke.allNodes(“ Transform”)。 But how to do it if i want to have it filter more?
但是,如果我想让它更多地过滤,该怎么办? Some work around?
有一些工作吗?
perhaps place them in: var = [] 也许将它们放在:var = []
But how do i access lets say motionblur value in a example (this dose not work): 但是我如何访问示例中的运动模糊值(此方法无效):
for i in var:
print i.knob("motionblur").value() #Transform nuke node class
print i.knob("samples").value() #ScanlineRender nuke node class
Thank you. 谢谢。
I'm a little confused because in your code you have i.knob("motionblur")
. 我有点困惑,因为在您的代码中有
i.knob("motionblur")
。 The string in .knob()
should be a name of a knob not the name of a node type. .knob()
的字符串应该是旋钮的名称,而不是节点类型的名称。
I would suggest iterating through all the nodes and checking the type of each node. 我建议遍历所有节点并检查每个节点的类型。 Then do whatever you need to on that type of node.
然后在该类型的节点上执行所需的任何操作。
for i in nuke.allNodes():
if i.Class() == "MotionBlur":
#DO SOMETHING
elif i.Class() == "Transform":
#DO SOMETHING
If you are doing the same thing to both types of nodes, you could merge two lists and iterate over it. 如果对两种类型的节点执行相同的操作,则可以合并两个列表并对其进行迭代。
n = nuke.allNodes("MotionBlur")
n.extend(nuke.allNodes("Transform"))
for i in n:
#DO SOMETHING TO BOTH TYPES
I don't know what you are specifically trying to achieve, so this may not be the most efficient method. 我不知道您要具体实现什么,因此这可能不是最有效的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.