View Full Version : uv selection info question
12-08-2011, 03:08 AM
If I have uvs selected for an object, I duplicate that object and want to get the same exact uv selection but on the duplicated object, how would I do that?
Ex. let's say I have these uvs selected.
I duplicate pCube1 and get pCube2.
I want to select pCube2.map[6:10] .
Other than slicing the object name off the index name and rebuilding the list, is there a Maya Python command somewhere I can use to save the uv info without the object name?
12-08-2011, 10:22 AM
not really. your question is also a little vague. do you want a solution to process the exact case you've given (i.e. the single static string "pCube1.map[6:10]") or do you just want a way of stroing arbitrary component ids, and then applying those to another object name?
# select some uvs on an object, then:
uvIds = [int(id.split('[').split(']')) for id in mc.filterExpand(sm=35)]
new = ['pCube2.map[%d]' % id for id in uvIds]
this example code will take the selected uvs and create a python list of ints. The second line will then map that list onto a new list of strings, using the supplied name. You could make it work with any component types by changing the sm= flag (or adding more sm= flags).
This is one basic way of doing it with python list comprehensions, but there are others.
12-08-2011, 10:52 AM
Thank you for your response. I am sorry I was too vague in my question. Yes, I just want a way of storing arbitrary component ids and then applying them to a duplicate object.
Your answer is what I was looking for though I was just wondering if there was some maya command I was not aware of.
Originally, I thought I might even have to slice off the name of the object before the ' . ' and add the string to each component in the list but I thought it was awkward.
Thank you again!
12-08-2011, 11:01 AM
don't apologise, I wasn't telling you off! ;) :D I was just qualifying why my post may not have been the answer you were looking for. :)
Originally, I thought I might even have to slice off the name of the object before the ' . ' and add the string to each component in the list but I thought it was awkwardyou could just as easily (if not easier) do it this way using the exact same method I gave.
uvIds = [id.split('.') for id in mc.filterExpand(sm=35)]
new = ['pCube2.%s' % id for id in uvIds]
12-08-2011, 11:01 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.