Forum Replies Created

  • René Pedersen

    December 14, 2022 at 10:25 am in reply to: SOURCERECTATTIME FOR STRING

    Amazing preset. I was told again and again it was impossible to get the size of individual lines in a text box since sourceRectAtTime uses the boundary of the entire text box.

    I am having problems utilizing the full potential though since I cant figure out what the Left – Top value is relative to.

    I am trying to create a coloured box for just one of the lines in a text box that automatically resizes when I change the text. Therefore I changed the sourceSubRect Helper to be based on Lines instead of characters.

    And I have added a shape layer with a path (and a fill) and added this code from the mask path that the preset generates to the path.

    pos=thisComp.layer("Text").effect("Left - Top")("Point"); //I have pickwhipped the effect to the text-layer.

    dim=thisComp.layer("Text").effect("Width - Height")("Point");

    pts=[

    pos,

    pos+[dim[0],0],

    pos+dim,

    pos+[0,dim[1]]

    ];

    createPath(pts,[],[],true);

    It creates a perfect sized box for my line, but I cant really figure out how to position it.

    When I have marked the Text layer I can see that the mask created is positioned correct, but if I try to use the points from “Left – Top” in the position of the TextBox/Shape Layer it is placed outside of the comps boundaries.

    My text layer is positioned at x = 0 and y = 0 and the anchor point on both my Text layer and Shape layer is placed top left with this expression

    sourceSize = thisLayer.sourceRectAtTime(time, false);

    T = sourceSize.top;

    L = sourceSize.left;

    [L , T]

    The left value always ends up around -515 and -519 (depending on the text) but I have no idea how to use these values.

  • René Pedersen

    December 7, 2022 at 2:22 pm in reply to: Getting active layer count at current time

    Hi

    The last couple of days I have been – unsuccessfully – trying to expand this old expression.

    The thing is that I don’t want to count active layers, but count all layers that has the term BlueBox in its name.

    I remembered an expression I had used before from that uses a keyword (not to get a number, but to set a width) https://ukramedia.com/how-to-automatically-get-the-size-of-many-layers/

    keyword = “ukramedia”;

    widthList = [];

    for(i = 1; i <= thisComp.numLayers; i++) {

    layerPath = thisComp.layer(i);

    layerWidth = layerPath.sourceRectAtTime().width;

    if(layerPath.name.match(keyword)) {widthList.push(layerWidth)} else {};

    }

    Math.max(…widthList) + 100

    
    

    But when I try to merge the expressions it doesn’t work. This is what I tried – any idea what am I doing wrong?

    n = 0;

    keyword = “BlueBox”

    for (i = 1; i < index; i++)

    layerPath = thisComp.layer(i)

    if (layerPath.name.match(keyword))

    n++;

    
    
    		
        

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