FORUMS: list search recent posts

Why doesn't the AE Numbers plug-in have commas???

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Nick Natteau
Why doesn't the AE Numbers plug-in have commas???
on Feb 17, 2012 at 8:51:55 pm

Just wondering why the Numbers plugin has no option for commas.

Why is it that using the Numbers decimal counter plugin you can display "1080.90" but there's no option to display that same number as "1,080.90"

Am I missing something or does the Numbers plug-in in After Effect have no comma option for numbers above 999???

And if that's the case, supposing i wanted a decimal counter to display numbers with commas as well as dots, how can I get the commas to display so that for example 123456.10 reads "123,456.10"

Thanks very much in advance if someone can point me to a simple tutorial or decimal counter expression script that generates a decimal counter with commas and dots for four figure numbers.


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 17, 2012 at 9:42:04 pm

Nick

I will put this in a code section as I think the COW has been stripping bits off, but the basic answer to your question is that javascript is lacking in number format area and you have to write your own function for it. I have got your expression down to a one liner for you. If you want to do the same format to another number, first make sure your number is a string, then add from the .replace part as below: I have cut & pasted and tested this so it should work for you


(effect("Slider Control")("Slider").value.toFixed(0)+" Miles").replace(/(d)(?=(d{3})+(?!d))/g, "$1,");


Declan Smith
http://www.madpanic.tv
FCS3 / After Effects CS5 / Combustion / Canon 7D / Canon XL2


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 17, 2012 at 9:55:25 pm


(effect("Slider Control")("Slider").value.toFixed(0)+" Miles").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");


Last attempt above to get the cow to insert backslashes. Everytime you see a d above put a backslash before it if backslashes are not being displayed.

It should look like this:



Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase


Return to posts index


Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 17, 2012 at 11:02:24 pm

Hi Declan,

Thank you so much! I really appreciate your help.


Return to posts index

Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 17, 2012 at 11:05:52 pm

Hi Decan,

One more question. If this number were a currency instead of a distance and i wanted the "$" symbol before instead of after the number, where in the expression would the "$" symbol have to go to be before rather than after the number?

Thanks again so much for helping me out with this.


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 18, 2012 at 12:18:39 am

Hi

You would put the currency symbol before the expression. I have shown this below, and shown it more verbosely in the second example.


"$" + (effect("Slider Control")("Slider").value.toFixed(0)).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");


In the fragment below, number is a variable that takes the numeric value from the slider. The other variable names should be self explanatory and are all strings.
The last line shows how they are concatenated together.


number = effect("Slider Control")("Slider").value;
numberFormatted = number.toFixed(0);
numberFormattedAsStringWithCommas = (numberFormatted + '').replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
prefix="$";

prefix + numberFormattedAsStringWithCommas;


Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase


Return to posts index


Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 5:20:41 pm

Hi Declan,

If I might just ask you another follow up question regarding the numbers effect.

I'm doing this for a documentary film about Hyperinflation in Weimar Germany when the Reichmark went from 12 Rm to the dollar to 4,200,000,000,000 Rm.

So my problem now is that in AE the number seems to stop at 1,000,000. How do I get past this??? I'm sure there's a way but i can't figure out. Thank you very much in advance.


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 6:00:34 pm

I think that is a hard limit of the slider control. Not quite sure what you are doing, but I guess you are keyframing the value or something. You could use a "Point Control" instead of a slider and just use one of the dimensions if you are trying to store the numbeer e.g

replace

effect("Slider Control")("Slider")

with

effect("Point Control")("Point")[0]

The full expression would then become:


"$" + (effect("Point Control")("Point")[0].value.toFixed(0)).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");


Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase


Return to posts index

Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 8:13:51 pm

Hi Declan,

Sorry but I can't get it to work. I just copy and pasted your last line exactly as you had it and now nothing appears:

"$" + (effect("Point Control")("Point")[0].value.toFixed(0)).replace(/(d)(?=(d{3})+(?!d))/g, "$1,");


Return to posts index


Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 8:38:14 pm

Nick,

Sorry, would have help if I had pasted a valid expression ;)

Try this. I have also included the screen shot in case the characters get corrupted:


"$" + (effect("Point Control")("Point")[0].toFixed(0)).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");




Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase


Return to posts index

Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 9:05:29 pm

Hi Declan,

Sorry to keep bothering you like this. But my final question: how would I ramp up my numbers in speed.

For example in my animation I have to show the Reichsmark hyperinflation increasing from
$1=12 Rm in 1919 to $1=17,000 Rm by 1923...

But in 1923 it increases dramatically from $1=17,000 Rm in Jan 1923 to $1=4,200,000,000 by Dec 1923

So I would need my numbers to ramp up in speed dramatically. Does this require another expression???


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 9:46:29 pm

This shouldn't need another expression. The expression you have is purely for formatting the required number. Assuming that you are now using the point control that I suggested, you just need to add keyframes at the various points to ramp up through time to suit.

So if I assume that your animation is over say 10 seconds, then at the beginning, set the value of the x portion of the point control to 12, add a keyframe. Then say at 5 seconds add another keyframe by changing the value to 17000, then say at 8 seconds set another keyframe with the value 4200,000,000.

Clearly you will need to play with timings and possibly keyframe interpolation, to get the ramping how you want it.

Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase


Return to posts index


Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 9:58:24 pm

Thanks very much Declan.

