Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects ExtendScript: find layers that are NOT selected

  • ExtendScript: find layers that are NOT selected

    Posted by Eugene Boitsov on February 10, 2019 at 12:02 am

    Hi there,

    CompItem.selectedLayers attribute allows me to keep all selected layers in the Array.
    But how can I get an Array of layers that are not selected layers (the rest, basically)?

    Thanx in advance,
    Eugene

    Walter Soyka replied 7 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Walter Soyka

    February 10, 2019 at 2:39 am

    Step through all the layers in the comp, check to see if they’re unselected, and create your own array of unselected layers.

    This code ought to do it:

    function getUnselectedLayers(comp) {
    if (comp instanceof CompItem) {
    var unselectedLayers = [];
    for (var compLayerIndex = 1; compLayerIndex < comp.numLayers; compLayerIndex++) {
    if (comp.layer(compLayerIndex).selected == false) unselectedLayers.push(comp.layer(compLayerIndex));
    }
    return unselectedLayers;
    } else {
    return null;
    }
    }

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

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