Copy link to clipboard
Copied
Hi Everyone, I bought a set of flipping text animations (kind of like an old Solari board) and it requires the letters to be placed manually. This is a nightmare for me since my intended project has quite a few of these lines we're animating. So, I am trying to write a script. I've been watching tutorials for the last few hours but I'm realy stuck on how to add a layer from a folder, scale, and position. Here's the crux of what I need to write:
First of all, inside the project (and in a folder on my disk) are the letters. There is a top folder called Type and then two subfolders, 0Letters and 1Numbers. Inside each folder is an individual composition containing a letter or a number.
Now the script:
1. Prompt the user for the letters or numbers needed
2. For each letter (loop)
2a. Place the corresponding letter on the timeframe at 0
2b. Scale the letter to 5%, 5%
2c. Place the first letter at 45, 53, for each additional letter, add 55 to the X, keep the Y same.
I know this is relatively simple but I just can't find the code samples to add a composition in a folder and then easily adjust the properties. I'm only 3 hours into this but I have Javascript experience, I'm just spinning my wheels and figured you guys could help faster than me reading more tutorials.
Thanks!
Nothing wrong with pulling the text from the layer, I just forgot to add 2 things. This is how you should pull the text from the layer
var text = myText("ADBE Text Properties")("ADBE Text Document").value.text.split("");
Copy link to clipboard
Copied
Here is a good start. If you know some javascript, you will be able to adjust it to your case particularities.
In order to get what text to write, create a text layer in your comp, select it and then run the script.
var mainComp = app.project.activeItem;
var myText = app.project.activeItem.selectedLayers[0];
var text = myText("ADBE Text Properties")("ADBE Text Document").value.text.split("");
xValue = 53;
for (var i = 0; i < text.length; i++) {
if (text[i] == " ") {
xValue += 53;
} else {
var crtComp = getCompByName(text[i]);//Here you may add some prefix/suffix to the comp name, based on how the creator named his compositions
if (crtComp != null) {
crtCompAsLayer = mainComp.layers.add(crtComp);
crtCompAsLayer("ADBE Transform Group")("ADBE Scale").setValue([5, 5]);
crtCompAsLayer("ADBE Transform Group")("ADBE Position").setValue([xValue, 53]);
xValue += 55;
}
}
}
function getCompByName(itemName) {
for (var i = 1; i <= app.project.numItems; i++) {
if (app.project.item(i).name == itemName && app.project.item(i) instanceof CompItem) return app.project.item(i);
}
return null;
}
Copy link to clipboard
Copied
Thanks for helping me get started! I created a text layer with the text TEST and then selected the layer and ran the script but got the error "Function myText()().split is undefined" Is there something wrong with pulling the text from the layer?
In the meantime, I populated text with this:
var text = prompt("Enter desired text","");
And that got me going.
Copy link to clipboard
Copied
Nothing wrong with pulling the text from the layer, I just forgot to add 2 things. This is how you should pull the text from the layer
var text = myText("ADBE Text Properties")("ADBE Text Document").value.text.split("");
Copy link to clipboard
Copied
Thanks! I extended the script a little to get the information from a prompt instead. I also turned your process into a function so it could be called and add some variables. The new function allows you to place the letters at a certain x and y value as well as at a certain time code. I used it in conjunction with this project to make placing letters much easier https://videohive.net/item/flipping-type-project/22484156
var mainComp = app.project.activeItem;
var text1 = prompt("Enter Line 1","");
var text2 = prompt("Enter Line 2","");
var text3 = prompt("Enter Line 3","");
var text4 = prompt("Enter Line 4","");
var text5 = prompt("Enter Line 5","");
var text6 = prompt("Enter Line 6","");
var text7 = prompt("Enter Line 7","");
var text8 = prompt("Enter Line 8","");
var text9 = prompt("Enter Line 9","");
var text10 = prompt("Enter Line 10","");
var text11 = prompt("Enter Line 11","");
place(45.4,53,text1,0);
place(45.4,149.8,text2,2.5);
place(45.4,246.7,text3,5);
place(45.4,343.5,text4,7.5);
place(45.4,440.6,text5,10);
place(45.4,537.6,text6,12.5);
place(45.4,634.8,text7,15);
place(45.4,731.9,text8,17.5);
place(45.4,829,text9,20);
place(45.4,926,text10,22.5);
place(45.4,1023.2,text11,25);
/*
place(45.4,53,text1,0);
place(45.4,149.8,text2,.1);
place(45.4,246.7,text3,.2);
place(45.4,343.5,text4,.3);
place(45.4,440.6,text5,.4);
place(45.4,537.6,text6,.5);
place(45.4,634.8,text7,.6);
place(45.4,731.9,text8,.7);
place(45.4,829,text9,.8);
place(45.4,926,text10,.9);
place(45.4,1023.2,text11,1);
*/
function place(xValue,yValue,text,time) {
for (var i = 0; i < text.length; i++) {
if (text[i] == " ") {
xValue += 65.2;
} else {
var crtComp = getCompByName(text[i]);//Here you may add some prefix/suffix to the comp name, based on how the creator named his compositions
if (crtComp != null) {
crtCompAsLayer = mainComp.layers.add(crtComp);
crtCompAsLayer.startTime = time;
crtCompAsLayer("ADBE Transform Group")("ADBE Scale").setValue([5, 5]);
crtCompAsLayer("ADBE Transform Group")("ADBE Position").setValue([xValue, yValue]);
xValue += 65.2;
}
}
}
}
function getCompByName(itemName) {
for (var i = 1; i <= app.project.numItems; i++) {
if (app.project.item(i).name == itemName && app.project.item(i) instanceof CompItem) return app.project.item(i);
}
return null;
}