Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Runing a function in nested comps in AE

  • Runing a function in nested comps in AE

    Posted by Mateo Mazzini on April 23, 2018 at 4:09 am

    Hi! I am trying to create a function which extends the outpoint of every layer in a comp.
    I need the function to detect when the layer is a precomp, enter it, and run again inside of it.
    so far, if I call the function within itself I create a loop which hangs AE.
    Any ideas on how to approach this?

    (Check line 23 ==> extendOut(activeSubC.layer(u).source) <== this is where I am crashing AE. this is not working… if you delete this line, the script works just fine for the first selected layers and it’s firsts precomps. but not for precomps inside those.

    thanks!

    app.beginUndoGroup(“extendOut”);

    //DEFINING GENERAL VARIABLES

    var activeC = app.project.activeItem;
    var activeSel = activeC.selectedLayers;

    //THE FUNCTION THAT RUNS INSIDE EVERY PRECOMP SELECTED.
    function extendOut(compToExtend){
    var activeCItems=compToExtend.numLayers;
    var activeSubC=compToExtend;
    for(u=1;u<=activeCItems;u++){
    //DEFINE THE VARIABLES FOR THE SCRIPT
    var currentSubLayer=activeSubC.layer(u);
    var inSubLay=currentSubLayer.inPoint;
    var activeSubCDuration=activeSubC.duration;

    // EXTENDING A PRECOMP
    if(activeSubC.layer(u).source instanceof CompItem){
    currentSubLayer.source.duration=activeSubCDuration-inSubLay;
    currentSubLayer.outPoint=activeSubCDuration;
    extendOut(activeSubC.layer(u).source)
    };

    // EXTENDING A VIDEO LAYER
    if(currentSubLayer.canSetTimeRemapEnabled==true && currentSubLayer.source.hasVideo==true){
    currentSubLayer.timeRemapEnabled=true;
    currentSubLayer.outPoint=activeSubCDuration;
    };

    //EXTENDING EVERYTHING ELSE

    else{
    currentSubLayer.outPoint=activeCDuration;
    }
    };
    };

    //RUN THE SCRIPT FOR THE FIRST TIME ONLY FOR SELECTED LAYERS

    for(i=0;i

    Mateo Mazzini replied 8 years ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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