Return-Path: Received: from oproxy6-pub.bluehost.com ([67.222.54.6] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with SMTP id 5041118 for AE-List@media-motion.tv; Wed, 17 Apr 2013 08:04:46 +0200 Received: (qmail 17893 invoked by uid 0); 17 Apr 2013 06:12:52 -0000 Received: from unknown (HELO host245.hostmonster.com) (74.220.215.245) by cpoproxy3.bluehost.com with SMTP; 17 Apr 2013 06:12:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zacklovatt.com; s=default; h=Content-Type:To:From:Subject:Message-ID:Date:References:In-Reply-To:MIME-Version; bh=E2O1jXsvfX6Am2WUcp0k3L4E5jFqVssZfc7s8apJkn0=; b=miO0TGn408gqEhHthxytsiaUdcxbY+TtjV4Q3I4h1wyjx+Wvb6gi0EJlTYCPUZr7WDyzrYwetg4cciXB2RkJQ8ge6dSc4H3DO/kluwBIqr61is9REzUgrz6b8Jrghi+f; Received: from [74.125.82.46] (port=54647 helo=mail-wg0-f46.google.com) by host245.hostmonster.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.80) (envelope-from ) id 1USLbw-0006Ne-7H for AE-List@media-motion.tv; Wed, 17 Apr 2013 00:12:52 -0600 Received: by mail-wg0-f46.google.com with SMTP id e11so1199216wgh.1 for ; Tue, 16 Apr 2013 23:12:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=E2O1jXsvfX6Am2WUcp0k3L4E5jFqVssZfc7s8apJkn0=; b=fArzstWgEwyGQ90SOAUu2sX5sk/np6sv990AJfNFKadvU+wyoU2ko0p2YO6dVCaBPb Ye/gQ9OSXbpkNe0iRK/aXQwfPFT5ix6m4wh2C9VuLdmu3YfSAZ0W8Kif92LTbw+oEExH EE6RpukAsvRBXan6ensJBn/414dY8fJ4jmkvCUh7d8bF11Jr25qT2r0Rv1VTW4G2LOHy o4lOqqmwETTL7cFRlZLxznEzHrRdhbrOEmwMs+BLsMGwiuVm2k4sv88NBwyIqzevRcNR rPzpNRaRypF0Z2MS9wRJCpt1Nd6JvXmVBne5MvL8iCBCUBizrPBLKEA7bjcixVQea09B R+BQ== MIME-Version: 1.0 X-Received: by 10.180.37.166 with SMTP id z6mr23518505wij.34.1366179170335; Tue, 16 Apr 2013 23:12:50 -0700 (PDT) Received: by 10.194.5.193 with HTTP; Tue, 16 Apr 2013 23:12:50 -0700 (PDT) Received: by 10.194.5.193 with HTTP; Tue, 16 Apr 2013 23:12:50 -0700 (PDT) In-Reply-To: References: Date: Wed, 17 Apr 2013 02:12:50 -0400 Message-ID: Subject: Re: [AE] expressions: limiting decimals and adding 0 to single digit integers? From: Zack Lovatt To: After Effects Mail List Content-Type: multipart/alternative; boundary=e89a8f64674d25c39204da886097 X-Identified-User: {2847:host245.hostmonster.com:trinolia:zacklovatt.com} {sentby:smtp auth 74.125.82.46 authed with zack@zacklovatt.com} --e89a8f64674d25c39204da886097 Content-Type: text/plain; charset=ISO-8859-1 >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 --e89a8f64674d25c39204da886097 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

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

nums =3D thisComp.layer("shape").transform.rotatio= n.value.toFixed(2) + "";

if ((nums < 10) && (nums > -10)) nums =3D &quo= t;0" + nums;

nums;

I am linking one layers rotat= ion to a text layers source text.

How do I modify the simple expression to limit the decimal to two places, a= nd 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 =3D thisComp.layer("shape").transform.rotation;
amtOfZeroes =3D 2;
//--Do not modify below this line
isNeg =3D false;
if(nums < 0)
{
nums =3D Math.abs( nums );
isNeg =3D true;
}
sVal =3D Math.round( nums ) + "";
while(sVal.length < amtOfZeroes)
{
sVal =3D "0" + sVal;
}
if(isNeg)
sVal =3D "-" + sVal;

sVal
//--Expression ends


Thanks, James


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