Same function with one line cleaned up (sorry, it’s been a long day...)
def recursiveFindReads(node=None, group=nuke.root(), reads=None):
if reads is None:
reads = set()
if node is None:
node = nuke.selectedNode() # Let this error on purpose if no node
selected
for n in node.dependencies(nuke.INPUTS | nuke.HIDDEN_INPUTS):
cls = n.Class()
if cls == 'Read':
reads.add(n)
elif cls == 'Group':
reads = reads.union(recursiveFindReads(node=nuke.allNodes('Output',
group=n)[0], group=n, reads=reads))
else:
reads = reads.union(recursiveFindReads(node=n, group=group,
reads=reads))
return reads
If you really DO need to select them, just run this:
nukescripts.clear_selection_recursive()
[n.setSelected(True) for n in recursiveFindReads()]
-Nathan
From: invisfx
Sent: Thursday, April 26, 2012 7:35 PM
To: [email protected]
Subject: [Nuke-python] Re: selecting a node from its name
what I meant by loop is
depNodes = selectedNode.dependencies()
only selects the immediate dependencies, not all the way up the graph. So I
have to re select those nodes and do it again.
or am I wrong?
--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python