Home Coding, Scripting, Shaders

Mel script is it possible to store UV shells into an array?

polycount sponsor
Offline / Send Message
malcolm polycount sponsor
I'm trying to select UV shells by index and then run some code and then select the next UV shell and run that same code, etc. Imagine if you wanted to scale each UV shell by 50%, that's not what I need to do, but if I could figure out how to select each shell one at a time in the script that would solve my problem. Is this possible, I searched for about a day and there's nothing in the documentation.

Replies

  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    try texGetShells. its located in C:\Autodesk\Maya20XX\scripts\others\texGetShells.mel  its a hidden mel script thats not documented. Its being used in a lot of the functions inside uv toolkit. I have been digging around that folder for some hidden cmds for mu UDIM layout script ive been working on forever.

  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Interesting, any idea why trying to store this in an array and then select it errors?
    $tempShell = `texGetShells`;
    select $tempShell;
    // Error: line 1: Invalid attribute name: pPlane1.map[1] pPlane1.map[5:6] pPlane1.map[11] //


  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Update, someone from the Autodesk forum was able to figure out how to convert the first shell in the array so you can select it, now I need to work on storing each shell into it's own array to loop through and run my code on which I think I know how to do using the size command and a counter. Will report back if I get it figured out.

    $tempShell = `texGetShells`;
    tokenize($tempShell[0], $tempShell);
    select $tempShell;

  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Okay got it working. Here is the code, just replace the polyEditUV line with whatever custom code you want to run on selected UV shells.

    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;
         }

  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    Thanks for sharing this. Malcolm I was hesitant on using tokenize. But if it works it works.
Sign In or Register to comment.