Darkgaze
Darkgaze

Reputation: 2573

MEL duplicateReference return value?

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.

Upvotes: 0

Views: 393

Answers (1)

Regnareb
Regnareb

Reputation: 144

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.

Upvotes: 1

Related Questions