Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions List all layers inside a selected composition

  • List all layers inside a selected composition

    Posted by Kiril Gerenov on January 13, 2015 at 11:39 am

    Hi,
    I’ve been searching for this and I still can’t find a solution.
    I am trying to get a list of the layers inside a selected composition layer

    var curItem = app.project.activeItem;
    var selectedLayers = curItem['selectedLayers'];
    var curLayer = curItem.selectedLayers[0];//curLayer is a composition layer

    var layersInside = curLayer.layers;//this one doesn't work and doesn't get the layers inside the composition layer

    Any ideas?

    Thx

    Kiril

    Kiril Gerenov replied 11 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    January 13, 2015 at 3:26 pm

    Even if a layer is a precomp, it doesnt have a “layers” property.
    You should use layer.source to get to its source.
    If the layer is a precomp, then layer.source should be a CompItem:

    var curItem = app.project.activeItem;
    var selectedLayers = curItem.selectedLayers;
    var curLayer = curItem.selectedLayers[0];
    var layersInside = curLayer.source.layers;

    Care: this will be valid only if currLayer is a precomp.

    Xavier

  • Kiril Gerenov

    January 13, 2015 at 3:34 pm

    Thank you, Xavier!
    That worked great!

    Kiril

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