Mel script, is it possible to identify UV shells and store them in an array?

Mel script, is it possible to identify UV shells and store them in an array?

malcolm_341
Collaborator Collaborator
4,102 Views
9 Replies
Message 1 of 10

Mel script, is it possible to identify UV shells and store them in an array?

malcolm_341
Collaborator
Collaborator

Hi there, I'm an artist learning mel. I need to store the selected UV shells into an array, but I can't find anything in the documentation or online. Is there really no concept of a UV shell index in Maya. Basically I need to perform an action on each shell so I need to store them in in an array so I can select them one at a time. For example, select first shell, scale it by 50%, select second shell scale by 50%, etc. That's not actually what I need to do, but if that's possible that will solve my more complex problem.

0 Likes
Accepted solutions (1)
4,103 Views
9 Replies
Replies (9)
Message 2 of 10

olarn
Advocate
Advocate
0 Likes
Message 3 of 10

malcolm_341
Collaborator
Collaborator

I already looked at that before posting, unless I'm not understanding how to use that command it's pretty much useless since there's no way to select anything that command prints out. All it does is tell you what index the UV shell is, but there is no way to select that index because UV shells don't exist as far as I can tell?

0 Likes
Message 4 of 10

olarn
Advocate
Advocate

Im afraid that you're going to have to construct your own uv shell look up from those list.

Event maya default "expand uv to uv shell" script have to resort to pretty roundabout way to get those lists.

C:\Program Files\Autodesk\Maya201X\scripts\others\polySelectBorderShell.mel

0 Likes
Message 5 of 10

malcolm_341
Collaborator
Collaborator

I don't think I'm advanced enough, If I could find a way to assign the index to a variable then I might be able to work it out I did find this command which works, but for some reason I can't select it after without getting an error?

$tempShell = `texGetShells`;
select $tempShell;
// Error: line 1: Invalid attribute name: pPlane1.map[1] pPlane1.map[5:6] pPlane1.map[11] //

0 Likes
Message 6 of 10

olarn
Advocate
Advocate
Accepted solution

Because all those lines are jammed in to the first item of tempShell string array instead of one each as "select" expected.

$tempShell = `texGetShells`; // type is string[]
tokenize($tempShell[0], $tempShell); // ["xx.map[0] xx.map[1]",] -> ["xx.map[0]","xx.map[1]"]
select $tempShell;
Message 7 of 10

malcolm_341
Collaborator
Collaborator

Oh wow, I'm not familiar with the tokenize command yet I'll need to read the docs on this today. This looks like I'll need to create a counter and then loop through all the items and update the counter and use tekenize to store each UV shell as an array of UVs I can then select and run my code on. Does that sound like the right way to go?

0 Likes
Message 8 of 10

malcolm_341
Collaborator
Collaborator

Here's how I ended up solving it thanks to olarn for tokenizing it for me. Still not confident with that command. In this example the for loop performs a rotate on each UV shell individual and then ends when it reaches the number of UV shells the user had originally selected.

 

ConvertSelectionToUVShell;
$shellUVs = `ls -sl`;

 

$findShells = `texGetShells`;
$numbShells = `size $findShells`;
$shellIndex = 0;

 

     for ($item = 0; $item < $numbShells; ++$item)
     {
          select $shellUVs;
          $findShells = `texGetShells`;
          tokenize($findShells[$shellIndex], $findShells); // ["xx.map[0] xx.map[1]",] -> ["xx.map[0]","xx.map[1]"]
          select $findShells;
          polyEditUV -pu 0.25 -pv 0.75 -a -14.449228 -rr 1 ;

          $shellIndex = $shellIndex + 1;
     }

Message 9 of 10

olarn
Advocate
Advocate

If you've just beginning to script, I would recommend learning python instead.

In mel you'll spend majority of the time fighting with the language itself..

 

just fyi legacy mel code can be call to and from python

http://help.autodesk.com/cloudhelp/2018/ENU/Maya-Tech-Docs/CommandsPython/eval.html

0 Likes
Message 10 of 10

malcolm_341
Collaborator
Collaborator

Thanks for the help, Python is on the road map once I become more comfortable with coding concepts, I'm self teaching so mel seems like a good way to understand the fundamentals. What's the main advantage over mel in this particular situation, would Python be able to select the UVs shells easier?

0 Likes