ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trying to access XY of verrtices

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Markus Stone
Trying to access XY of verrtices
on Jul 14, 2019 at 11:38:00 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


Return to posts index

Markus Stone
Re: Trying to access XY of verrtices
on Jul 15, 2019 at 12:08:02 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


Return to posts index

Dan Ebberts
Re: Trying to access XY of verrtices
on Jul 15, 2019 at 1:18:41 am

Try it this way:

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


Dan



Return to posts index


Markus Stone
Re: Trying to access XY of verrtices
on Jul 15, 2019 at 6:44:51 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].


Return to posts index

Dan Ebberts
Re: Trying to access XY of verrtices
on Jul 15, 2019 at 1:22:08 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



Return to posts index

Markus Stone
Re: Trying to access XY of verrtices
on Jul 23, 2019 at 12:49:34 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


Return to posts index


Dan Ebberts
Re: Trying to access XY of verrtices
on Jul 23, 2019 at 1:03:35 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



Return to posts index

Markus Stone
Re: Trying to access XY of verrtices
on Jul 25, 2019 at 3:57:15 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


Return to posts index

Markus Stone
Re: Trying to access XY of verrtices
on Jul 25, 2019 at 3:58:50 am

Sorry, Ignore my last, just saw your reply.

Muchas Gracias :-)


Return to posts index

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