add a comp to a comp?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
peteoconnell
Posts: 19
Joined: November 14th, 2004, 2:10 pm

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
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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;
		}
	}
}
peteoconnell
Posts: 19
Joined: November 14th, 2004, 2:10 pm

Thanks, that's a pretty efficient way of doing it.
Much obliged
Pete
Post Reply