Page 1 of 1

add a comp to a comp?

Posted: May 22nd, 2009, 9:17 am
by peteoconnell
Hi, I am not sure if this is a really obvious one but what I am trying to do is place a comp within another comp. In the AE interface this would be that same as dropping a comp onto the comp icon at the bottom of the project panel.
Thanks
Pete

Re: add a comp to a comp?

Posted: May 23rd, 2009, 4:11 am
by Paul Tuersley
Here's an example that finds the first selected comp in the project panel, creates a new comp with the same settings, and drops the original comp into it.

Code: Select all

{
	for (x=1; x <= app.project.items.length; x++) {
		if (app.project.item(x) instanceof CompItem && app.project.item(x).selected == true) {
			origComp = app.project.item(x);
			newComp = app.project.items.addComp(origComp.name + "*", origComp.width, origComp.height, origComp.pixelAspect, origComp.duration, origComp.frameRate);
			newComp.layers.add(origComp);
			break;
		}
	}
}

Re: add a comp to a comp?

Posted: May 23rd, 2009, 9:54 am
by peteoconnell
Thanks, that's a pretty efficient way of doing it.
Much obliged
Pete