ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Counting Layers in a comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Obed Ampong
Counting Layers in a comp
on Aug 24, 2019 at 8:52:44 pm

Hi,
Please, I came across this expression to count layers in pre-comp somewhere. When I tried it, it seems to be working however it displays nothing. Could anyone help me out? Thanks in advance.
Regards,

Obed

var myComp = app.project.activeItem;

var myLayer = thisComp.layer("Comp 1")Layers[0];

alert (myLayer.source.numLayers)


Return to posts index

Dan Ebberts
Re: Counting Layers in a comp
on Aug 24, 2019 at 9:22:02 pm

That looks like a script, not an expression. What do you want to do with the number?

Dan



Return to posts index

Dan Ebberts
Re: Counting Layers in a comp
on Aug 25, 2019 at 12:00:36 am

If you apply this expression to the Source Text property of a text layer, it will display the number of layers in Comp 1:

comp("Comp 1").numLayers

Dan



Return to posts index


Obed Ampong
Re: Counting Layers in a comp
on Aug 25, 2019 at 3:35:12 am

Hello Dan,

It works!!! Thank you very much.

Regards,

Obed


Return to posts index

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