ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Scripting iterative changes

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Owen Silverwood
Scripting iterative changes
on Jan 20, 2020 at 12:16:03 am

Hi everyone, I'm new to scripting and feel like I might have bitten off a big chunk for my first attempt, but necessity is the mother of invention right?

My goal is relatively simple really:
- duplicate the comp
- transform the position of a layer in duplicate comp
- send current frame to render queue
** duplicate the duplicated comp** and continue the process for x number of iterations.

I have been working with 'curVal+x' variables to get my cumulative transforms working, but I just cant get my 'activeItem' to step down onto the duplicate comp OR find a way to loop the entire process for a specified number of iterations.

I fear I might not even be using language that makes sense in the context of AE scritping, I'm really that new to it. But hopefully someone can point me in the right direction...

Thanks! Such a great community. Long time lurker here since about 2006 I think.

Return to posts index

Dan Ebberts
Re: Scripting iterative changes
on Jan 20, 2020 at 1:15:31 am

I'd probably structure it something like this:

var numDups = 10;
var myPosOffset = [50,50];
var myComp = app.project.activeItem;
var myDupComp;
var myDupLayer;
var myPos;
for (var i = 1; i <= numDups; i++){
myDupComp = myComp.duplicate();
myDupLayer = myDupComp.layer(1);
myPos ="Position").value;"Position").setValue([myPos[0]+myPosOffset[0],myPos[1]+myPosOffset[1]]);
// do render stuff
myComp = myDupComp;


Return to posts index

Owen Silverwood
Re: Scripting iterative changes
on Jan 20, 2020 at 11:23:57 am

Dan, thank you so much. I hadn't anticipated someone literally translating what I'd said and posting it for me. Thats very kind of you.

It works exactly as I hoped, and I can pretty much wrap my head around why, which is just as important.

As soon as I can get the additional render commands working, I'll be on my way.

Thanks again. Hopefully useful for someone else at some point too.

PS: For the record, in case it's useful in the future: This was specifically required for the rendering of moving slitscan images, where the relationship between time and position is somewhat changed, meaning that regular keyframes and expressions couldn't achieve the intended result.

Return to posts index

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