Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Whats the Easiest way select Uvs by UVTILE/UDIM Patches?

Whats the Easiest way select Uvs by UVTILE/UDIM Patches?

absoluteKelvin
Collaborator Collaborator
3,248 Views
8 Replies
Message 1 of 9

Whats the Easiest way select Uvs by UVTILE/UDIM Patches?

absoluteKelvin
Collaborator
Collaborator

I've been looking for a easy way to select uvs by Uv patches. Similar to Mari's select uv Patches.

 

I would appreciate if anyone can point me in the right direction

https://www.artstation.com/kelvintam
0 Likes
Accepted solutions (1)
3,249 Views
8 Replies
Replies (8)
Message 2 of 9

mspeer
Consultant
Consultant

Hi!

 

I don't know if there is an easier way, but creating a function that iterates over all UV's and selects(/skips) the ones you want(/don't want), based on UV values, seems to be very simple and easy to do.

0 Likes
Message 3 of 9

absoluteKelvin
Collaborator
Collaborator

thanks for the reply. But preferably I dont have to get into Api or C++ because its way to advance for me. My friend help me built one in Pymel that works on only a single object, but Speed is an issue.

https://www.artstation.com/kelvintam
0 Likes
Message 4 of 9

absoluteKelvin
Collaborator
Collaborator

I forgot to mention that I also tried to do it In mel. But due to the broken selection constraint with uvs, i was unable to create a decent working script for the UV patch selection.

https://www.artstation.com/kelvintam
0 Likes
Message 5 of 9

mspeer
Consultant
Consultant

Hi!

 

I meant scripting, but you don't need any selection constraints in MEL, just check all UV's. Of course scripting is not as fast as a plug-in, but this should not be an issue here.

0 Likes
Message 6 of 9

absoluteKelvin
Collaborator
Collaborator

with a mesh thats under 100k, testing uv with polyedituv -query works. But anything more than 100k will freeze maya. So thats why Im looking for a more effective method. Thanks for the help anyways mspeer.

https://www.artstation.com/kelvintam
0 Likes
Message 7 of 9

mspeer
Consultant
Consultant

Hi!

 

It will not freeze Maya, but the calculation time may be not acceptable for you (a few seconds). But this is a limitation of script execution.

0 Likes
Message 8 of 9

absoluteKelvin
Collaborator
Collaborator

 

global proc selectUDIMPatch(){ 
    global float $uNum,$vNum;
    convertUDIM;        
    float $uPoint = $uNum + 0.5;
    float $vPoint = $vNum + 0.5;
    polySelectConstraint -m 3 -t 0x0010 -d 1 -dp $uPoint $vPoint 0 -db 0 0.7075; // select uv covering the whole tile.
    ConvertSelectionToUVShellBorder; // convert to uv border to save time and iterations 
    string $preProcessSel[] = `ls -sl -fl`; 
    polySelectConstraint -m 0 -t 0x0010 -d 0 -dp 0 0 0 -db 0 0;// Zero out select Constraint
    resetPolySelectConstraint;
        
    float $minU = $uNum; //
    float $minV = $vNum; ////
    float $maxU = $uNum + 1; //// set boundary
    float $maxV = $vNum + 1; //
    
    string $finalUV[]; //variable for storing UV selection after testing
    int $numUVs = `size $preProcessSel`;
    int $MaxAmount = $numUVs * 2;
    int $pAmount = 0;
    progressWindow
        -title "Selecting UV Patch"
        -maxValue $MaxAmount
        -progress $pAmount
        -status "Selecting: 0%"
        -isInterruptable false;
        
    float $Uarray[]; // using array because I read somewhere that matrix doesn't handle strings. MEL limitation
    float $Varray[];
    float $tempUV[];
    
    for($i = 0; $i < ($numUVs)*2; $i++){
         $tempUV = `polyEditUV -q -u -v $preProcessSel`;
        }
    
    for($j = 0; $j < ($numUVs)*2; $j++){ //store u into seperate array
       $Uarray[size($Uarray)] = $tempUV[$j];
       $j++;
       }

    for($k = 1; $k < ($numUVs)*2; $k++){ //store v into seperate array
       $Varray [size($Varray)] = $tempUV[$k];
       $k++;
       }
       
    for($L = 0; $L < ($numUVs); $L++){ //testing to see if uvs lies within the tile boundary then storing it
        if ($Uarray[$L] > $minU && $Uarray[$L] < $maxU && $Varray[$L] > $minV && $Varray[$L] < $maxV){
            $finalUV[size($finalUV)] = $preProcessSel[$L];
        }
        else{
            continue;
        }
    }
    select -replace $finalUV;
    SelectUVShell;
    //inViewMessage -smg ("UDIM Patch " + $UDIMinput + " Selected") -pos topRight -bkc 0x00000000 -fade;
    progressWindow -endProgress; 
}

You were right mspeer, after some more testing i was able to get a script functioning. Since it runs for more than a few seconds. I want to create a progresswindow for User to see, so they can get some feedback. Problem is I have no idea where to put the $pAmount counter in the proc, since i have several for loops. Im also not sure about what to set the Max Amount as. I was hoping you can help me a bit Mspeer.

 

 

 

https://www.artstation.com/kelvintam
0 Likes
Message 9 of 9

mspeer
Consultant
Consultant
Accepted solution

Hi!

 

Not sure what i could can tell more than what's included in the Maya documentation about this command.

- progress 50 maxValue 100 = 50%.

- progress 300 maxValue 600 = 50%.

 

Your maxValue should be the amount of UV's or U + V coordinates.

0 Likes