sabato 23 gennaio 2016

MEL multiParent

A small and simple timesaver for MEL to parent constrain one or more objects to a same object. For example to parent constrain 5 characters to a vehicle with just one click.
//select first your driver, then all your driven objects. run the script, smile
proc MtMultiParent(){
    string $myObjects[] = `ls -sl`;
    string $myDriver = $myObjects[0];
    int $i = 0;
    select -cl;
    select -r $myDriver;
    for( $each in $myObjects ){
        if ($myDriver != $each){
            select -add $myObjects[$i];
            parentConstraint -mo -weight 1;
            print ("\n"+($myDriver) + "+" + ($myObjects[$i]) + " constrainCreated" + "\n" );
            select -d $myObjects[$i];
            $i++;
        } else $i++;
    }
    select -r $myObjects;
}

Save the script in your Maya script folder, then call the MEL procedure "MtMultiParent();" how you prefer: shelf button, hotkey or typing code. Then smile!
happy animating!

sabato 3 ottobre 2015