Actually I did just that: used point instead of slider as you suggested, then added 3 keyframes (one for 12, one for 17,000 and one for 2,400,000,000)...but after I did that: from 12 to 17,000 the numbers were then going in reverse and after 17,000 forward. I can't make it out. Will try again.


Return to posts index

Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 10:03:50 pm

Thanks very much Declan.

Actually I did just that: used point instead of slider as you suggested, then added 3 keyframes (one for 12, one for 17,000 and one for 2,400,000,000)...but from 12 to 17,000 the numbers are going in reverse. Really weird.

And when I now delete the middle keyframe and just go from 12 to 17,000 the number seems to ramp up to 6,000,000 and the go instantly down to 17,000.


Return to posts index


Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 10:14:33 pm

Select all the keyfames for the point control, cmd click (or ctrl click if on windows) until they are all diamond shapes. Then, with them all selected, right click and select 'keyframe interpolation'. Now change both temporal and spatial interpolation to linear.

This should stop the numbers going negative.



Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase


Return to posts index


Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 20, 2012 at 11:19:18 pm

Hi Declan,

Thank you so much for all your help! It worked!


Return to posts index

Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 21, 2012 at 12:09:46 am

Hi Declan,

I believe some currencies like the Euro actually go after the number. So I've been trying to change the position of the currency from appearing before to appearing after with the point instead of slider expression, and it doesn't seem to be working:

I tried changing this:

"$" + (effect("Point Control")("Point")[0].toFixed(2)).replace(/(d)(?=(d{3})+(?!d))/g, "$1,");

to this:

(effect("Point Control")("Point")[0].toFixed(2)).replace(/(d)(?=(d{3})+(?!d))/g, "$1,"); + "S"


but the currency symbol isn't appearing after. It seems to be breaking the setup.


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 21, 2012 at 12:34:11 am

Nick

In the expression, the semi-colon at the end is a terminating character and must always be the last thing on the line.

eg. change what you have, to read

(effect("Point Control")("Point")[0].toFixed(2)).replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, "$1,") + "S" ;


Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase


Return to posts index


Nick Natteau
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 21, 2012 at 10:53:30 pm

Hi Declan,

Thank you very much! I admire your patience with me. AE is an amazing program, and I feel like I've only just scratched the surface of what it can do. But all those expressions are really intimidating. I'm very grateful to you for taking the time to explain it all. I'm sure this will help others as well. Thanks again!


Return to posts index

Van Bridges
Re: Why doesn't the AE Numbers plug-in have commas???
on Nov 6, 2012 at 2:46:20 pm

How from here would I add a multiplayer, EX (*3.5)


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Nov 6, 2012 at 5:13:42 pm

Change the expression to something like:



Declan Smith
http://www.madpanic.tv
After Effects CS5.5/ FCS3 / Canon 7D / Canon XL2 / Reason / Cubase

"it's either binary or it's not"


Return to posts index

Luc Nutter
Re: Why doesn't the AE Numbers plug-in have commas???
on Dec 7, 2012 at 9:24:21 am

Thanks for the script, Declan. It was exactly what I was looking for, and your posts helped me a lot!

Cheers,

Luc


Return to posts index

Barry Rubin
Re: Why doesn't the AE Numbers plug-in have commas???
on Aug 8, 2013 at 4:10:02 pm

Can you further explain "first make sure your number is a string, then add from the .replace part as below:"

Thanks Barry

Love is great

Barry R.


Return to posts index

jamie buck
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 13, 2014 at 7:49:11 pm

Hi Declan,

I am using the code you provided to put that includes the dollar sign in front of the number, but I was wondering if its possible to also include the 2 decimal places. ( i.e. $1,000.12)?


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on Feb 13, 2014 at 8:43:20 pm

This thread lives again!

The bit that is truncating the decimal point is where it says 'toFixed(0)'. If you want two decimal places, then this needs to change to 'toFixed(2)'. The full modified expression as below:

"$" + (effect("Point Control")("Point")[0].toFixed(2)).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");

Declan Smith
http://www.madpanic.tv
After Effects CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

"it's either binary or it's not"


Return to posts index

Felipe SantamarĂ­a
Re: Why doesn't the AE Numbers plug-in have commas???
on May 11, 2016 at 3:30:46 pm

Hey Declan,

I've used this code before for animated counters, so THANK YOU SO MUCH, but there's somenthing I've been unable to do.

Some times I've been asked to use commas to separate thousands and points to separate decimals (1,000.10), but sometimes I've been asked the opossite, to separate decimals with commas and thousands with points (1.000,10).

How can I do this?

Thank you for this code. This thread lives again!


Return to posts index

Declan Smith
Re: Why doesn't the AE Numbers plug-in have commas???
on May 11, 2016 at 5:55:37 pm

Wow, this thread really does live on. Ok, if you want to do as you are saying, then try this. Basically, replace the "." with "," then add the separator as a "."


num = "$" + (effect("Point Control")("Point")[0].toFixed(2)).replace(".", ",").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1.");


Hope this is what you're after.

Declan Smith
http://www.madpanic.tv
After Effects CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

"it's either binary or it's not"


Return to posts index

Liran Tabib
Re: Why doesn't the AE Numbers plug-in have commas???
on Apr 22, 2016 at 7:15:28 am

keeping this thread alive!
if you are tired of programming your way out of counter animation you can use this Counter preset:http://www.vdodna.com/products/counter-preset/


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]