ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Auto align layers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jacob Thorup
Auto align layers
on Apr 19, 2019 at 8:07:06 pm

Hi everyone.

I might just not know the right phrasing to search, in order to find an answer to this question, my apologies in advance if this has already been answered.

I'm wanting to automate the alignment of one layer according to the length of another layer.
Here is my scenario;
I am using Comps from Spreadsheets (An AE plugin that automatically generates comps based on a template and a spreadsheet) to combine assets and generate 180 videos for me.

I have 2 video clips that vary in length, one is the opening segment, the second is the main program.
Comps from spreadsheets is great at swapping out assets at a specific time index on your timeline, but because my clips vary in length I am trying to figure out a way to have the clips/layers automatically align according to the length of another layer. Something like

Layer 2 overlap last 30 frames of layer 1.

Any help would be appreciated.

Return to posts index

Dan Ebberts
Re: Auto align layers
on Apr 19, 2019 at 8:41:44 pm

You'd have to do that with a script that you run after your spreadsheet script is done. As far as scripts go, it would be a pretty simple one, but the details would depend on the layout of your comp and the names (or indices) of the relevant layers.


Return to posts index

Jacob Thorup
Re: Auto align layers
on Apr 22, 2019 at 6:40:16 pm

Thanks for your reply. I decided to buckle down and try to learn how to create my own script and it worked!!!

I've always avoided really learning to make a custom script, but this is really going to open up what I can do!

Just for kicks, here is the script I wrote.

This is going to save me 16+ hours, per market, of editing on a 180 episode series, where we have to change out sponsorship for different markets

Thanks for the nudge.


//Comp Layers
var theComp = app.project.activeItem;
var logo = theComp.layer(1)
var word = theComp.layer(2);
var logoAnimate = theComp.layer(3);
var head = theComp.layer(4);
var endCard = theComp.layer(5);
var body = theComp.layer(6);
var bg = theComp.layer(7);

//Script Functions
function logoAlign(){
(logoAnimate.startTime = head.outPoint - 1); //align the animation

function bodyAlign(){
(body.startTime = logoAnimate.outPoint - 1); //align the body

function endCardAlign(){
(endCard.startTime = body.outPoint - 1); //align the end card
function fades(){

//Logo Animation fade up and down
(logoAnimate.opacity.setValueAtTime (logoAnimate.outPoint - 1,100));
(logoAnimate.opacity.setValueAtTime (logoAnimate.outPoint ,0));
(logoAnimate.opacity.setValueAtTime (logoAnimate.startTime + 1,100));
(logoAnimate.opacity.setValueAtTime (logoAnimate.startTime ,0));

//End Card fade up.
(endCard.opacity.setValueAtTime (endCard.startTime + 1,100));
(endCard.opacity.setValueAtTime (endCard.startTime ,0));

//Logo fade Up and Down.
(logo.opacity.setValueAtTime (head.outPoint - 1,100));
(logo.opacity.setValueAtTime (head.outPoint ,0));
(logo.opacity.setValueAtTime (body.startTime + 1,100));
(logo.opacity.setValueAtTime (body.startTime ,0));
(logo.opacity.setValueAtTime (body.outPoint - 1,100));
(logo.opacity.setValueAtTime (body.outPoint ,0));

//Word fade Up and Down.
(word.opacity.setValueAtTime (head.startTime + 3,0));
(word.opacity.setValueAtTime (head.startTime + 3.5 ,100));
(word.opacity.setValueAtTime (head.outPoint - 1,100));
(word.opacity.setValueAtTime (head.outPoint ,0));
(word.opacity.setValueAtTime (body.startTime + 1,100));
(word.opacity.setValueAtTime (body.startTime ,0));
(word.opacity.setValueAtTime (body.outPoint - 1,100));
(word.opacity.setValueAtTime (body.outPoint ,0));

//Script Execution
head.startTime = 0

bg.startTime = 0

word.startTime = 0

logoAlign ()

bodyAlign ()

endCardAlign ()

fades ()

theComp.duration = body.outPoint + 15

Return to posts index

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