Wednesday, May 16, 2007

OK, my mel doodles !

i've been posting some mel stuff in one of the forums... but i thought i can have these MEL
doodles here too :)

{
// find and rename the end joints
// select any top DAG node under which you have a joint chain
// running this will rename the LAST joint in the hierarchy
string $s[]=`ls -sl`;$s=`listRelatives -ad -type "joint" $s[0]`;
for ($e in $s)
{
if (!size(`listRelatives -ad -type "joint" $e`)) {
rename $e `substitute "[0-9]+" $e "_end"`;
}
}
// now u can deselect your 'end' joints easily before binding any geometry
}

{
// at selectted UV on a polygon place a follicle
// tweaked from the example in documentation
string $selObj[]=`ls -sl`;
float $uvValss[]=`polyEditUV -query -v $selObj[0]`;
string $objname[];$tmp=`tokenize $selObj[0] "." $objname`;
// create a follicle nodestring $fol = `createNode follicle`;
// get the parent transforms of the follicle
string $folTform[] = `listTransforms $fol`;
// connect the sphere to the follicle
connectAttr ($objname[0] + ".outMesh") ($fol + ".inputMesh");
connectAttr ($objname[0] + ".worldMatrix[0]") ($fol + ".inputWorldMatrix");
// apply the follicle output positions to its own transform
connectAttr ($fol + ".outTranslate") ($folTform[0] + ".translate" );
connectAttr ($fol + ".outRotate") ($folTform[0] + ".rotate" );
setAttr ($fol + ".parameterV") $uvValss[1];setAttr ($fol + ".parameterU") $uvValss[0];
}

{
// Create a group for a controller, which is oriented to it
string $s[]=`ls -sl`;select -cl;
group -em -n ($s[0]+"GP");
delete `parentConstraint $s[0] ($s[0]+"GP")`;
parent $s[0] ($s[0]+"GP");
}

{
// to snap objB to objA
// select objA and then shift select objB and run :
delete `parentConstraint`;
// this will point n orient snap or
delete `pointConstraint`;
// this will just point snap
// this saves us the use of 'remove target' from the constraints menu !
}

-more coming soon, or keep checking the thread .. !

No comments: