Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions referencing a comp by it’s name in a script

  • referencing a comp by it’s name in a script

    Posted by Alexis Martinez on July 16, 2008 at 3:26 pm

    Hello,

    First, sorry for my bad english, I read it but writing it is much more difficult 😉
    I’m writing a script, and I know how to refer to a comp using proj.item(), but I want to use it’s name, not it’s “position” in the Project panel.
    I’ve tried “comp.(“comp’s name)”.layer(“layer’s name”)….”, but it doesn’t work, because it’s a script, not an expression.
    I’ve searched on internet, books, … but no solution.
    Can someone help me ?
    Thanks a lot :-),

    _____
    Couad

    Alexis Martinez replied 18 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    July 16, 2008 at 4:28 pm

    Unfortunately, you have to loop through the project bin looking for it, like this:

    var myCompName = “your comp name”;
    var myProject = app.project;
    var myComp = null;

    for (var i = 1; i <= myProject.numItems; i++){ if ((myProject.item(i).name == myCompName) && (myProject.item(i) instanceof CompItem)){ myComp = myProject.item(i); break; } } If (myComp == null){ alert("Comp " + myCompName + " not found!"); } Dan

  • Alexis Martinez

    July 16, 2008 at 7:40 pm

    I’m surprised there isn’t a more simple solution to refer to a comp by its name, but it works perfectly Dan.
    Thanks 😉

    _____
    Couad

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