Page 1 of 1

I need a script to add one frame to a comp

Posted: July 6th, 2005, 4:58 pm
by scribling
Here's the deal.
A lot of people build their shots at frame 1.
When we need to add a slate we need it at frame 0.
So, I need a script that would take selected comps from the project window, add one frame to them and slide all layers over so that they start at frame 1.
That way we can paste the slate in at frame 0.

What do you think? Can it be done?

Posted: July 17th, 2005, 5:49 am
by Paul Tuersley
Here's a script that places each of the selected comps into another that is one frame longer (and has (S)late tagged on the name), moving the precomp layer so it starts on the 2nd frame. I thought it was safer to do it this way, rather than moving all the layers in the original comp.

It'd be pretty easy to get it to add the slate frame too, and perhaps even to fill in the slate information. (I've created a script like this at our visual effects house that completely automates the whole process of setting up a shot for render.)

Paul T

Code: Select all

{

	// create an array of selected comps
	var selectedComps = new Array();

	for (var i = 1; i <= app.project.items.length; ++i) {
		if (app.project.items[i] instanceof CompItem && app.project.items[i].selected) {
			selectedComps[selectedComps.length] = app.project.items[i];
		}
	}


	// for each of the selected comps
	for (var i = 0; i < selectedComps.length; ++i) {

		// create new comp, make it one frame longer and add S to it's name
		currentComp = selectedComps[i];
		slateCompName = currentComp.name + " S"
		slateCompDuration = currentComp.duration + (currentComp.frameDuration * 0.99);
		slateComp = app.project.items.addComp(slateCompName, currentComp.width, currentComp.height, currentComp.pixelAspect, slateCompDuration, currentComp.frameRate);

		// add orignal comp and move the layer to start on the 2nd frame.
		precompLayer = slateComp.layers.add(currentComp);
		precompLayer.startTime = currentComp.frameDuration
	}

}

Thanks!

Posted: July 18th, 2005, 3:05 pm
by scribling
Yea, you are right it's safer to precomp it and leave it alone. Who knows what could happen otherwise. The only thing is that the slate we're using places the comp name in the slate. So now it's got the extra "S" ... you know some places they go nuts if a slate isn't exactly right, even if not a single person would be confused.

What did the whole setup render script do that you wrote and use? Maybe I could use some of it.

Thanks

Posted: July 18th, 2005, 3:16 pm
by Paul Tuersley
It'd be pretty easy to modify the script so it changes the original currentComp.name (i.e adding P for precomp) instead of the new comp, let me know if you need any help with that.

Paul T