ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

pull layer's comp name?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Alex Printz
pull layer's comp name?
on Nov 8, 2018 at 4:00:16 pm

Hey all, quick expression question:

If I have declared a layer in a variable:
L = comp("Comp 1").layer("Shape Layer 1");
can I later pull the comp name for L? e.g. (doesn't work)
N = L.propertyGroup(1).name

or do I need to declare them individually?
C = comp("Comp 1");
L = C.layer("Shape Layer 1");
n = C.name;

I would really prefer to declare as a single line (as this will half the time be pickwhip'd, half not), so if it's at all possible I'd love to hear!

Alex Printz
Mograph Designer


Return to posts index

Dan Ebberts
Re: pull layer's comp name?
on Nov 8, 2018 at 4:36:15 pm

The second one. Expressions don't have anything like the containingComp attribute that's available in scripting.


Dan



Return to posts index

Alex Printz
Re: pull layer's comp name?
on Nov 8, 2018 at 5:49:08 pm

Actually, it turns out that you can. After a bit of experimenting, you can grab the comp :

L = comp("Comp 1").layer("Shape Layer 1");
n = L.thisComp.name;


Strangely, if you do this, you cannot grab the layer the same way:

R = comp("Comp 1").layer("Shape Layer 1").content("Rectangle Path 1");
n = R.thisLayer.name


but you can do this:

R = comp("Comp 1").layer("Shape Layer 1").content("Rectangle Path 1");
n = R.propertyGroup(2).name


Alex Printz
Mograph Designer


Return to posts index


Dan Ebberts
Re: pull layer's comp name?
on Nov 8, 2018 at 6:23:26 pm

>n = L.thisComp.name;

I'm really surprised that this works. The expression language reference lists thisComp as a global object representing the comp containing the expression, but it must really be a layer attribute, with the layer defaulting to thisLayer.

thisLayer.thisComp.name

(which I would expect to throw an error) gives the same result as:

thisComp.name

You learn something every day I guess...


Dan



Return to posts index

Alex Printz
Re: pull layer's comp name?
on Nov 9, 2018 at 3:16:00 pm

Yeah that was really unexpected now that I'm looking at adobe reference page. Interesting that it can be referenced via the layer. Might have to play around with that some more.

Alex Printz
Mograph Designer


Return to posts index

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