ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Runing a function in nested comps in AE

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mateo Mazzini
Runing a function in nested comps in AE
on Apr 23, 2018 at 4:09:40 am
Last Edited By Mateo Mazzini on Apr 23, 2018 at 4:16:17 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 //DEFINE THE VARIABLES FOR THE SCRIPT
var currentLayer=activeC.selectedLayers[i];
var inLay=currentLayer.inPoint;
var activeCDuration=activeC.duration;

// EXTENDING A PRECOMP
if(activeC.selectedLayers[i].source instanceof CompItem){
var newDuration=activeCDuration-inLay;
currentLayer.source.duration=newDuration;
currentLayer.outPoint=activeCDuration;
extendOut(activeC.selectedLayers[i].source)
};

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

//EXTENDING EVERYTHING ELSE

else{
currentLayer.outPoint=activeCDuration;
}
};

Matz


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]