Copy link to clipboard
Copied
If I have the number "5" as a text layer, how can I get another text layer to read that number, and then add another number to it?
This gives me "56". I want "11".
temp = thisComp.layer("5").text.sourceText.value;
(temp + 6)
This should work"
txt = thisComp.layer("5").text.sourceText;
numDigits = 3;
n = parseInt(txt)+6;
s = n.toString();
while (s.length < numDigits) s = "0" + s;
Dan
Copy link to clipboard
Copied
I think I got it! How's this?
temp = thisComp.layer("5").text.sourceText.value;
add(temp, 6)
Copy link to clipboard
Copied
I think I'd do it this way:
txt = thisComp.layer("5").text.sourceText;
parseInt(txt)+6
Dan
Copy link to clipboard
Copied
Okay, just to complicate things, how would I add leading zeros? So I'd get 005, 010…
Copy link to clipboard
Copied
This should work"
txt = thisComp.layer("5").text.sourceText;
numDigits = 3;
n = parseInt(txt)+6;
s = n.toString();
while (s.length < numDigits) s = "0" + s;
Dan
Copy link to clipboard
Copied
hey dan I combined both of your expression in to one: (worked better for me)
temp = thisComp.layer("5").text.sourceText;
numDigits = 3;
n=add(temp, 0.00003);
s = n.toString();
while (s.length < numDigits) s = "0" + s;
(my number is 1.11337 and I need to add 0.00003 to it...)
everything works beside the 0 digit thingy when it reaches 1.1140 for example.
tnxxx!
Copy link to clipboard
Copied
Thanks Dan, this worked perfectly for me.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more