Populating Comp A with 2 instances of Comp B

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
peiter
Posts: 2
Joined: February 21st, 2014, 10:43 am

Hello AENHANCERS!
My name is Peiter, im an After Effects fanatic and new to scripting.

My question is about compositions in my project library. If I have two comps, am I able to add one in the other?

My ultimate goal is to have a COMP.A populated with 2 instances of COMP.B.

Any help or links to past conversations would be awesome.

Peiter
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

This isn't optimal, but it should give you the idea:

Code: Select all

var compA = compB = null;
for (var i = 1; i <= app.project.numItems; i++){
	if (app.project.item(i) instanceof CompItem){
		if (app.project.item(i).name == "COMP.A")
			compA = app.project.item(i)
		else if (app.project.item(i).name == "COMP.B")
			compB = app.project.item(i);
	}
}

if (compA != null && compB != null){
	compA.layers.add(compB);
	compA.layers.add(compB);
}else
	alert("Can't find both comps.");

Dan
peiter
Posts: 2
Joined: February 21st, 2014, 10:43 am

Thanks Dan!
Post Reply