Questions concerning selecting/identifying things via scripting

Questions concerning selecting/identifying things via scripting

duedoman
Explorer Explorer
650 Views
2 Replies
Message 1 of 3

Questions concerning selecting/identifying things via scripting

duedoman
Explorer
Explorer

I am aware of standard ways of selecting object, such as selecting it by an explicit name, or via a namespace grouping... but what if the names of the things I place into my scene are subject to change and I want a script to be able to select things by their structure? Is there some kind of hexadecimal or numeric identifier that I can use which is attached to all things in a given scene?

 

The reason I ask is that often times I need scripts to remember the user's selection, but I don't want my script to break the moment they decide to change the name of something.

0 Likes
Accepted solutions (1)
651 Views
2 Replies
Replies (2)
Message 2 of 3

RFlannery1
Collaborator
Collaborator
Accepted solution

As a matter of fact, there is.  Maya 2016 introduced UUIDs on all nodes.  So if you want to get the UUID of all selected objects, you can do the following:

cmds.ls(sl=True, uuid=True)

And if you need to get the name back from the uuid, you can do something like this:

cmds.ls(someUuid)
Message 3 of 3

duedoman
Explorer
Explorer

Thank you so much for this, exactly what I was looking for.

0 Likes