Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Script for Standard Pose

  • Script for Standard Pose

    Posted by Michael Helmrich on February 19, 2014 at 12:58 pm

    Hello Cows,

    I am about to animate short scenes with an IK-character in After Effects. All scenes begin and end in the same standard pose.
    I would like to create a script that basically resets my character-rig back to the standard pose, so I can easily blend from one clip to another.

    So far I have a script which reads the value from frame 0 and creates a key at the current time with this value, essentially resetting to the standard value. But it only works for the transform parameters position, rotation and scale.

    Some of the layers, like the mouth layer, are animated over a slider control. But not all the layers have 1 or 2 effects on them.

    Is it possible to access the effects similarly to the way one accesses the transform options? Is there something similar to “numKeys” like “numEffects”?

    Below is what I have so far. Thanks for your help!

    {
    var myProj = app.project;
    var myComp = myProj.activeItem;
    var mySelectedLayers = myComp.selectedLayers;

    app.beginUndoGroup("Standard Pose Keys");

    for (var i = 0; i < mySelectedLayers.length; i++) {
    var curLayer = mySelectedLayers[i];
    var curTime = app.project.activeItem.time;
    var oldPosValue = curLayer.property("Position").valueAtTime(0, false);
    var oldScaValue = curLayer.property("Scale").valueAtTime(0, false);
    var oldRotValue = curLayer.property("Rotation").valueAtTime(0, false);

    if (curLayer.position.numKeys > 0){
    curLayer.position.setValueAtTime(curTime,oldPosValue);
    }
    if (curLayer.scale.numKeys > 0){
    curLayer.scale.setValueAtTime(curTime,oldScaValue);
    }
    if (curLayer.rotation.numKeys > 0){
    curLayer.rotation.setValueAtTime(curTime,oldRotValue);
    }

    }

    app.endUndoGroup();
    }

    Michael Helmrich replied 12 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    February 19, 2014 at 4:11 pm

    This should give you the number of effects:

    curLayer.property(“Effects”).numProperties

    Dan

  • Michael Helmrich

    February 20, 2014 at 8:28 am

    Wow, thank you Dan! It works wonderfully.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy