Skip to content

Instantly share code, notes, and snippets.

@lg3bass
Created February 1, 2014 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lg3bass/8748060 to your computer and use it in GitHub Desktop.
Save lg3bass/8748060 to your computer and use it in GitHub Desktop.
MEL - Loft Curves and Rig
//2014-01-31
//SELECT 4 CURVES, LOFT, ADD TO RIG NODE.
//bob white [bobwhitemedia.com]
//create the loft
string $geo[];
string $selection[];
$selection = `ls -sl`;
$geo = `loft -ch 1 -u 1 -c 1 -ar 1 -d 1 -ss 2 -rn 1 -po 1 -rsn true $selection`;//loft it
polyCloseBorder -ch 1 $geo;//put on endcaps
select -r $geo;//re-select so that it smooths the right node.
polySmooth -mth 0 -dv 1 -bnr 1 -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -peh 0 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $geo;//smooth 1 degree
//find the sub-curves and animate
//create a rig node if none exists already
if( `objExists RIG` ) {
warning("A RIG node has already been created");
} else {
string $myRig[];
$myRig = `CreateEmptyGroup`;
rename $myRig "RIG";
//turn off all the keyable attributes
setAttr -keyable false -channelBox false "RIG.tx";
setAttr -keyable false -channelBox false "RIG.ty";
setAttr -keyable false -channelBox false "RIG.tz";
setAttr -keyable false -channelBox false "RIG.rx";
setAttr -keyable false -channelBox false "RIG.ry";
setAttr -keyable false -channelBox false "RIG.rz";
setAttr -keyable false -channelBox false "RIG.sx";
setAttr -keyable false -channelBox false "RIG.sy";
setAttr -keyable false -channelBox false "RIG.sz";
setAttr -keyable false -channelBox false "RIG.v";
}
//add the attribute
//string $ctrl;
string $c1;
$c1 = $geo[0]+"_start";
addAttr -ln $c1 -at double -min 0 -max 1 -dv 0 |RIG;
$t1 = "|RIG."+$c1;
setAttr -e-keyable true $t1;
string $c2;
$c2 = $geo[0]+"_end";
addAttr -ln $c2 -at double -min 0 -max 1 -dv 1 |RIG;
$t2 = "|RIG."+$c2;
setAttr -e-keyable true $t2;
//get the subcurves
string $crvObj[];
clear $crvObj;
//clear $allObjects;
select -r $geo;
string $allObjects[];
string $obj;
$allObjects = `listHistory -lv 1`;
for ( $obj in $allObjects ) {
if ( `nodeType $obj` == "subCurve" ) {
//print ($obj + "\n");
$crvObj[size($crvObj)] = $obj;
}
}
//set driven key
for($i=0; $i < size($crvObj); $i++ ){
string $subc;
//start
$subc = $crvObj[$i]+".minValue";
for($j=0; $j<2; $j++){
setAttr $t1 $j;
setAttr $subc $j;
setDrivenKeyframe -currentDriver $t1 $subc;
}
//start
$subc = $crvObj[$i]+".maxValue";
for($j2=1; $j2>-1; $j2--){
setAttr $t2 $j2;
setAttr $subc $j2;
setDrivenKeyframe -currentDriver $t2 $subc;
}
}
setAttr $t1 0;
setAttr $t2 1;
select -r RIG;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment