ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Find the Master Composition from a precomp ( Extendscript )

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
James Ronan
Find the Master Composition from a precomp ( Extendscript )
on Jul 5, 2017 at 10:21:57 pm

Hey guys

I've written a function that will loop through all layers of an active comp, find any precomps, and loop through all those layers inside until there are none left.

This is great if the active comp is the 'Master Composition'. but if the function is executed inside a precomp it will only loop through the precomps within it.

My question is: Is there a way that you can find what the master composition is from inside a precomp by looping upwards / backwards? Or another way?


precompSearchFunction(app.project.activeItem);

function precompSearchFunction(a){

for(var i = 1; i <= a.layers.length; i++){ // Loops through all the layers active composition.
if(a.layer(i).source instanceof CompItem){ // If layer source is an instance of a comp Item (precomp)
//more code here
precompSearchFunction(a.layer(i).source); // same function to search within precomps with in it.
} else { // If it's not a comp item.
return;
}

}// End of Function

};


Any help much appreciated!

Thanks


Return to posts index

Dan Ebberts
Re: Find the Master Composition from a precomp ( Extendscript )
on Jul 5, 2017 at 10:32:25 pm

Check out the "usedIn" attribute. It returns an array of comps that use the item.

Dan



Return to posts index

James Ronan
Re: Find the Master Composition from a precomp ( Extendscript )
on Jul 6, 2017 at 3:27:20 pm

Amazing!

That was just what I was looking for. Thanks, Dan!


Return to posts index

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