Add a Comp and the add a Camera in

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
DhAoS
Posts: 6
Joined: May 21st, 2007, 3:13 am

Hello

I'm trying to create a script that add a new comp in a project an then add a camera in.

it's somethinf like this

Code: Select all

var newComp;

        newComp = app.project.items.addComp("BlendComp", 720, 576, 1.070000, 4.800000, 25);

var newCamera;
		
		newCamera = app.project.XXX.layers.addCamera("BlendCamera",[360.0,243.0]);
Obviously instead of "XXX" it has to call the new comp, but her it's the the problem: I don't know how to do! According to the script Guide to call a specific comp I have to do something like this

Code: Select all

app.project.item().name("BlendComp").layers.addCamera("BlendCamera",[360.0,243.0]);
However doesn't work!

Anyone here have the solution, please?

Thank you in advance

PS I'm on After Effects 7.0 Win Xp
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Here's how you'd write it:

Code: Select all

var newComp = app.project.items.addComp("BlendComp", 720, 576, 1.070000, 4.800000, 25); 
var newCamera = newComp.layers.addCamera("BlendCamera",[360.0,243.0]);
After creating the new comp, "newComp" contains a Comp Item object, the equivalent of app.project.item, which is why you can miss that out in the second line and start from "newComp" instead.

Here are two examples of how you might write it if you hadn't already defined the comp. The first line will add a camera to the first item in the Project window (assuming it's a comp). The second line will add a camera to the currently active comp (assuming a comp is active).

Code: Select all

var newCamera = app.project.item(1).layers.addCamera("BlendCamera",[360.0,243.0]);
var newCamera = app.project.activeItem.layers.addCamera("BlendCamera",[360.0,243.0]);
DhAoS
Posts: 6
Joined: May 21st, 2007, 3:13 am

:oops: Ok shame on me, it was a simple syntax error! now everyone knows that I'm an Ae scripts newbie! :D
However a big thanks to you!
Post Reply