Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Extendscript – get name of comp which a layer is in?

  • Extendscript – get name of comp which a layer is in?

    Posted by Jeroen Rommelaars on September 24, 2019 at 3:24 pm

    Hey guys,

    Im trying to build something here, but im running into some issues.
    Im doing all kinds of for loops to find layers in my project – in the entire project. The layers I want to find are color coded, or locked, or shy for example.
    If one of those layers is found, i would like to get the name of the composition that layer was found in. Preferrably the sourcename of that comp, but a name would be a great starting point.

    Now most of the scripting goes from toplever down to layer level – like project, comp, layer – but in this case i would like to do it inside out, from layer, to comp, etc.

    Does anyone know a way to find the compname in which a layer is present through extendscript?

    Any help is much appreciated!

    Thanks!

    //this looks for darkgreen labeled layers - but now i need the compnames of the comps that have those layers in them
    function greenCheckFunction() {

    for (var h = 1; h <= app.project.numItems; h++)
    if (app.project.item(h) instanceof CompItem)
    for (var i = app.project.item(h).numLayers; i > 0; i--) {
    if (app.project.item(h).layer(i).label == 16) {
    exclusionArray.push(app.project.item(h).layer(i).name)
    }
    }
    }

    Jeroen Rommelaars replied 6 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 24, 2019 at 4:32 pm

    YourLayer.containingComp will give the comp that the layer is in, but I don’t understand how you get to the layer without already knowing the comp.

    Dan

  • Jeroen Rommelaars

    September 24, 2019 at 4:55 pm

    Ooh, im gonna try that first thing in the morning.

    I get the layer in a for loop, linked in the above post. The loop just runs. I could probably extract the index number of the comp for a specific layer from that loop, but i need the comp name. Ofcourse…now that you mention it…i probably couldve gotten the index number, and then simply check the name for said index number. Hmmmmm

    Although i like your approach better ☺
    Thanks!

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