Thursday, 15 March 2012

Mel: Invert Selection from a render layer

Thought I might post up this useful code someone asked for...

//  ld_invertSel_rlyr.mel  0.2
// 
//  Authors:     Lee Dunham
//  Licence:     Creative Commons, Attribution, Share Alike
//  About:       Inverts selection for visible objects in current render layer.
//  Usage:
//      ld_invertSel_rlyr ;
global proc ld_invertSel_rlyr(){
string $currentRenderLayer=`editRenderLayerGlobals -q -currentRenderLayer` ;
string $objsRenLayer[]=stringArrayRemoveDuplicates(`editRenderLayerMembers -q $currentRenderLayer`) ;
for($obj in $objsRenLayer)
    if(`getAttr ($obj+".v")`==1 && `objectType -isType "transform" $obj`)
        select -tgl $obj ;
    else
        select -d $obj ;
}

It'll invert the selection for whatever visible transform objects are in the current render layer. Its not fantastic but it was a 5-minute job.

No comments:

Post a Comment