• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ordinal numerals in after effects

New Here ,
Jun 23, 2022 Jun 23, 2022

Copy link to clipboard

Copied

Hi, 

is it possible to do ordinal numerals in after effects,

I mean like if a text source layer is linked to a slider control and goes 21, 22, 23 ... etc

another text layer shows "st" "nd" "rd" else "th" 

 

Thank you,

R

TOPICS
Expressions , How to , Scripting

Views

145

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jun 27, 2022 Jun 27, 2022

There's a pattern of 3s (ST,ND,RD) which a modulus (%3) can capture easily and you can run through your original numbers via their respective array index numbers. 

You can use the javascript Map Method to run a function involving modulus across the index of the array and then just read of the newly created array. It's complex but also not too difficult. Unfortunately, it's going to take quite a while to go through this, for me. Hopefully, someone is quicker to the task or has a different approach

...

Votes

Translate

Translate
Valorous Hero ,
Jun 23, 2022 Jun 23, 2022

Copy link to clipboard

Copied

Lots of things are possible in AE and so is this. Mostly, it depends on how much time and knowledge you have to find the most efficient way to do it. At the basic level, you can link an Expression Slider to an array within a Text Layer such that each point (use Math.round) on the slider is accompanied by an array made up of your different text bits. 
HTH


Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

Thanks for replying, do you know if there is a better way than this

 

if(parseInt(thisComp.layer("Number").text.sourceText) == 1) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 2) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 3) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 21) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 22) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 23) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 31) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 32) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 33) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 41) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 42) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 43) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 51) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 52) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 53) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 61) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 62) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 63) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 71) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 72) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 73) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 81) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 82) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 83) "rd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 91) "st"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 92) "nd"; else if(parseInt(thisComp.layer("Number").text.sourceText) == 93) "rd";

else "the";

 

so this one works until 100, if there's no better solution, do you know how I can do it like 

if(parseInt(thisComp.layer("Number").text.sourceText) == 1 OR 21 OR 31) "st"; else ..... etc

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

LATEST

There's a pattern of 3s (ST,ND,RD) which a modulus (%3) can capture easily and you can run through your original numbers via their respective array index numbers. 

You can use the javascript Map Method to run a function involving modulus across the index of the array and then just read of the newly created array. It's complex but also not too difficult. Unfortunately, it's going to take quite a while to go through this, for me. Hopefully, someone is quicker to the task or has a different approach. 

Info on the Javascript MAP method can be found here - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

HTH

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines