Basically what I'm trying to do currently is set up a script in Nuke using python that takes nodes selected by the user and adds shuffle nodes to them for an easy compositing workflow. However I'm stuck on getting Nuke to add the shuffles onto the selected nodes. It works on 1 node when selected but if multiple are selected it only works on the first one selected. I asked a friend about it and she said to try a while loop so this is the code as follows:
while True:
if n in nuke.selectedNodes():
name = n.name()
node = nuke.toNode(name)
blue.setInput(0,node)
green.setInput(0,node)
red.setInput(0,node)
except StopIteration :
break
This all works well until the except part. I've ran the script while there wasn't an except and it froze Nuke which shows it's running infinitely but I need it to stop. Nuke tells me the except is a invalid syntax. Does anyone know how I can fix this or create a better work around for my process I'm trying to go for?