Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Script to set a Keyframe at current time

  • Script to set a Keyframe at current time

    Posted by Oscar Gomez on November 1, 2017 at 11:51 pm

    Hi all! I need some help creating a script to add a keyframe on a selected layer.

    I already have one that works but this only works for position, rotation, scale or opacity. I need this script to add the keyframe on a slider control in the selected layer called HandShape.

    Here’s the script I got:

    var MyComp = app.project.activeItem;
    if(MyComp && MyComp.selectedLayers.length > 0){
    for(var i = 0 ; i < MyComp.selectedLayers.length; i++){
    var currentLayer = MyComp.selectedLayers[i];
    currentLayer.property(myProperty = “rotation”).setValueAtTime(MyComp.time,myValue = 5);
    };
    }else{
    alert(“At least one layer must be selected”);
    };

    Thanks for taking the time to read this, hopefully someone out there can solve it!

    Oscar Gomez replied 8 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Walter Soyka

    November 2, 2017 at 4:54 pm

    Try this:

    var MyComp = app.project.activeItem;
    if(MyComp && MyComp.selectedLayers.length > 0){
    for(var i = 0 ; i < MyComp.selectedLayers.length; i++){
    var currentLayer = MyComp.selectedLayers[i];
    currentLayer.effect("HandShape")("Slider").setValueAtTime(MyComp.time,myValue = 5);
    };
    }else{
    alert("At least one layer must be selected");
    };

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Oscar Gomez

    November 2, 2017 at 10:56 pm

    Walter Soyka, you are amazing!

    Thank you so much for taking the time to solve this. This is going to be a HUGE time saver on the project I’m working on!

    Cheers,
    Oscar

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