Copy link to clipboard
Copied
Hello,
I've been working on a script and have the following line of code, where I create and want to edit the font size of the just created text. However I can't seem to get it work. I can change some of the other text properties, which is why it is stumping me.
var finishText = thisComp.layers.addText(finishTime);
var textProp = finishText.property("Source Text");
var textDocument = textProp.value;
textDocument.resetCharStyle();
textDocument.fontSize = 36;
textProp.setValue(textDocument);
Help appreciated! Thanks!
Sup Nathan,
I`ve tried the following code and it seems like everything work properly.
var thisComp = app.project.activeItem;
var finishText = thisComp.layers.addText("finishTime");
var textProp = finishText.property("Source Text");
var textDocument = textProp.value;
textDocument.resetCharStyle();
textDocument.fontSize = 50;
textProp.setValue(textDocument);
Can you tell us your AE version?
Copy link to clipboard
Copied
Sup Nathan,
I`ve tried the following code and it seems like everything work properly.
var thisComp = app.project.activeItem;
var finishText = thisComp.layers.addText("finishTime");
var textProp = finishText.property("Source Text");
var textDocument = textProp.value;
textDocument.resetCharStyle();
textDocument.fontSize = 50;
textProp.setValue(textDocument);
Can you tell us your AE version?
Copy link to clipboard
Copied
I'm using CC 2014.
I would like to point out that finishTime is a variable established earlier in my code that basically puts a stopwatch looking timer into the text layer. Any ideas as to what it might be? It still isn't working for me
Copy link to clipboard
Copied
I guess the problem is under finishTime variable. Can`t tell you exactly without code example, but you can try adding .toString to this one:
var finishText = thisComp.layers.addText(finishTime.toString);
Copy link to clipboard
Copied
if(minutes == 0 && seconds == 0 && milliseconds == 0){
var finishTime = "00:00.00";
}
if(minutes == 0 && seconds == 0){
var finishTime = "." + milliseconds;
}
if(minutes == 0 && milliseconds == 0){
var finishTime = seconds + ".00";
}
if(seconds == 0 && milliseconds == 0){
var finishTime = minutes + ":00.00";
}
if(minutes == 0){
var finishTime = seconds + "." + milliseconds;
}
if(milliseconds == 0){
var finishTime = minutes + ":" + seconds + ".00";
}
alert(finishTime);
thisComp.openInViewer();
var finishText = thisComp.layers.addText(finishTime);
var textProp = finishText.property("Source Text");
var textDocument = textProp.value;
textDocument.resetCharStyle();
textDocument.fontSize = 36;
textProp.setValue(textDocument);
toString appears not to work. It's a bit messy, but this is kind of how I get the var finishTime. i confirmed with an alert that it is indeed working properly. With the code how it is, everything but the font size change works.
Copy link to clipboard
Copied
Well, that`s weird...
I`ve tried this code with deffirent condition on several AE versions including 13.2 and it works fine.
Tried to reboot/restart AE/clear cache? Also are you on Mac?
Copy link to clipboard
Copied
I'm running Windows 7. I rebooted my computer, cleared the caches, and it still doesnt work.... hmmmm
Update: I added .value to the end of the var textProp line. It seems to change the font size, but cause problems in other places.
Another Update: I had a dumb moment and forgot there was a function after this that changes the font size... Thanks for your help Alex!
Copy link to clipboard
Copied
I`m glad that you solved it.
Copy link to clipboard
Copied
setValue twice can avoid this problem when you create the text layer without text string.Another method is to create the text layer with text string.I posted a thread a few days ago in this forum,so you can check for it.
Copy link to clipboard
Copied
как
I posted a thread a few days ago in this forum,so you can check for it.
By @Deleted User
Where is this topic? Give me a link please?