nuke.selectedNodes() will return the selected nodes in the order they appear on the node stack. In other words, the most recently selected or created node will be at the top of the stack (and thus at the front of the returned list).

When you paste them, they are created in script order (imagine reading through a Nuke script in a text editor and creating nodes as you encounter their class names). Thus, the most recently created node (the "bottom" node in a simple tree) will end up at the top of the stack after pasting.

However, there is no way to predict the order in which a user selected a collection of nodes. You could try to re-sort the selection into topological order using one or more simple graph algorithms, but without knowing the exact method Nuke uses to decompose a DAG, it may be hard to cover all cases.

If you can provide a little more information about what you're trying to do, it may help inform some solutions.

-Nathan

-----Original Message----- From: Adam Wierzchowski
Sent: Tuesday, June 04, 2013 9:53 AM
To: Nuke Python discussion
Subject: [Nuke-python] Node order after nodeCopy and nodePaste

Hi,
I'm modifying default copy paste behaviour

for n in nuke.selectedNodes():
  #store some params in global array
nuke.nodeCopy(nukescripts.cut_paste_file())

nuke.nodePaste(nukescripts.cut_paste_file())
for n in nuke.selectedNodes():
  #restore some params from global array

Problem is that node order in first loop is different from order in
second. For example

Copy:
ColorBars1
PostageStamp1

Paste:
PostageStamp2
ColorBars2

Is there any pattern which could be used to correlate copied and pasted
nodes?

regards
Adam
_______________________________________________
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

Reply via email to