Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scripting: how to access all the keyframes of a given property?

  • Scripting: how to access all the keyframes of a given property?

    Posted by Paulo Jan on November 9, 2014 at 12:03 am

    Hi all:

    I can check whether a given property is keyframed or not using the numKeys attribute, but is there a way to get a list of all the keyframes in that property?

    Thanks in advance.

    Dan Ebberts
    replied 10 years, 2 months ago
    2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    November 9, 2014 at 12:23 am

    What needs to be in the list?

    Dan

  • Paulo Jan

    November 9, 2014 at 2:15 pm

    The basics, time and value. (I realize now that this is a more complicated issue than I had first thought, since a keyframe can also have a lot of other attributes: hold or not, interpolation… but the ones I need in my case are just those).

  • Dan Ebberts

    November 9, 2014 at 3:54 pm

    I suspect what you want may be more complicated than this (file I/O maybe?) but something like this example would construct a string containing a list of key times and values:


    var myProp = app.project.activeItem.layer(1).property("Position");
    var str = "";
    for (var i = 1; i <= myProp.numKeys; i++){
    str += (i == 1 ? "" : "\r") + myProp.keyTime(i) + " " + myProp.keyValue(i).toString();
    }
    alert(str);

    Dan

  • Paulo Jan

    November 9, 2014 at 7:49 pm

    Wow, thanks. Actually, I was just wondering how to access the keyframes at all; I didn’t realize that you could do that just by its index. Just a question: why do you start the for loop with 1 instead of 0? I’ve just had a quick glance at Adobe’s scripting guide and didn’t find any reference to that.

  • Dan Ebberts

    November 9, 2014 at 9:15 pm

    When using the property key methods, the key index numbers run from 1 through numKeys. You may be thinking of array indexing.

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