Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Position of shape layer elements

  • Position of shape layer elements

    Posted by Jonas Karten on May 8, 2019 at 3:54 pm

    Hi there!

    I have a grid with 120 circles (within a single shape layer) which I want to animate through another layer.

    The circles are supposed to check which color is on their exact position on this second layer and change their size accordingly. Black will shrink them to 0%, gray shrinks them to 50% and white will leave them at 100% of their size.

    This works not like I want since all individual circles use the same reference point, the position of the layer and not the single element.

    Question: How can I change

    “samplePoint = transform.position;”

    to a behaviour like

    “samplePoint = content(“Circle_123″).transform.position;”

    without using absolute names like “Circle_123” but something more universal like “this.Element” or “this.Content”?

    Or would it be easier if I just place every circle on a different layer with the shape centered on this layer? Until now, I tried to keep the the circles in a single shape layer to have a better overview and be able to change the properties more easily.

    sourceLayer = comp("Grid").layer("Gradient");
    sampleSize = [1,1];
    samplePoint = transform.position;
    color= sourceLayer.sampleImage(samplePoint,sampleSize);
    x=color[0]*100;
    [x,x]

    Filip Vandueren replied 7 years, 4 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 8, 2019 at 4:39 pm

    Assuming that the Gradient layer is comp-sized and you’re applying the expression to the Size property, something like this should be close:

    sourceLayer = comp(“Grid”).layer(“Gradient”);
    sampleSize = [1,1];
    samplePoint = toComp(thisProperty.propertyGroup(3)(“Transform”)(“Position”));
    color= sourceLayer.sampleImage(samplePoint,sampleSize);
    x=color[0]*100;
    [x,x]

    Dan

  • Jonas Karten

    May 9, 2019 at 9:44 am

    Thank you very much Dan, this is what I needed. Didn’t know about the propertyGroup yet! Great!

    With the help of your code I’ve applied it to the scale within the “transform: Circle 123” tab of the individual circle:

    sourceLayer = comp(“Raster”).layer(“Verlauf”);
    sampleSize = [1,1];
    samplePoint = toComp(thisProperty.propertyGroup(2)(“Transform”)(“Position”));
    color= sourceLayer.sampleImage(samplePoint,sampleSize);
    x=color[0]*100;
    [x,x]

    I understand that propertyGroup(2) looks up the value of the second element within the group/transform-tab, which is the position, right? Like this I can still use the percentages and a starting size of the circle.

  • Dan Ebberts

    May 9, 2019 at 11:59 am

    propertyGroup(2) moves up two levels in the hierarchy from the property hosting the expression. It gets a little tricky with shape layers because not all the property levels are visible in AE’s UI.

    Dan

  • Filip Vandueren

    May 9, 2019 at 6:57 pm

    True,

    this script is a godsend to try and comprehend how properties are nested into each other:

    https://www.redefinery.com/ae/view.php?item=rd_GimmePropPath

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