Quantcast
Channel: Adobe Community : Discussion List - After Effects Scripting
Viewing all articles
Browse latest Browse all 2143

Dynamically create and name comps

$
0
0

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[i] = "Promo"+i;

    }

for (var i = 0; i < total; i++) {

    var arrPromoPrecomp[i] = app.project.items.addComp(arrPromoNames[i], 1920, 1080, 1.00, 25, 25);

    }

 

 

Thanks.


Viewing all articles
Browse latest Browse all 2143

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>