Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Are there internal index numbers inside shape layers?

  • Are there internal index numbers inside shape layers?

    Posted by David Cabestany on September 19, 2019 at 2:40 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.

    David Cabestany replied 6 years, 9 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    September 19, 2019 at 8:29 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

  • David Cabestany

    September 19, 2019 at 8:37 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]

  • Dan Ebberts

    September 19, 2019 at 9:07 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

  • David Cabestany

    September 19, 2019 at 10:23 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.

  • David Cabestany

    September 19, 2019 at 10:53 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.

  • Dan Ebberts

    September 20, 2019 at 12:50 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

  • David Cabestany

    October 31, 2019 at 10:17 pm

    I just realized I never thanked you for this, so thank you very much, it was a huge help.

    Best,
    David.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy