It’s much more efficient to simply filter the nodes as you assemble a list:
notViewers = [n for n in nuke.selectedNodes() if n.Class() != 'Viewer'] -Nathan From: Nico Dufort Sent: Friday, January 04, 2013 3:56 PM To: Nuke user discussion Cc: Nuke Python discussion Subject: [Nuke-python] Re: [Nuke-users] How to get all but one class in nuke.selectedNodes…? Your code does nothing to remove anything from your collection. Did you mean something similar to this: collection = nuke.selectedNodes() for n in collection[:]: # use a copy of your list to be able to remove items from it if n.Class() == 'Viewer': n['selected'].setValue(False) collection.remove(n) At this point, your viewers are deselected and not part of your collection. That being said, you mentioned something about them being "connected", but your code did not address anything with connection. Is this what you were after, or you really needed something around the connection between nodes and viewers to be dealt with? Cheers. nico On Fri, Jan 4, 2013 at 3:44 PM, Rich Bobo <richb...@mac.com> wrote: Hi, I can't get my brain to figure this out, so I'm reaching out to the "collective brain"… 8^) I need a collection of nodes, minus any connected Viewers. So, selNodes = nuke.selectedNodes() --- but without any Viewers that may be connected... I can do this: selNodes = nuke.selectedNodes() for node in selNodes: if node.Class() == 'Viewer': node["selected"].setValue(False) else: node['selected'].setValue(True) However, that does not change the original collection of nodes - it still has all of the nodes that were connected when I set the origin variable, including any Viewers. I want to *remove* any Viewer class nodes from the selNodes collection! I know it's probably simple, but it's been a long week… Any help? Thanks! Rich Rich Bobo Senior VFX Compositor Armstrong-White http://armstrong-white.com/ Email: richb...@mac.com Mobile: (248) 840-2665 Web: http://richbobo.com/ "Until one is committed, there is hesitancy, the chance to draw back ineffectiveness. Concerning all acts of initiative and creation, there is one elementary rule - the ignorance of which kills countless ideas and splendid plans; that the moment one definitely commits oneself, then Providence moves too. Things occur to help that would never otherwise have occurred. A whole stream of events issues from the choice, raising in one's favour all manner of unforeseen incidents and meetings and material assistance, which no man could have dreamed would have come his way." - Goethe _______________________________________________ Nuke-users mailing list nuke-us...@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users -- "Attention, attention. Here and now, boys," the mynah repeated. "Here and now, boys." -------------------------------------------------------------------------------- _______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python