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


James Ronan
Re: Find the Master Composition from a precomp ( Extendscript )
on Oct 2, 2017 at 2:33:48 pm

Hey Dan,

Thanks again for your previous help, alas I've another question relating to the usedIn attribute ...

Using the attribute creates an array of what compositions an object is used in, but can it show you what the layer index is, of that item in that composition?

E.g. if I right click on an item in the Project panel, and click "Reveal in Composition", it will show me the composition, the layer index, and the name of the layer.

Specifically, I'm looking for its index in that composition. So is the usedIn attribute still the way to go, or is there something else that could work?

Thanks!

James


Return to posts index

Dan Ebberts
Re: Find the Master Composition from a precomp ( Extendscript )
on Oct 2, 2017 at 10:52:49 pm

I can't think of anything better than looping through the usedIn comp layers, looking for AVLayers with a CompItem source where the id attribute of the source comp matches the id of comp you're searching for.

Dan



Return to posts index

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