Skip to main content
Participating Frequently
September 7, 2023
Answered

Grid of precomps, each with a distinct number

  • September 7, 2023
  • 2 replies
  • 504 views

Hi there,

 

My goal is to make a 10x10 grid of precomps (animated squares), each with its own random number physically displayed on top of it.

 

My setup: I have a single PRECOMP called "Square," which is an animated square (it doesn't yet have an animated number on it). I dragged this PRECOMP into my MAIN COMP, then duplicated it 100 times so that the X and Y positions increment based on the X and Y positions of the previous PRECOMP (index - 1 equation).

 

Does anyone know if it's possible to add a random number on top of each square? I obviously can't do this in the PRECOMPs themselves because they're all duplicates of a single PRECOMP. 

 

Happy to provide more information 🙂 

 

Thanks!

This topic has been closed for replies.
Correct answer Rick Gerard

You could number the comps. Name the first pre-comp (nested comp) "1," then add this expression to a text layer to generate a random number based on a random seed based on the layer name (the number);

 

n = thisComp.name;
seedRandom(n, true);
v = random() * 100;
v.toFixed()

 

Then, all you have do to is duplicate the first numbered comp in the Project Panel and drag them into the main comp. Because you multiply the random number generated by 100, the expression will give you a two-digit number between 0 and 99.

 

Another approach would be to use a similar expression to generate the number of ten text layers named with a number and arrange the text layers on top of the ten nested comps. n = thisLayer.name; would do it.

2 replies

Rick GerardCommunity ExpertCorrect answer
Community Expert
September 8, 2023

You could number the comps. Name the first pre-comp (nested comp) "1," then add this expression to a text layer to generate a random number based on a random seed based on the layer name (the number);

 

n = thisComp.name;
seedRandom(n, true);
v = random() * 100;
v.toFixed()

 

Then, all you have do to is duplicate the first numbered comp in the Project Panel and drag them into the main comp. Because you multiply the random number generated by 100, the expression will give you a two-digit number between 0 and 99.

 

Another approach would be to use a similar expression to generate the number of ten text layers named with a number and arrange the text layers on top of the ten nested comps. n = thisLayer.name; would do it.

mrossi206Author
Participating Frequently
September 8, 2023

This is brilliant. Thank you 🙂

Mylenium
Legend
September 8, 2023

There's still the good old Numbers effect...

 

Mylenium