Forum Replies Created
-
Trent Armstrong
May 21, 2021 at 2:11 pm in reply to: Number of characters on each line in a paragraph layerAndrei,
Maybe this will get you started. I copied/pasted your text and actually inserted carriage returns at the end of each line. The carriage return—or “\r”—is important to how this expression works. (Maybe someone else knows if AE can read automatic line breaks, but I don’t think it does.) This expression just returns the number of characters per line on the respective line.
I’m not exactly sure what you’re going for, but this might get you headed in the right direction.
var txt = text.sourceText.split(“\r”);
n = txt.length;
list = [];
var t = “”;
for (i=0; i<n; i++) {
t = txt[i];
t = t.length;
list.push(t + “\r”);
}
list
Trent
-
Hi!
I’m not sure I understand “fully” what you’re trying to get, but I remember seeing somewhere a solution for rounded corners where circles were used on each of the corners for the rounding instead of the Corner Roundness. I think they were attached to the corners with Nulls, but maybe you could do the same thing with sourceRectAtTime().
-
Trent Armstrong
May 6, 2021 at 3:41 pm in reply to: getstyleat() & setText() returns [object Object]Philip,
This is another common concern. Sadly, at the present time, it’s not possible to mix text styles through the “style” expression. The best thing to do is have two separate text layers with two different styles you then place using expressions. There should be another thread here for causing two text layers to be placed in relationship to each other.
Trent
-
Trent Armstrong
May 6, 2021 at 1:17 pm in reply to: getstyleat() & setText() returns [object Object]Philip!
You are not alone in thinking this is a tricky one. I still have to scour the docs to make sure I’m getting the order and formulae right just about every time I use these new text style expressions.
I think I’ve got something here that will work for you (please let me know if it needs to be different).
TXT1 = comp("TXT1").layer("TXT1").text.sourceText;
TXT2 = comp("TXT2").layer("TXT2").text.sourceText;
txt = TXT2 + ' ' + TXT1;
const style = TXT2.getStyleAt(0,0);
style.setText(txt)I’m going to explain what’s happening in each spot. You may already understand some of this, so bear with me.
• The two variables TXT1 and TXT2 are pulling the text.sourceText value from the TXT1 and TXT2 text layers in their respective comps.
• “txt = TXT2 + ‘ ‘ + TXT1 ” is building a new variable out of the two previously defined variables as a string of text—with a space in between the two pieces of text.
• “const style = TXT2.getStyleAt(0,0)” tells this particular text layer to store the style of the text from the layer “TXT2” of the comp “TXT2”.
• “style.setText(txt)” <— This was the tricky one for me. It sets the style for this text layer with the “style” command and then sets the actual text string of the layer to the value of “txt”. So the order is Get a style/Create a Style and then apply that Style to what you set as the text of the layer.
\/ The area below is me trying and failing at formatting code \/ 😉
-
Trent Armstrong
April 29, 2021 at 1:17 pm in reply to: Text layers to maintain distance from each otherI stand fully by the solution Filip has provided, and I will offer a secondary solution. This project has each layer referencing the position and size of the previous layer through expressions. I don’t consider it better or worse. It is just another way of accomplishing your goal. That’s what I enjoy so much about After Effects! There are—many times—multiple ways to achieve a result.
-
Trent Armstrong
April 6, 2021 at 1:52 pm in reply to: Expression to centralize two text layers to comp heightIf these are all set up as precomps or all the text in one layer, this solution will work.
POSITION EXPRESSION
L = thisComp;
x = L.width * .5;
y = L.height * .5;
[x, y]
ANCHOR POINT EXPRESSION
L = thisLayer.sourceRectAtTime(time);
a = L.left;
b = L.top;
x = L.width * .5;
y = L.height * .5;
[a + x, b + y]
If you are using multiple layers to stack the lines and text together, you’ll need to do some parenting to a Null or something like that, add all the sourceRectAtTime() heights and widths together, and then do the * .5 part of the expression.
The reason I multiply times .5 instead of dividing by 2 is just habit. When dividing by the number returned from a slider or time or size etc. it’s possible to divide by zero and that breaks an expression. So, using that for width and height makes sense to me in this situation.
-
I am on board with Aris here, Dan. This would be great for one of your motionscript.com explanations with notes on the expression!
Such a simple and elegant solution!!!
-
For Shape Layers and Text, the effects are applied based on 100% of the width and the height of the comp. So anything you try to do will have to be based on that. The big problem with trying to use a Linear Wipe isn’t the percent of the wipe, it’s the angle because it always defaults to rotating around the “center” of the layer. With the effects used on Shape Layer always fitting themselves to the full width and height of the comp, the center for Linear wipe is always at the center of the comp.
If you need a single layer for this, take what I built there and move the Rectangle 2 from the MATTE down into the Content of the original shape. At that point you can use Merge Paths to get the reveal you’re looking for.
-
Here is a bit of a hack for you!
-
Trent Armstrong
March 10, 2021 at 1:41 pm in reply to: Right to left, top to bottom opacity animatorAndrei,
Sorry I couldn’t help. I hope you get it figured out!
Trent