View Single Post
# 5 26-01-2016 , 04:47 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
You don't even need an expression - using node connections would provide faster frame rates. The script below will connect scale X, Y and Z to the visibility attribute. Therefore when the object is visible the scale will be 1, and when it's invisible, it will be zero. The extra code simply removes static channels (for example if you're keying with "s" instead of "W"), and repeats the connections for every selected object.

Select all of your objects and run the following in the mel tab in the script editor:

Code:
string $sel[] = `ls -sl`;

for ($obj in $sel)
{
    delete -staticChannels -unitlessAnimationCurves false -hierarchy 0 -controlPoints 0 -shape 0 $obj;    // remove static channels
    connectAttr ($obj + ".visibility") ($obj + ".scaleX");
    connectAttr ($obj + ".visibility") ($obj + ".scaleY");
    connectAttr ($obj + ".visibility") ($obj + ".scaleZ");
}


Imagination is more important than knowledge.