Mailing List AE-List@media-motion.tv ? Message #48544
From: James Culbertson <albion@speakeasy.net>
Subject: Re: [AE] expressions: limiting decimals and adding 0 to single digit integers?
Date: Tue, 16 Apr 2013 23:31:15 -0700
To: After Effects Mail List <AE-List@media-motion.tv>
Almost there. The - sign inserts itself between the two integer numbers when the rotation is negative... 0-3.47 instead of 03.47.

Thanks much,

James


On Apr 16, 2013, at 11:12 PM, Zack Lovatt wrote:

From my understanding, this may be what you're looking for. Use this instead of your existing code. Doesn't deal with the negative sign, though; written hastily. In the morning I'll double check it and refine it to add the negative!

nums = thisComp.layer("shape").transform.rotation.value.toFixed(2) + "";

if ((nums < 10) && (nums > -10)) nums = "0" + nums;

nums;

I am linking one layers rotation to a text layers source text.

How do I modify the simple expression to limit the decimal to two places, and at the same time make all integers two digits so 0 - 9 are 00, 01, 02,...?

Something like this but that adds two decimal places to the number:

//--Expression begins
nums = thisComp.layer("shape").transform.rotation;
amtOfZeroes = 2;
//--Do not modify below this line
isNeg = false;
if(nums < 0)
{
nums = Math.abs( nums );
isNeg = true;
}
sVal = Math.round( nums ) + "";
while(sVal.length < amtOfZeroes)
{
sVal = "0" + sVal;
}
if(isNeg)
sVal = "-" + sVal;

sVal
//--Expression ends


Thanks, James


+---End of message---+
To unsubscribe send any message to <ae-list-off@media-motion.tv>

 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster