FORUMS: list search recent posts

How to properly get the center of a shape? Advanced Doubt

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Albert Navarro
How to properly get the center of a shape? Advanced Doubt
on Mar 28, 2019 at 3:32:48 pm

This may be hard to explain, but basically I have 3 shape layers with a circle. I'd like to connect them all with a line using "Beam". To do so, I pickwhip the starting point of the beam to the position of one of the circles, but it doesn't go to the center. The anchor point is centered and there is no offset anywhere, why doesn't it get the center of the circle?

Here are some screenshots so you can see what I mean:

This is what I'm trying to get:

This is what I have and what happens:

As you can see here there's no offset and the anchor point is centered:

I don't know if you can see it, put the beam's length is at a 100%, and the starting point is pickedwhiped to the small circle on the left, and the end point to the small circle on the bottom left. It moves correctly following the circles' keyframes, but there's like an offset that for some reason deviates the point from the center of the shape layer.

Is there anyway to get the circle's center?

Thanks in advance.

Return to posts index

Steve Bentley
Re: How to properly get the center of a shape? Advanced Doubt
on Mar 28, 2019 at 8:45:23 pm

After just a quick look: you have your circles as 3D layers. You have your beam as a 2D layer. Are they all at the same z depth? (which would have to be 0 since the beam is 2D.)
If you can't make your beam a 3D layer (and there's lots of reasons why that might be bad), you can use localToGlobal expressions to get the value of the circle's anchor point as it relates to 2D space.

Return to posts index

Albert Navarro
Re: How to properly get the center of a shape? Advanced Doubt
on Mar 28, 2019 at 9:42:12 pm

Hey! Thank you very much. Yeah that was basically the problem, I didn't think of that. I actually solved it by myself before my post was even approved, so I couldn't delete it. Sometimes you focus on the hardest things and it's the most basic stuff that you're doing wrong :)

Return to posts index

Oleg Pirogov
Re: How to properly get the center of a shape? Advanced Doubt
on Mar 28, 2019 at 9:25:58 pm

Shape Layer position is not the same as your circle center position.

Your circle center position is layer("Circle8").content("Ellipse 1").content("Ellipse Path 1").position
Which is [0,0].

Those coordinates are given in "Ellipse 1" group's own coordinate space. It's origin can be found as thisComp.layer("Circle8").content("Ellipse 1").transform.position - thisComp.layer("Circle8").content("Ellipse 1").transform.anchorPoint
Those are position and anchor point of "Ellipse 1" group, both =[0,0] in your case.

Those coordinates are given in Circle8's own coordinate space. And Circle8 position is thisComp.layer("Circle8").transform.position
Which is [426.2, 365.1, -45.0].

But it is a 3D layer shifted along Z-axis (by -45.0) and beam layer is in 2D, so simply taking first 2 coordinates won't correspond to visible shape layer's origin position i.e. beam will still be misplaced.

So you have to take all of this into account (expression for starting/ending point to move it to Circle8's center):
posPath=thisComp.layer("Circle8").content("Ellipse 1").content("Ellipse Path 1").position;
ancGr=thisComp.layer("Circle8").content("Ellipse 1").transform.anchorPoint;
posGr=thisComp.layer("Circle8").content("Ellipse 1").transform.position;
[p[0], p[1]];

BTW, since you have only changed layer's position leaving all other values a =[0,0], in your particular case you can just write:
[p[0], p[1]];

BTW, that "toComp" thing is the one that accounts for Z-axis shift of the shape layer.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved