简体   繁体   中英

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"). But how to do it if i want to have it filter more? Some work around?

perhaps place them in: 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") . The string in .knob() should be a name of a knob not the name of a node type.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM