Home Technical Talk

Maya_question - Selecting objects smaller than a size you specify...

VBV
VBV
polycounter lvl 2
Offline / Send Message
VBV polycounter lvl 2

Hi guys 

New user here. 

Here is my situation. I am working on a scene(MAYA) with thousands of objects, but I don't need the objects that are smaller than a certain size. Is there are a way(maybe a script) of selecting multiple objects in a scene that are smaller than a size you specify(xyz scale)? This will speed up my workflow tremendously. 

 

Thank you in advance!

VBV

Replies

  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    something like this works:

    <div>global proc GetSmallObjects(&nbsp; &nbsp; float $xLimit,&nbsp;
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float $yLimit,&nbsp;
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float $zLimit ){
    
    </div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; string $sceneObjs[] = ` ls -l `;
    <span style="background-color: transparent; color: inherit; font-size: inherit; font-family: "open sans", sans-serif;">        select -cl;</span>
    </div><div>
    </div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; for ($obj in $sceneObjs){
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; float $bbox[] = ` exactWorldBoundingBox $obj`;
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; float $xSize = $bbox[3] - $bbox[0];
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; float $ySize = $bbox[4] - $bbox[1];
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; float $zSize = $bbox[5] - $bbox[2];
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (( $xSize < $xLimit) && ( $zSize < $zLimit) && ( $zSize < $zLimit)){
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select -add $obj;
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; }
    
    </div><div>&nbsp; &nbsp;}
    
    </div><div>}</div>

    where you run it from the command line like this:

    GetSmallObjects( 1, 2, 3); 

    where the numbers are the x, y, z, sizes

  • VBV
    Options
    Offline / Send Message
    VBV polycounter lvl 2
    Wow. Thank you so much Daniel!!! I really appreciate this! The script works like a charm. This will save a lot of time. Thank you again!!!!
  • VBV
    Options
    Offline / Send Message
    VBV polycounter lvl 2
    BTW do you mind me posting your script to the Autodesk Maya forum, as I asked the same thing there?
    Thank you!
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    VBV said:
    BTW do you mind me posting your script to the Autodesk Maya forum, as I asked the same thing there?
    Thank you!
    I posted the script myself
Sign In or Register to comment.