Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression On Comp Duration

  • Expression On Comp Duration

    Posted by Jeff Horowitz on December 29, 2014 at 5:29 pm

    Here’s what I’m trying to do in AE:

    EX) Lets say I have a precomp that is 2 seconds long, and inside of it, is just a photo.

    Scenario 1) Here’s what Im looking to do: For every 3 words of text that I add to this precomp I want the precomp to add 1 second more to its duration.

    For example: If my precomp has just a picture in it…then keep the duration at 2 sec long. If my precomp has a picture in it as well as words…count the number of words, and for every 3, add 1 second.

    So, picture (2sec) + 9 words (3sec) = 5sec long precomp. I’m trying to make the duration of the comp responsive to the amount of text that’s added to it. The more text you add, the longer the comp gets, and the less text you add, the shorter the comp gets.

    Let me know if this is possible?

    JAH

    Jeff Horowitz replied 11 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    December 29, 2014 at 6:44 pm

    There’s no way to do that with an expression. You could do it with a script though.

    Dan

  • Jeff Horowitz

    December 29, 2014 at 6:55 pm

    How would I do this with a script?

    JAH

  • Dan Ebberts

    December 29, 2014 at 7:18 pm

    I guess the basic outline would look like this:


    var myComp = app.project.activeItem;
    var myLayer;
    var numWords = 0;

    for (var i = 1; i <= myComp.numLayers; i++){
    myLayer = myComp.layer(i);
    if (myLayer instanceof TextLayer){
    numWords += myLayer.property("Text").property("Source Text").value.toString().split(" ").length;
    }
    }
    myComp.duration = 2 + Math.floor(numWords/3);

    You’d probably want to add some code to make sure you actually have a comp selected and maybe some to extend the outpoints of your layers.

    Dan

    Dan

  • Jeff Horowitz

    January 2, 2015 at 2:30 pm

    wow thanks that worked

    JAH

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