Recursive checking pre-comps for missing footage

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

As i am getting more and more comfortable with scripting i sometime hit some walls that i have a hard time getting around.

I am trying to write a simple function that check for missing footage in a particular comp. It's pretty straight forward as long as the missing item is in that parent comp. The way i am accomplishing this is by doing a for loop in the project window using footageMissing and then using usedIn to check whether that missing footage is in my comp.

The problem is if the footage is in a pre-comp that is then in my parent comp. I can write another for loop to go in 1 more comp up, but pre-comps could be infinately deep so i am stuck figuring out how to keep recursively checking until i find the top-most comp. My guess is that this can be done more efficiently than the way i am approaching it..

any help will be greatly appreciated..

to clarify what i am looking to do: I want to check whether a comp has any missing footage in it. This missing footage could be located within a pre-comp that is in this comp.. That is what i am having trouble with.


this is what i have so far:

Code: Select all

var projItems = app.project.items;
	var missingItems = 0;
	var missingFootageArray = new Array();
	for (j=1; j < projItems.length; j++){
			if (projItems[j].footageMissing == true) {
			missingItems = missingItems + 1;
			if (projItems[j].usedIn.length > 0){
				var compsUsedIn = projItems[j].usedIn;
					if (compsUsedIn.length > 0) {
					var compsUsedInNames = new Array();
					for (k=0; k < compsUsedIn.length; k++){	
					compsUsedInNames[k] = compsUsedIn[k].name;
				}
  			}		
				missingFootageArray[missingFootageArray.length] = String(projItems[j].name) + " Used In: " + String(compsUsedInNames) + "\r";
				}
		}
	}
	
alert(missingFootageArray);
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

Hi lloyd,

I would suggest to first retrieve the selected comp in a variable and check recursively for missing footage in its layers (rather than beginnig with a missing footage).
To use a recursive function simply call it in its own definition.
Take look at this one http://www.nabscripts.com/Forum/Scripts ... InComp.jsx, this script finds missing footages in the selected comp and removes them.
Should be a "good" example for your own script.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

awesome!

that's exactly what i was looking for..

Thanks alot nab..

-Lloyd
Post Reply