Activity › Forums › Adobe After Effects Expressions › attaching an object to an updatable string of text
-
attaching an object to an updatable string of text
Cameron Pinegar replied 8 years, 9 months ago 7 Members · 38 Replies
-
Dan Ebberts
February 23, 2012 at 11:56 pmYour code got mangled somewhere along the line. Try this:
L = thisComp.layer("TEST");
for (i = 0; i <= L.width; i++){
temp = L.sampleImage([i,thisComp.height/2],[0.5,thisComp.height/2],true,time);
if (temp[3] > 0) break;
}[i,value[1]]
Dan
-
Mike Headley
February 24, 2012 at 12:22 amDan,
That did the trick! Thank you so much for the support. I do have a followup question, though. While the expression seems to be working, the solid layer is now overlapping the text layer even as I add or remove text. It actually seems that the left edge of the solid is aligned to the left edge of the textbox. I also can’t move the solid with the selection tool once the expression is activated. Is there a way for me to manually adjust the position of the solid within the expression? I was able to find a workaround by applying the expression to a null object, then parenting my solid to the null.
Thanks again,
-Mike H. -
Dan Ebberts
February 24, 2012 at 12:35 amI would just move the anchor point to adjust the x, adjust the y by dragging the layer.
Dan
-
Mike Headley
February 24, 2012 at 12:45 amEureka, that works! Thanks again for the help. This expression is really going to save me a lot of time.
Cheers,
-Mike H. -
Vojtěch Palme
December 14, 2012 at 5:50 pmDan. You’ve been tremendous help. I used the script for left adjusted text
L = thisComp.layer("TITLE");
for (i = thisComp.width; i >= 0; i--){
temp = L.sampleImage([i,thisComp.height/2],[0.5,thisComp.height/2],true,time);
if (temp[3] > 0) break;
}
[i,value[1]]and aplyed it to scale of layer on background of that text. It works. But when I load the “TITLE” content from external .txt
$.evalFile("C:/.../TITLE.txt");
try {
eval(title1)[0]
} catch (err) {
"not found"
}and change the text within, I get this error
After Effects warning: Timeout while waiting for the engine
Expression disabled.
Error occurred at line 4.
Comp: ‘TABULKA1’
Layer: 16 (‘Title bg’)
Property: ‘Scale’is there some way to maybe let the scale expression wait until the text is loaded? Seems to me that is looping it self or something..
And one more question, Is there a way to get number of lines of text? Or at least heigh of the text field? So when I paste text into some layer, the animator would readjust itself acordingly to display one row per second.
Thank you -
Cameron Pinegar
August 9, 2017 at 8:22 pmHi Dan,
I’m amazed by this script, I’ve been looking for something like this for a long time. I’m using the code to create dynamic underlines that change automatically with the width of the text. I’m parenting one null object to the position of the left aligned text and using your code to parent another null object to the ragged right side of the text. I’m then using the connect layers plugin to create a stroke that connects the two null objects (thus creating the underline). It seems to be the perfect way to solve my need for dynamic underlines, but the one issue I’m having is once I’ve pasted your script it becomes very taxing on my CPU and doesn’t end up helping me save the time I was hoping to save. My laptop is not very beefy, but I’m baffled because the script seems pretty simple and I feel like I’ve used much more complicated scripts without this kind of lag. Any suggestions?
MacBook Pro (Retina, 15-inch, Late 2013)
2.3 GHz Intel Core i7
16 GB 1600 MHz DDR3
NVIDIA GeForce GT 750M 2048 MB
Intel Iris Pro 1536 MBL = thisComp.layer("My name is Jonas.");
for (i = thisComp.width; i >= 0; i--){
temp = L.sampleImage([i,thisComp.height/2],[0.5,thisComp.height/2],true,time);
if (temp[3] > 0) break;
}
[i,value[1]] -
Dan Ebberts
August 9, 2017 at 9:31 pmAnything that has sampleImage() in a loop is going to be slow. If you have a recent version of AE, you should switch to a solution that uses sourceRectAtTime() to find the edges of the text.
Dan
Reply to this Discussion! Login or Sign Up