Copy link to clipboard
Copied
Hello all,
I'd like to automate part of the script where I create 3 promo comps.
I'll connect script with spreadsheet file and I want to control quantity of promo comps through spreadsheet.
I also need to name them and attach them to variable so I could easily access them later.
This is the old version where I hard coded 3 promo comps (and later also precomps and all other stuff)
and put them in array so I can easy acces them via loop counters:
var promo1 = app.project.items.addComp("Promo1", 1920, 1080, 1.00, 25, 25);
var promo2 = app.project.items.addComp("Promo2", 1920, 1080, 1.00, 25, 25);
var promo3 = app.project.items.addComp("Promo3", 1920, 1080, 1.00, 25, 25);
var arrPromo = [promo1, promo2, promo3];
var promo1precomp = app.project.items.addComp("Promo1precomp", 1920, 1080, 1.00, 25, 25);
var promo2precomp = app.project.items.addComp("Promo2precomp", 1920, 1080, 1.00, 25, 25);
var promo3precomp = app.project.items.addComp("Promo3precomp", 1920, 1080, 1.00, 25, 25);
var arrPromoPrecomp = [promo1precomp, promo2precomp, promo3precomp];
This is the code I've been playing with, it's wrong but you can get the idea
(at the moment I just put prompt to define number of promos, later I'll connect this to spreadsheet):
var total = parseFloat(prompt("Number of promos:", 3));
var arrPromo =new Array();
var arrPromoPrecomp = new Array();
var arrPromoNames = new Array();
for (var i = 0; i < total; i++) {
var arrPromoNames = "Promo"+i;
}
for (var i = 0; i < total; i++) {
var arrPromoPrecomp = app.project.items.addComp(arrPromoNames, 1920, 1080, 1.00, 25, 25);
}
Thanks.
I just noticed I had stupid mistake.
I repeated var in for-loop and my array was already defined before.
Copy link to clipboard
Copied
I just noticed I had stupid mistake.
I repeated var in for-loop and my array was already defined before.