Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Applying an effect to a layer through a script

  • Applying an effect to a layer through a script

    Posted by Corey Drake on September 22, 2011 at 2:15 am

    I’ve been dipping my feet into extendscript a bit and I was wondering how I would go about doing this:

    User selects two nulls with animated position
    User selects footage layer
    Script applies effect, say, a ramp to footage
    Script copies keyframes from 1st null to start of ramp
    Script copies keyframes from 2nd null to end of ramp

    Any help would be really appreciated.

    Corey Drake replied 14 years, 10 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    September 22, 2011 at 3:08 pm

    Applying an effect to a layer is easy:

    myLayer.property(“Effects”).addProperty(“Ramp”);

    Copying keyframes can be complicated, depending on the nature of the keyfames, especially if there is easing to consider. Actually, you can’t just copy them from one property to another, you have to re-create them. As an alternative, you might consider just having the script apply expressions linking the Start of Ramp and End of Ramp properties to the position of the nulls.

    Dan

  • Corey Drake

    September 22, 2011 at 3:24 pm

    Great! Thanks. You mention applying an expression through a script. I didn’t know that could be done. In fact, that would actually help me skip a whole process and make things way easier for me. Could you give an example of how to do that or point me in a direction where I can learn that?

  • Dan Ebberts

    September 22, 2011 at 3:51 pm

    It’s pretty straight forward. I haven’t tested this code, but it would look something like this:

    var myEffect = myLayer.property(“Effects”).addProperty(“Ramp”);
    var myProperty = myEffect.property(“Start of Ramp”);
    myProperty.expression = ‘thisComp.layer(“Null 1”).transform.position’;

    You might have to construct the expression on the fly if you don’t know the name of the target layer (Null 1 in this case) at the time you write the script.

    Dan

  • Corey Drake

    September 22, 2011 at 3:56 pm

    Thank you very much. This is going to help so much.

  • Corey Drake

    September 22, 2011 at 8:40 pm

    Thank you very much. This is going to help so much

    [Edit] Also, I was wondering how to get a list of selected items within the comp. I’ve found the items and selection attributes, but they seem to work for the project panel. Do I have to do something with activeItem first?

  • Corey Drake

    September 22, 2011 at 8:55 pm

    [edit2] I have found the compItem attributes, so I am good to go. No I wonder, how can I check if a selected layer is a null or a solid?

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