Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Pulling multiple frames from a comp via expression

Tagged: 

  • Pulling multiple frames from a comp via expression

    Posted by Syed Iqbal on October 31, 2022 at 5:40 am

    Hi folks,

    Someone made a wonderful expression that I have tried to use after slight modifications (in setup and not in expression) and now I want to improve it further to match my requirements. My precomp “letters” has image layers for all 26 alphabets. In the main comp I have a text layer having different alphabets as source text property at different frames and below expression works fine as long as the sourceText property is based on a single letter. Is it possible to extend the functionality of this expression so that the expression could pull and form a complete word based on text layer’s source property. This would be handy in situations where you are using vector image-based fonts.

    txt = thisComp.layer(“text”).text.sourceText;

    comp = comp(“letters”);

    for(i=0; i<comp.numLayers;i++) {

    if(comp.layer(i+1).name.toLowerCase().match(txt)) {

    framesToTime(i); break;

    } else 100;

    }

    I know this seems almost impossible, but I still feel may be there could be a workaround. I could think of using a loop to read the char values of each letter stored in sourceText property of text layer (remember this text layer has sourceText keyframes at specific intervals) but the most challenging aspect to me is to show multiple frames from that image based “letters” precomp at once. Even if this could be achieved, positioning them with some “padding” would be another challenge. So in short very difficult for me but may be guys like Dan Ebberts could find a workaround.

    Your help would be much appreciated!

    Syed

    Syed Iqbal replied 3 years, 8 months ago 3 Members · 4 Replies
  • 4 Replies
  • Filip Vandueren

    October 31, 2022 at 7:30 am

    If you know how many characters there would be max, then the easiest way is to prepare enough layers, and have an expression hide the ones you don’t need. Each layer uses its index to look at a different character of the sourceText.

    If that is not an option: there is a hack using the echo effect: an expression gives different results at different times and echo combines those different results in time into the current frame, this way 1 layer can be at multiple places at once. Not easy to implement.

    The spacing / layout is indeed the biggest problem. The spacing should be based on the width of the characters in the precomp, not the spacing of the current text-layer?

    But kerning is an art: just using 1 fixed spacing parameters between letters usually doesn’t look very good, unless the font was designed to be used that way (like monotype or pixel-style fonts).

  • Syed Iqbal

    November 1, 2022 at 6:15 pm

    Hi, I really appreciate your comments, but I just want to reiterate that the “letters” precomp that has those 26 layers of images (alphabets) is the one that has my quoted expression on time remap keyframe. This precomp should ideally use text layer’s source text property (which it is capable of right now but only for a single character) to show multiple frames of this precomp at once in order to display a word which has more than one characters on the text layer. Your monospaced font rings the bell but first I want to be sure if it is really possible to display multiple frames of a precomp at once.

    Thanks again for showing your willingness to assist and by sharing your valuable advice.

  • Dan Ebberts

    November 1, 2022 at 8:59 pm

    To display multiple frames (letters) at once, you’d need multiple copies of the time remapped layer. You’d need time remapping and position expressions that would need to determine which character from the source text this layer would represent (probably based on layer index or layer name). Here’s a simple example that assumes your letter precomp layers are at the top of the layer stack in the timeline and that the letter precomp has been trimmed to be the same size as the letters. Your time remap expression for each letter precomp layer might look like this:

    txt = thisComp.layer("Text").text.sourceText.value.toUpperCase();
    myIdx = index - 1;
    myFrame = txt.charCodeAt(myIdx) - "A".charCodeAt(0);
    framesToTime(myFrame);

    and your position expression might look like this:

    myIdx = index - 1;
    value + [myIdx*width,0]

    Again, this is a simplified example and doesn’t do anything about kerning.

  • Syed Iqbal

    November 2, 2022 at 4:48 am

    Hi Dan, as always, your solution works like a charm. Thanks a lot.

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