Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Bulk convert expressions into keyframes

  • Bulk convert expressions into keyframes

    Posted by Satya Meka on May 25, 2009 at 9:22 pm

    Hello,

    I have a project with more than 200 layers with a lot of expressions for various transform properties. Is there a way I could convert all the expressions to keyframes at once? (atleast with a script/select all animated properties at a time)

    Thank you

    regards,
    Satya Meka.

    Satya Meka,
    https://www.gutsblow.com

    Ben Forder replied 15 years ago 5 Members · 12 Replies
  • 12 Replies
  • Dan Ebberts

    May 26, 2009 at 12:11 am

    This should get you started. It will convert position, anchorPoint, roation, scale, and opacity expressions to keyframes for each layer in the active comp (if the layer has those properties):

    {

    function convertToKeyframes(theProperty){
    if (theProperty.canSetExpression && theProperty.expressionEnabled){
    theProperty.selected = true;
    app.executeCommand(app.findMenuCommandId(“Convert Expression to Keyframes”));
    theProperty.selected = false;
    }
    }

    var myComp = app.project.activeItem;
    if (myComp && myComp instanceof CompItem){
    var myLayer;
    var myProperty;
    app.beginUndoGroup(“convert expressions”);
    for (var i = 1; i <= myComp.numLayers; i++){ myLayer = myComp.layer(i); try{ myProperty = myLayer.property("position"); convertToKeyframes(myProperty); }catch(err){ } try{ myProperty = myLayer.property("anchorPoint"); convertToKeyframes(myProperty); }catch(err){ } try{ myProperty = myLayer.property("rotation"); convertToKeyframes(myProperty); }catch(err){ } try{ myProperty = myLayer.property("scale"); convertToKeyframes(myProperty); }catch(err){ } try{ myProperty = myLayer.property("opacity"); convertToKeyframes(myProperty); }catch(err){ } } app.endUndoGroup(); } } Dan

  • Satya Meka

    May 26, 2009 at 12:24 am

    Awesome Dan! You just made my day!

    Satya Meka,
    https://www.gutsblow.com

  • Michael Skoz

    September 30, 2010 at 12:49 pm

    i’m using cs5…ae announced an error on line 18…expect “;”
    Any suggestion?

  • Dan Ebberts

    September 30, 2010 at 11:38 pm

    I just copied it from my post, pasted it into a text document and ran it, and it works fine for me. I’m not sure why it doesn’t work for you.

    Dan

  • Jake Nelson-dooley

    November 8, 2010 at 5:45 pm

    Hi Dan,
    I’m also getting the same error in CS5 on line 18:

    Expected ;

  • Dan Ebberts

    November 8, 2010 at 6:42 pm

    More info about the conditions generating this error would be helpful. What was your setup? What was the script doing when it died? How far did it get? Also, please paste the code you used into this forum.

    Dan

  • Ben Forder

    May 12, 2011 at 4:43 pm

    Hi,
    That’s really useful, thanks for posting that. I’m having a problem though – I need to convert expressions to keyframes from more than one comp, all in the same script which is running completely automated inside a programme that opens and shuts after effects automatically with no person there to select a comp for it to work on…

    Do you know of any way to get a script to select a certain comp as the active comp so that the “convert expression to keyframes” command will work? It only seems to do it if the property or layer to be converted is selected with the mouse first.

    Or, if that’s not possible, is there any way a script can look at the output of an expression and use that data to do other things?

    Thanks for your time!

  • Dan Ebberts

    May 12, 2011 at 5:01 pm

    There is a hack using the undocumented ramPreviewTest() method. Basically you save the comp’s work area duration, change it to something short (two frames seems to work), issue the command like this:

    myComp.ramPreviewTest(“”,1.0,””); // the middle parameter is the magnification–use 0.25 for 25%, etc.

    That should make the comp active. Don’t forget to restore the original work area duration.

    Dan

  • Dan Ebberts

    May 12, 2011 at 5:05 pm

    Actually, that’s probably not going to help because the property needs to be selected.

    Dan

  • Ben Forder

    May 12, 2011 at 5:16 pm

    Thanks! I’ll give it a try, even if it doesn’t work, a secret hack is kind of exciting anyway (in a very nerdy way) 😀

Page 1 of 2

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