02 May 2007

the inner geek.

i'm going to be a geek out there for anyone who is a geek, if you are not a computer 3D geek then you may move on , for this is jibberish ;)
I thought i'd share a script i wrote for changing mass attributes in Maya. This is a fairly simple task but saves so much time. What it does is take whatever objects are selected, shove them into an array, then do a for loop to apply whatever you want to each object in the array. This is nice for multiple uses, but i'll show a generic example.

string $obj[];
int $num;
int $i =0;

$obj = `ls -sl`;
$num = `size ($obj)`;

for ($i=0;$i < $num;$i++)
{ setAttr ($obj[$i]+".renderable") 0;
};
the setAttribute line is where you would add your own personal use, but here i've made this one to select all my cameras in a scene to set them to non-renderable. This is handy for when you are making lots of camera nulls to be exported to after effects. Here is a generic break down so you can understand if you dont know the basics:
string $obj[]; - this tells maya that $obj will be an array
int $num; - generic integer to work with
int $i =0; - generic integer, naming is irrelevant
$obj = `ls -sl`; - grabs all objects that are selected.
$num = `size ($obj)`; - sets size of the array to the number of objects
for ($i=0;$i < $num;$i++){ - for loop that runs until all of the objects have been addressed
setAttr ($obj[$i]+".wrapU") 0; - this is cool because it takes the objects name, and appends whatever detail you are changing to it. so instead of typing pshere1.rotateX - you are just telling it what to affect. neat to me... anyways hehe

anywhoo... thats a simple thing that saves me time from now and then, so perhaps it could save you time, like today ben had textured all of these planes but didnt set their wrap off, so i changed it so he could select all of the planes and run a script and viola! turned wrapping off. enjoy your evening, im back to working on a website.