Skip to content

Instantly share code, notes, and snippets.

@MarissaJ
Last active August 24, 2022 02:32
Show Gist options
  • Save MarissaJ/5d95fa08114c612de1064fe20841074f to your computer and use it in GitHub Desktop.
Save MarissaJ/5d95fa08114c612de1064fe20841074f to your computer and use it in GitHub Desktop.
After Effects Data Driven Expression- Line Break Control
row = parseInt(thisComp.layer("Data-Sample.csv")("Data")("Number of Rows")-1);
thisComp.layer("Data-Sample.csv")("Data")("Outline")("Long Text")("Long Text " + row)
txt = thisComp.layer("Data-Sample.csv")("Data")("Outline")("Long Text")("Long Text " + row);
n = effect("Line Break")("Slider");
outStr = "";
newLine = "";
splt = txt.split(" ");
for (i = 0; i < splt.length; i++){
if ((newLine + " " + splt[i]).length > n){
if (outStr != "") outStr += "\r";
outStr += newLine;
newLine = splt[i];
}else{
if (newLine != "") newLine += " ";
newLine += splt[i]; }
} if (newLine != ""){ if (outStr != "") outStr += "\r";
outStr += newLine; } outStr;
@MarissaJ
Copy link
Author

For more on how to use this expression and download a sample After Effects 2019 file here https://www.fluxvfx.com/data-driven-expressions-for-after-effects-2019/

@we9designer
Copy link

Hey buddy, where the file? ) can you provide it to me?

@volition74
Copy link

Line 2 is a duplicate and not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment