ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Are there internal index numbers inside shape layers?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Cabestany
Are there internal index numbers inside shape layers?
on Sep 19, 2019 at 2:40:00 pm

I need to cascade an expression that looks more or less like this:

content("Ellipse 1").transform.position

I have Ellipse 1, Ellipse 2, etc . Can I change the name of the shape for a generic word +1 like we do with the index of a layer?

Thanks in advance,
D.


Return to posts index

Dan Ebberts
Re: Are there internal index numbers inside shape layers?
on Sep 19, 2019 at 8:29:02 pm

Normally you can use propertyGroup() and propertyIndex to navigate a shape layer's property hierarchy, but it depends on what you're trying to do exactly.


Dan



Return to posts index

David Cabestany
Re: Are there internal index numbers inside shape layers?
on Sep 19, 2019 at 8:37:19 pm

I'm trying to push position 100 pixels further than the previous ellipse. Right now it looks like this:

And I'd like to replace ("Ellipse #") with the index of the object. It's a shape layer with multiple ellipses in it. I manually replaced the number ("Ellipse 4,5,6 etc) but if I can do it with index numbers would be better.

Thanks

y=thisComp.layer("xp").effect("y")("Slider");
content("Ellipse 4").transform.position+[0,y]


Return to posts index


Dan Ebberts
Re: Are there internal index numbers inside shape layers?
on Sep 19, 2019 at 9:07:55 pm

OK, so if this expression is going to live in the Position property of the ellipse's Transforms, you can find out the ellipse's number like this:

p = thisProperty.propertyGroup(2);
idx = parseInt(p.name.split(" ")[1],10)

or, if you want that ellipse's index (maybe they're stacked from highest number to lowest), you could do this:

p = thisProperty.propertyGroup(2);
idx = p.propertyIndex;

I hope that helps.

Dan



Return to posts index

David Cabestany
Re: Are there internal index numbers inside shape layers?
on Sep 19, 2019 at 10:23:18 pm

Thanks Dan.

Yes, they are stacked with the highest on top and the lowest at the bottom, when I duplicated them the newer ones were created above the previous ones.

It partially works, the expression is not broken, but the values are all haywire. I'll try tweaking it to see if I can make it work.

Thanks again,
D.


Return to posts index

David Cabestany
Re: Are there internal index numbers inside shape layers?
on Sep 19, 2019 at 10:53:41 pm

Hey Dan, two more questions and I promise I'll get off your hair.

1. How do you determine that Ellipse # is the propertyGroup(2)? I tried adding extra objects on the shape layer and it only works with 2, every other number breaks the expression so I haven't been able to determine which one is propertyGroup(1), (3), etc.

2. I think the 10 after the [1] array determines which character to read from the 2nd word, in this case the number of the Ellipse, but why 10? I tried other numbers such as 8 and the expression still works but I don't get where the result is coming from, the numbers are unrelated.

Sorry for all the asking, I'm trying to understand what is going on so I don't keep bothering with lame questions in the future.


Return to posts index


Dan Ebberts
Re: Are there internal index numbers inside shape layers?
on Sep 20, 2019 at 12:50:52 am

Say you have a shape layer with 5 ellipses. Then you create a text layer with this Source Text expression:

p = thisComp.layer("Shape Layer 1").content("Ellipse 5").transform.position;
p.propertyGroup(1).name

You should get "Transform", which is one property group up from "Position". If you change it to:

p = thisComp.layer("Shape Layer 1").content("Ellipse 5").transform.position;
p.propertyGroup(2).name

You should now see "Ellipse 5".

If you continue one, you'll see "Contents" and "Shape Layer 1".

The 10 you're asking about is part of parseInt(), and it just specifies what number base to use for the conversion from string to integer. If you stick an 8 in there, it will convert the number to base 8, which doesn't matter as long as the number you're converting is less than 8.

Fire away if you have more questions.

Dan



Return to posts index

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