ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Link Pin to the Bounding box of a shape layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
James Ronan
Link Pin to the Bounding box of a shape layer
on Jun 7, 2017 at 11:12:11 am

Hey guys

I've been using CC Bend It on a shape layer, but anytime I try to change position or rotate the shape layer the pin remains still in relation to the comp and I've had to manually keyframe the Start and End points with the layer.

I'm trying to get the Start pin to always been center top of the shape (bounding box), and the End pin to always be center bottom.

I've tried a few different variations but so far no avail. This is what I've got so far... but it's not even remotely working aha:

//For Start Pin at the center top of the bounding box
var L = thisLayer.sourceRectAtTime(0,true);
var xPos = L.left + thisLayer.width/2;
var yPos = L.top;
[xPos,yPos]

//For Start Pin at the center bottom of the bounding box
var L = thisLayer.sourceRectAtTime(0,true);
var xPos = L.left + thisLayer.width/2;
var yPos = L.top + thisLayer.height;
[xPos,yPos]

Any direction would be massively appreciated

J


Return to posts index

James Ronan
Re: Link Pin to the Bounding box of a shape layer
on Jun 7, 2017 at 4:12:27 pm

After trawling through the forums I've modified an expression that Dan Ebberts wrote a few years ago and it is ALMOST working!!

It now works on position and scale... just not for rotation.

This is my version of the expression:

//For Start Pin at the center top of the bounding box
L = thisLayer;
rect = L.sourceRectAtTime(time,false);
x = L.toComp([rect.left+rect.width/2,rect.top])[0];
y = L.toComp([rect.top+rect.width/2,rect.top])[1];

[x,y]

//For End Pin at the center top of the bounding box
L = thisLayer;
rect = L.sourceRectAtTime(time,false);
x = L.toComp([rect.left+rect.width/2,rect.top+rect.height])[0];
y = L.toComp([rect.top+rect.width/2,rect.top+rect.height])[1];

[x,y]

Any suggestions welcome :)


Return to posts index

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