Page 1 of 1

Populating Comp A with 2 instances of Comp B

Posted: February 21st, 2014, 11:11 am
by peiter
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

Re: Populating Comp A with 2 instances of Comp B

Posted: February 22nd, 2014, 2:22 pm
by Dan Ebberts
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

Re: Populating Comp A with 2 instances of Comp B

Posted: February 24th, 2014, 10:39 am
by peiter
Thanks Dan!