Home Technical Talk

(MEL)Wierd PolySelectionConstraint bug

polycounter lvl 16
Offline / Send Message
onionhead_o polycounter lvl 16
I can't seem to set the correct value in Poly selection Constraint on Texture Offset (UV)

polySelectConstraint -mode 3 -type 0x0010 -dist 1 -distpoint 0.5 0.5  0 -distbound 0 0.5;

distbound is suppose to set the Min and Max for distance. But it refuses to set to 0.5, whenever it executes it jumps down to 0.25. It is a wierd behavior. Also when I try to do it manually in Selection constraint options, it won't work either.

Replies

  • Deadly Nightshade
    Options
    Offline / Send Message
    Deadly Nightshade polycounter lvl 10
    If this is true then it's likely to be an error in the actual command. Maybe whoever coded it had a reason to set the cap to 0.25 - who knows?
    You will eventually stumble upon commands that behave weird like this, especially as you do more and more coding. There isn't much to do about it other than either work around it or contact Autodesk directly.
  • Klaudio2U
    Options
    Offline / Send Message
    Klaudio2U polycounter lvl 8
    Try instead of  "-distbound 0 0.5;" use "-distbound 0 0.7071;  

    This will set Max Distance in Use Constraint to 0.5  - not sure why it happens but there you have it.
  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16
    DeadlyNightshade: just wanted to see if it is user error on my end or actual bug.

    Klaudio2U: thanks. It seems that even if I set the  -distbound 0 0.7071. the uv selection still seems to be inaccurate. So Im gona have to do a lot more testing to make my script work.
  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16
    heres part of the script that ive been working on if anyone is interested. Essentially what its suppose to do is select the UDIM patch user specifies. For example if user say select 1001 UDIM (u1_v1) uv, it will select all the uvs within the UDIM tile boundary. Its using PolySelectconstraint as the backbone for the uv selection. Unfortunately, due to the inaccuracy of the maximum distance boundary, I had to do a lot of testing for the limits. Also In my findings, because its distance based on a specified point in the u and v space. It selects uvs in a radial falloff. Therefore I have to run it in several passes to select the uvs near the corner of the uv tile.

    global proc selectUDIMPatch(){
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.5 0.5 0 -db 0 0.5;
        string $Cnstpass1[] = `ls -sl -fl`; //center limit
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.75 0.75 0 -db 0 0.25;
        string $Cnstpass2[] = `ls -sl -fl`; //top right center limit
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.9 0.9 0 -db 0 0.1;
        string $Cnstpass3[] = `ls -sl -fl`; //top right small limit
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.1 0.9 0 -db 0 0.1;
        string $Cnstpass4[] = `ls -sl -fl`; //top left small limit
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.1 0.1 0 -db 0 0.1;
        string $Cnstpass5[] = `ls -sl -fl`; //botton left limit
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.99 0.99 0 -db 0 0.01;
        string $Cnstpass6[] = `ls -sl -fl`; //tiny right limit
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.05 0.05 0 -db 0 0.01;
        string $Cnstpass7[] = `ls -sl -fl`; //tiny left limit
        resetPolySelectConstraint;
        string $storedUV[];
        string $strAryA, $strAryB;
            for( $i=1; $i<6; ++$i){
                $strAryA = ("$Cnstpass" + $i);
                $strAryB = ("$Cnstpass" + ($i+1));
                $storedUVs[] = stringArrayCatenate($strAryA,$strAryB);// combine all the string arrays into one
                }
                string $finalUVs[] = stringArrayRemoveDuplicates $storedUVs; // remove duplicate of uvs due to overlap
    select $finalUVs;
    }
    selectUDIMPatch;

    if you run it now it will give this sort of error
    // Error: $storedUVs[] = stringArrayCatenate($strAryA,$strAryB);
    //
    // Error: Line 22.24: Syntax error //
    // Error: string $finalUVs[] = stringArrayRemoveDuplicates $storedUVs;
    //
    // Error: Line 24.71: Invalid use of Maya object "stringArrayRemoveDuplicates". //





  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16

    After getting the above code to work by concatenate each string array manually instead of using a for loop to do it. I realize that this method is way too slow. So I decided to use a different approach. Instead of using multiple polySelectConstraint , use only one with a bigger range which selects the uvs covering the tile with some overlap due to the radial selection> then I test those uvs against the min and max of the UV tile > after correct uvs are stored, it reselects them.

    but now comes another issue, if I run the code now, it seems to ignore my if statement and store all the uvs instead of storing the correct uvs only.


    I would appreciate it if someone can give me some pointers.
    global proc selectUDIMPatchalt(){ 
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp 0.5 0.5 0 -db 0 0.7075; // select uv covering the whole tile.
        resetPolySelectConstraint;
        string $ConstraintSel[] = `ls -sl -fl`; //store initial selection
        select -clear;
        int $minU = 0;
        int $minV = 0;
        int $maxU = 1;
        int $maxV = 1;
        string $finalUV[]; //variable for storing UV selection after testing
        int $numUVs = `size $ConstraintSel`;
        float $uvLoc[];
            for($i = 0; $i < ($numUVs*2); $i++) { // *2 because uv location is store as pairs, odd number for u, even number for v
               $uvLoc = `polyEditUV -q -u -v $ConstraintSel`; //store u and v location for each uv in $ConstraintSel
               }
               
            for($j = 0; $j < $numUVs; $j++){
                   if (($j % 2 == 1) && ($uvLoc[$j] > $minU) && ($uvLoc[$j] < $maxU)){ //odd number testing
                       $finalUV = $ConstraintSel;
                      }
                      
                   if (($j % 2 == 0) && ($uvLoc[$j] > $minV) && ($uvLoc[$j] < $maxV)){ //even number testing
                       $finalUV = $ConstraintSel;
                   }
                   else{
                       continue;
                   }
            }
            print $finalUV;
            select $finalUV;
    }
    
    selectUDIMPatchalt;

     
  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16
    Heres a simple test scene I forgot to include. nothing fancy just 5 boxes with uvs laid out in udim format
Sign In or Register to comment.