ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

get property of layer by index

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andy Engelkemier
get property of layer by index
on Mar 21, 2018 at 2:24:26 pm

I'd like to use the same effect for a bunch of layers where I'm basically just linking only X or Y position of a parent layer. But I'd have to change the expression over and over.

So I'd rather just have to keep the layers in order. So it'd be layered parent, child for X, child for Y, next parent, child for X, child for Y.

So what I'm after is calling the position of the parent, but rather than using it's name, it's index. So i'd figure out my current child parent index and just subtract 1 (or 2 for the second child) so that they are pointing to the parent layer.

But I can't figure out how to change a layer property based on a specific index.


Return to posts index

Andrei Popa
Re: get property of layer by index
on Mar 21, 2018 at 3:00:00 pm

You mean like this?
First child:
thisComp.layer(index-1).transform.position
Second child:
thisComp.layer(index-2).transform.position

Andrei
My Envato portfolio.


Return to posts index

Andy Engelkemier
Re: get property of layer by index
on Mar 21, 2018 at 5:13:15 pm

I think so, yes. thank you.
All the examples I could find we calling just an index number, using the index to call on another property. So I couldn't figure out how to order things.
I suppose it's always comp.layer.property.subproperty?

I need just one example of the longest one possible, so I could see the order of things in order to properly call on things.

Thanks


Return to posts index


Dan Ebberts
Re: get property of layer by index
on Mar 21, 2018 at 5:25:52 pm

You could also use this to get the parent's position:

parent.transform.position

this to get the grandparent's position:

parent.parent.transform.position

etc.


Dan



Return to posts index

Andy Engelkemier
Re: get property of layer by index
on Mar 21, 2018 at 5:56:37 pm

That sounds like something I would use, but I'm not sure I understand.
I don't know what the "parent" part is indicating. Is that meaning that the layer is actually parented? Because putting position there wouldn't make sense to me, unless maybe you're after adding some math to it.

I was after having a ground shadow and wall shadow follow my layer. But then I'd duplicate those layers, and replace them with a different object. But the expression doesn't change to the newly duplicated layers, so I was looking to accomplish the same thing with index.

So the ground shadow would be linked only to XZ, and the wall shadow would only be linking to XY.

I didn't like the effect anyway, but still like to know different ways of doing things. Especially when they are more efficient.


Return to posts index

Dan Ebberts
Re: get property of layer by index
on Mar 21, 2018 at 6:07:07 pm

Ah, so the layers aren't actually parented together. Sorry, I misunderstood.

Dan



Return to posts index


Andy Engelkemier
Re: get property of layer by index
on Mar 21, 2018 at 6:25:40 pm

Shoot, I thought you were about to teach me something that was going to blow my mind.

I mean, always helpful of course. If you're ever in Kalamazoo, I'll buy some beers. Every time I'm stuck, I usually hit your site before even googling, and the answer is usually there. Most of which is over my scripting head, but still helpful.


Return to posts index

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