• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamically create and name comps

Community Beginner ,
Dec 04, 2018 Dec 04, 2018

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.

TOPICS
Scripting

Views

283

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Dec 06, 2018 Dec 06, 2018

I just noticed I had stupid mistake.

I repeated var in for-loop and my array was already defined before.

Votes

Translate

Translate
Community Beginner ,
Dec 06, 2018 Dec 06, 2018

Copy link to clipboard

Copied

LATEST

I just noticed I had stupid mistake.

I repeated var in for-loop and my array was already defined before.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines