Return-Path: Received: from asbnvacz-mailrelay01.megapath.net ([207.145.128.243] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with ESMTP id 5041147 for AE-List@media-motion.tv; Wed, 17 Apr 2013 08:23:54 +0200 Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net [69.17.117.53]) by asbnvacz-mailrelay01.megapath.net (Postfix) with ESMTP id 3F2C81EE4FE6 for ; Wed, 17 Apr 2013 02:32:01 -0400 (EDT) Received: (qmail 21831 invoked from network); 17 Apr 2013 06:32:00 -0000 Received: by simscan 1.4.0 ppid: 32454, pid: 9882, t: 0.3587s scanners: clamav: 0.88.2/m:52/d:13495 spam: 3.0.4 Received: from c-67-185-28-214.hsd1.wa.comcast.net (HELO [192.168.1.125]) (albion@[67.185.28.214]) (envelope-sender ) by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 17 Apr 2013 06:32:00 -0000 From: James Culbertson Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: multipart/alternative; boundary="Apple-Mail=_133770E0-993F-4C94-89AC-300AE5035021" Subject: Re: [AE] expressions: limiting decimals and adding 0 to single digit integers? Date: Tue, 16 Apr 2013 23:31:15 -0700 In-Reply-To: To: "After Effects Mail List" References: Message-Id: <7D22A1BE-C5BB-4C31-9EE5-CD03D43D79AF@speakeasy.net> X-Mailer: Apple Mail (2.1283) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail8.sea5 X-Spam-Level: X-Spam-Status: No, score=0.1 required=8.0 tests=HTML_30_40,HTML_MESSAGE autolearn=disabled version=3.0.4 --Apple-Mail=_133770E0-993F-4C94-89AC-300AE5035021 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 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: > =46rom 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! >=20 > nums =3D thisComp.layer("shape").transform.rotation.value.toFixed(2) + = ""; >=20 > if ((nums < 10) && (nums > -10)) nums =3D "0" + nums; >=20 > nums; >=20 > I am linking one layers rotation to a text layers source text. >=20 > 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,...? >=20 > Something like this but that adds two decimal places to the number: >=20 > //--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; >=20 > sVal > //--Expression ends >=20 >=20 > Thanks, James >=20 >=20 > +---End of message---+ > To unsubscribe send any message to --Apple-Mail=_133770E0-993F-4C94-89AC-300AE5035021 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=iso-8859-1
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>

--Apple-Mail=_133770E0-993F-4C94-89AC-300AE5035021--