Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trying to access XY of verrtices

  • Trying to access XY of verrtices

    Posted by Markus Stone on July 14, 2019 at 11:38 pm

    Hi all,

    I’m trying to access the XY of say, vertice number 1 in a rectangle shape layer as proof of concept for something I’m trying to do, but even these baby steps are too big for me because I’m falling over at the first hurdle.

    I have this expression sitting on the position property of a Null layer.

    thisComp.layer("Test").content("Shape 1").content("Path 1").path.points(1);

    I *think I’m telling a null layer’s position property to look at vertex (1) on a bezier shape in a layer called ‘Test’, only I get told that this ‘array piece can’t expand to more than one value’.

    Huh? The position property of a layer is [x,y] and so is the position of a vertex, so what gives?

    Thanks for any guidance.

    Markus

    Markus Stone replied 6 years, 9 months ago 2 Members · 8 Replies
  • 8 Replies
  • Markus Stone

    July 15, 2019 at 12:08 am

    …and if I try it like this, I get ‘[…] is not a function’ whether or not I define anything in points()

    thisComp.layer("Test").content("Shape 1").content("Path 1").content("path").points();

    Apologies for the newbie posts, but I can’t find a guide to expression errors and what they might mean in english.

    So it’s not a function. Cool. So what does that mean I might have done wrong?

    Thanks,
    Markus

  • Dan Ebberts

    July 15, 2019 at 1:18 am

    Try it this way:

    L = thisComp.layer(“Test”);
    p = L.content(“Shape 1”).content(“Path 1”).path.points();
    L.toComp(p[0])

    Dan

  • Markus Stone

    July 15, 2019 at 6:44 am

    Oh My God, it works!

    Thank you Dan (legend!)

    I’ve commented my understanding of the code below. What I don’t get is why;

    a) Addressing the points must be done by first breaking everything up into variables. I mean, you could make a variable for “Path 1” too if you really wanted. How does substituting variables help us here?

    b) toComp? Is that because the shape layer dimensions are *not necessarily the same size as the composition size? Would this be unnecessary of it was a mask on a footage layer if it was the same size as the composition itself?

    Cheers and thanks!
    Markus

    My Understanding of the code

    L = thisComp.layer(“Test”);
    //define variable L as this comp “Test”

    p = L.content(“Shape 1”).content(“Path 1”).path.points();
    //define variable p as the ‘points’ parameter of the L (Test) Layer

    L.toComp(p[0])
    // Take ‘Test’ layer (variable ‘L’), transform point from layer space to composition space, *then specify which point you want the X,Y of [0].

  • Dan Ebberts

    July 15, 2019 at 1:22 pm

    a) You don’t have to use intermediate variables, it just makes the code simpler (in my opinion) and more compact.

    b) the path vertices are specified in layer “Test”‘s layer space. toComp() converts them to comp space.

    p is an array of vertices, p[0] is the first vertex.

    Dan

  • Markus Stone

    July 23, 2019 at 12:49 am

    So, to enhance my understanding, (if you’re happy to teach a noob like me ☺) would you be happy to show me how it would look *without intermediate variables?

    I have a problem with my syntax that I need to resolve, and I kinda thought the above would work.

    Cheers & thanks

    Markus

  • Dan Ebberts

    July 23, 2019 at 1:03 am

    I guess that would be like this:

    thisComp.layer(“Test”).toComp(thisComp.layer(“Test”).content(“Shape 1”).content(“Path 1”).path.points()[0])

    Dan

  • Markus Stone

    July 25, 2019 at 3:57 am

    How would it look if you weren’t to use intermediate variables?

    I’m just trying to figure out where I went wrong with my attempt. I think I have the syntax wrong, but everything I tried crashed and burned.

    Cheers
    M

  • Markus Stone

    July 25, 2019 at 3:58 am

    Sorry, Ignore my last, just saw your reply.

    Muchas Gracias 🙂

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