ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How do I get the comp's index number when...

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Stefan Grimm
How do I get the comp's index number when...
on Nov 23, 2019 at 4:23:17 pm

Hello everyone.

Maybe you can help me with the following:

I have a MainComp that contains another comp that contains a text layer (and other stuff) lets call this child comp "IDs". The text layer inside IDs should be a random number. That's no problem... but now I want to duplicate the IDs inside the MainComp n times and with every duplicate it should change the random number of my text layer.

My idea was to use the index that IDs has in the MainComp (parent) as a multiplicator. But I don't know how to fetch the index number that this comp has as child of another comp?

Does this makes sense?

I thought it should be somethin like this:

posterizeTime(0); // x should be kept over the whole time

var y = // how do I get the index of this comp thats a child of another?
var x = Math.round(random(99999))*y;

"ID: "+x;


Return to posts index

Dan Ebberts
Re: How do I get the comp's index number when...
on Nov 23, 2019 at 6:34:27 pm

Are you talking about duplicating the IDs layer inside the main comp? If so, you only end up with one instance of the IDs comp in the project panel, so there's no way to have each layer copy render differently.

You'd have to duplicate the comp in the project panel. Then each copy of the comp should get its own random number with:

posterizeTime(0);
Math.round(random(99999))


Dan



Return to posts index

Stefan Grimm
Re: How do I get the comp's index number when...
on Nov 23, 2019 at 7:11:03 pm

Hi Dan,

Thanks for your reply. No I want to duplicate the comp that contains the text layer, but this text layer should receive a random number nevertheless. That’s why I wanted to link the random to the index one level above. Do you have an idea how to get this done?


Return to posts index


Dan Ebberts
Re: How do I get the comp's index number when...
on Nov 23, 2019 at 7:19:30 pm

To be clear, when you say "duplicate the comp", you're talking about duplicating the comp in the project panel, not duplicating the comp layer in your master comp timeline, is that correct? If so, each duplicate comp should get automatically its own random number seed.

If you're talking about duplicating the comp layer in the master comp's timeline, then each of the "duplicates" actually has the same comp as it source, so you won't be able to have a different random number for each.

Dan



Return to posts index

Stefan Grimm
Re: How do I get the comp's index number when...
on Nov 23, 2019 at 9:12:13 pm

Sorry, I think I didn’t explained it correctly.

Within the Main Comp I want to duplicate the IDs composition, not in the projects panel.
And the text layer inside the IDs composition should get a new random value with each duplicate inside the Main Comp.

Timeline
—————————————-
Main Comp
|
|_ _ IDs Comp
| |_ Text Layer
|
|__ IDs Comp (duplicate)
| |_Text Layer
|
....

That’s why I wanted to know how to refer one level above and figure out how‘s the index for each duplicate


Return to posts index

Dan Ebberts
Re: How do I get the comp's index number when...
on Nov 23, 2019 at 9:19:00 pm

Sorry, doing it that way won't work. Duplicating in the time line doesn't create multiple versions of the comp. There may be multiple layers, but they all reference the same comp, and therefore there is only one text layer. Any change you make to that text layer will show up in all the "duplicates".

Dan



Return to posts index


Stefan Grimm
Re: How do I get the comp's index number when...
on Nov 23, 2019 at 9:27:33 pm

I know. That’s why I want to multiply the random number with the index the comp receives when I duplicate it. But not the index of the texlayer inside the IDs comp but the index of the duplicate. That’s why I want to read out the index of the duplicate inside the duplicate.

Does this make sense?


Return to posts index

Dan Ebberts
Re: How do I get the comp's index number when...
on Nov 23, 2019 at 9:41:16 pm

>with the index the comp receives when I duplicate it

The problem is that you're not duplicating a comp. You're duplicating a layer.

There is a way you can fake it. If you replace the expression on the text layer with this:

Math.round(random(99999))

so that it generates a new random number on each frame, and then turn on time remapping for the comp layer in your main comp, and add this time remapping expression:

seedRandom(index,true);
random(thisComp.duration)

Then when you duplicate the comp layer, each duplicate will display a different random number. Of course that won't work if you have other stuff going on in the comp.

Dan



Return to posts index

Stefan Grimm
Re: How do I get the comp's index number when...
on Nov 24, 2019 at 8:25:44 am

You guessed it, theres more going on in this comp- But your workaround yet helps me in case I need static comps.

THANK YOU!


Return to posts index

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