FORUMS: list search recent posts

Problem wit for loop in Extendscript

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Riaan Myburgh
Problem wit for loop in Extendscript
on Sep 5, 2017 at 1:07:10 pm

Hi,
I am very new to extendscript/javascript and realise theres probably an easy solution here.
My objective is to be able to import footage into AE, then run a script that counts the number of files available, and creates a corresponding comp from each footage file.(each ones specific parameters), and then to place the file inside the comp .

Here is the code


var proj = app.project ;

var newCompsToMake = proj.numItems;


app.beginUndoGroup("Add5Comps");
for (var i = 1; i <= newCompsToMake; i++){
proj.item(i).width


var newCompWidth = proj.item(i).width;
var newCompNames = proj.item(i).name;
var newCompHeight = proj.item(i).height;
var newCompPAR = proj.item(i).pixelAspect;
var newCompDur = proj.item(i).duration;
var newCompFPS = proj.item(i).frameRate;

proj.items.addComp(newCompNames, newCompWidth, newCompHeight, newCompPAR, newCompDur, newCompFPS);


};
app.endUndoGroup();


So in typing this I realise the problem is that each time a new comp is created it replaces the previous index, thus all the comps are being made from the same footage file.
Any ideas on how to remedy this are welcome!


Return to posts index

Walter Soyka
Re: Problem wit for loop in Extendscript
on Sep 6, 2017 at 1:07:47 pm

Instead of looping through every item in the project and creating comps in the same loop, split this into two loops. The first loop should step through every item in the project, building an array of footage objects to be processed. The second loop should step through the array you just built.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

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