0

I found this on the script called with right click on outliner -> reference -> duplicate, and found the original script.

I select a referenced item in my scene.

Then, I do: string $test = duplicateReference 0 " ";

It doesn't return the new reference. How do I get the new item created on the outliner from this command?

It doesn't have any reference on Python or MEL, if you look for it.

Darkgaze
  • 2,280
  • 6
  • 36
  • 59

1 Answers1

1

When it is not in the documentation, try the MEL command whatIs

whatIs duplicateReference;

It will return the mel file where that function is written.

You can open the file in a text editor to see that it doesn't return anything. Sometimes it select the nodes, sometimes not. In those cases the best thing to do is to list the nodes before the action and after, then do the difference:

def getNewNodesCreated(_function):
    """ Return the new nodes created after the execution of a function """
    before = cmds.ls(long=True)
    eval(_function)
    after = cmds.ls(long=True)
    return list(set(after) - set(before))

It will return all the new nodes created.

Regnareb
  • 134
  • 6
  • As I said, I found the code "and found the original script." using this same method. But I never thought that script would call another script. In fact it is doing the same stupid thing I ended up doing, so I'll do it myself . What a nonsense! – Darkgaze Sep 13 '16 at 09:37