Expressions/Scripts/Presets

Moderators: Disciple, zlovatt

 
vranan
Topic Author
Posts: 13
Joined: Tue Feb 08, 2005 9:53 am
Contact:

align layers along a path

Mon Nov 02, 2009 8:05 am

Hi,
I am trying to align an n-amount of layers (ie 10) to distribute themselves along a path I have drawn in Illustrator. Now I know you can copy a path for Illustrator into a mask and then copy the mask into the layer's position property, but is there a way to automatically distribute my layers equally along any given path. Any help is appreciated.

Nino
 
kobyg
Posts: 128
Joined: Fri Dec 07, 2007 10:11 am

Re: align layers along a path

Mon Nov 02, 2009 2:42 pm

You could copy your path to the position of a NULL layer, making it move according to your path,
and then use the valueAtTime expression to sample that position to each of your 10 layers, using the layer's index in order to sample at a different time.
You could use a slider to change the spacing between your layers.

The expression should be something like:
dt = effect("Slider Control")("Slider");
thisComp.layer("Null 1").transform.position.valueAtTime(index*dt)

Koby.
 
vranan
Topic Author
Posts: 13
Joined: Tue Feb 08, 2005 9:53 am
Contact:

Re: align layers along a path

Tue Nov 03, 2009 6:58 am

Hi Koby,

thanks for your help, it's working a treat. I was wondering if there is a way to auto orient my layers along the path (ie a spiral). I've auto orientated the Null to move along the path, but my layers wont follow (neither when I set all my layers to auto orient) :(

Thank you,
Nino
 
kobyg
Posts: 128
Joined: Fri Dec 07, 2007 10:11 am

Re: align layers along a path

Tue Nov 03, 2009 8:59 am

Hi Nino,

The Auto-orient will not work...
However you can use another expression for the Orientation :)
This expression will make the layer look at the tangent direction of the original path, using the lookAt expression.
It should look something like:

nullPos = thisComp.layer("Null 1").position;
dt = thisComp.layer("Null 1").effect("Slider Control")("Slider");
T = thisComp.frameDuration;
p0 = nullPos.valueAtTime(index*dt);
p1 = nullPos.valueAtTime(index*dt+T);
lookAt(p0,p1)

or you could use a simpler expression, that will make each layer look at the next layer (which is a bit different, and less accurate, but will seem quite similar):
p0 = position;
p1 = thisComp.layer(index+1).position;
lookAt(p0,p1)

Note that if you use the second expression, you would need a bit different expression for the LAST layer, because of the (index+1) phrase, or else you would get an error...
so you could make the last layer look at the previous layer (index-1) instead of the next layer (index+1).

Koby.
 
vranan
Topic Author
Posts: 13
Joined: Tue Feb 08, 2005 9:53 am
Contact:

Re: align layers along a path

Mon Nov 16, 2009 10:28 am

Hi Koby,

sorry was busy finishing project that i never said thank you for all your help!
 
sameervalva
Posts: 4
Joined: Fri May 21, 2010 2:39 am

Re: align layers along a path

Fri Jan 07, 2011 6:05 am

Hi kobyg

Can We Make all layers depend on the a slider control added to the null so we can change the value of the distance from one layer instead of changing it from each layer

Thanks alot
 
alchemist988
Posts: 1
Joined: Fri Jan 08, 2016 1:12 am

Re: align layers along a path

Fri Jan 08, 2016 2:01 pm

Hello everyone

I hope that someone will see this post or I should post new one...?

I have one problem to solve. I am currently working on 2D animation in which I have to solve problem of bulldozer truck movement, and also movements of joints of the arm. I know how to animate rotating wheels by using this expression which i apply on rotation property of the wheel.

d=width;
pi=Math.PI;
circ=d*pi;
rot=360/circ;
movex=thisComp.layer("sasija").transform.position[0];
scaler=thisComp.layer("sasija").transform.scale[0]/100;
rot*movex

So now I have to find solution how to animate truck rotation of some vehicle in my situation it's bulldozer but it can be tank or some other... Here is the picture, and also I need the best way to animate arm movement, so it imitate sand digging in most "natural" way.

Picture:

Buldozer 2.jpg
Buldozer 2.jpg (324.25 KiB) Viewed 3905 times

(This is sample picture of my 2D work that I need to animate. there is about 37 yellow triangles that represent bulldozer trucks. I need solution how to make them move (rotate) along the path and if possible how to write expression to avoid key-framing. I have created this picture in Illustrator and every single triangle is on separate layer)

Also if someone has ideas for how to animate sand movement during digging it would be great.

Thanks in advance.

Who is online

Users browsing this forum: No registered users and 3 guests