import a AVItem into a comp

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
ndeboar
Posts: 8
Joined: April 17th, 2005, 8:39 pm

Hey,

Im sure this will be a simply one to answer. How do you import a AVItem into a comp? Ive been playing with:

app.project.item(index).lcoll.add(item, duration)

But it always returns an error. Is the item index supposed to represent the Comp, and the item the avitem i want? If so, it still doesnt work. And im calling my comp by name, i have no idea what it's index is.

Any ideas? Thanks for all the help latley, ill post my script when its done!

Cheers,

Nick
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Have a look at the script I put in this topic: http://www.aenhancers.com/viewtopic.php?t=235
Specifically the line: precompLayer = slateComp.layers.add(currentComp);

If you've already created/found the comp object you want to place the layer into, and stored it in a variable, you can access it in the way I have above with slateComp.layers.add().

Explaining item(index):
app.project.items represents everything in the project window. app.project.item(1) represents the first thing in the project window. So this a way to access a single item from the project window, with each item automatically assigned an index, starting from 1, going from top to bottom.

There are lots of other ways to access a comp, you could use app.project.activeItem to access the currently selected comp. Or you could create a loop to go through all the items in the project, checking if they're instances of a CompItem and are .selected or have a particular name.

Explaining lcoll:
I'm not sure but I think this is just shorthand in the scripting guide for the Layer Collection and shouldn't actually be written as such, the proper word to use in AE scripting is layers. But in plain english it means 'the collection of layers in a comp', as in, you are trying to add your AV item to the collection of layers in a comp.

Finally add(item, duration);
You would replace item with the variable or app.project.item(index) or whatever, that represents the AV item you wish to add to the comp (in my example script it's the variable 'currentComp' which represents a CompItem), and duration is an optional value used to choose the duration if the AV item is a solid/still layer (otherwise it defaults to length of comp).

Hope that helps.

Paul T
Post Reply