Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Script to remove everything from a Comp except light layers..not working!

  • Script to remove everything from a Comp except light layers..not working!

    Posted by Satya Meka on October 29, 2009 at 4:54 am

    Hello I am writing a basic script to remove all the layers except lights. But sometimes it works and sometimes it doesn’t and usually a camera/solid is left behind. Here is the script. Thanks in advance.

    app.beginUndoGroup("Trial");
    var srcComp = app.project.activeItem;

    if (srcComp == null || !(srcComp instanceof CompItem)){
    alert("Please select an active Composition and run again");
    } else{
    var lightComp = srcComp.duplicate();
    for (i=1;i<=lightComp.numLayers;i++) {
    var curLayer = lightComp.layer(i)
    if ((curLayer.property("intensity") == null) || (curLayer instanceof CameraLayer) || (curLayer instanceof AVLayer)) { curLayer.remove(); }else{
    alert("Yes!");
    };
    };
    };

    Satya Meka,
    https://www.gutsblow.com

    Satya Meka replied 16 years, 9 months ago 1 Member · 1 Reply
  • 1 Reply
  • Satya Meka

    October 29, 2009 at 5:53 am

    Ok I figured the problem, I forgot that Collection Object lists change when we remove layers from it. So Never mind 🙂

    Satya Meka,
    https://www.gutsblow.com

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