Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects add a definied comp in another comp with javascript

  • add a definied comp in another comp with javascript

    Posted by Phil Largilliere on April 11, 2016 at 9:27 am

    Hi every one

    I wrote a script where I create a new comp, then I want to import a definied comp in this new one, but I can’t find the way to do this.

    myProject = app.project;
    myProject.items.addComp("surComp",1920,1080,1,15,25);

    var myComp = new Array();
    for (i=1; i <= myProject.numItems; i++)
    {
    if (myProject.item(i).name == "Comp 1")
    { myCompNum = i - 1;
    }
    }

    for (i=1; i <= myProject.numItems; i++)
    {
    if (myProject.item(i).name == "surComp")
    {
    myProject.item(i).openInViewer();
    //Add "Comp 1" as layer in this new Comp ???
    }
    }

    Can you help me ??

    Thank you so much
    PH…

    Phil Largilliere replied 10 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Walter Soyka

    April 11, 2016 at 10:13 am

    You use the .add() method of a LayerCollection:

    myProject = app.project;
    surComp = myProject.items.addComp("surComp",1920,1080,1,15,25);

    var myComp = new Array();
    for (i=1; i <= myProject.numItems; i++)
    {
    if (myProject.item(i).name == "Comp 1")
    { comp1 = myProject.item(i);
    }
    }

    surComp.openInViewer();
    comp1Layer = surComp.layers.add(comp1);

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

  • Phil Largilliere

    April 11, 2016 at 10:32 am

    Thank you !!

    it works perfectly well !! I use to write this code, but I don’t know why it doesn’t work. Thanks again 😉

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy