-
Find the Master Composition from a precomp ( Extendscript )
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