Saturday, January 8, 2011

Template and Untemplate MEL Scipt


Here is a little MEL Script I wrote over the holidays. Save it as a Shelf Button. When you click it, it will template anything you have selected or untemplate anything that has already been templated. I find it handy when working on a scene that has lots of objects close together.

I hope it is useful. 




// Version 6 Template Untemplate Script //
//Creates a list of all selected objects//
string $list1[];
$list1 = eval("ls -sl");

//Creates a list of all templated objects//

string $list2[];
$list2 = eval("ls -tm");

//Goes through the list of templated objects and untemplates them//

for ($object2 in $list2)
{
select -r $object2;
toggle -state off -template;
select -cl;
}

//Goes through the list of selected objects and temmplates them//

for ($object1 in $list1)
select -r $object1;
int $template = eval ("toggle -q -template");
if ( $template == off )
{
toggle -state on -template;
}
else
{
toggle -state off -template;
}
select -cl;
}

3 comments: