Skip to main content
Participating Frequently
November 4, 2016
Answered

Copy layer to another composition

  • November 4, 2016
  • 3 replies
  • 8022 views

Hi all,

I am trying to import a specific layer from one AE project to another.

I am able to import AE project and find a composition and add it to where I want with:

myComp.layers.add(app.project.item(c).item(e));

But how can i go one level down and target specific layer? I tried:

myComp.layers.add(app.project.item(c).item(e).layer(1));

But i get an error: "[object AVLayer] is not of the correct type".

Thanks for your help,

Martin

This topic has been closed for replies.
Correct answer UQg

You can use layer.copyToComp(whichComp):

app.project.item(c).item(e).layer(1).copyToComp(myComp);

The above line evaluates to undefined, ie copyToComp returns nothing.

The created layer is first in myComp layers stack: that's how you retrieve it afterwards.

Xavier

3 replies

blackburn.49963592
Inspiring
August 8, 2019

I need to copy layer too, but I never used code in adobe.

Can someone tell where should I paste this code?

app.project.item(c).item(e).layer(1).copyToComp(myComp);

Alex White
Legend
November 4, 2016

You can use:

app.project.item(index).layer(index).copyToComp(intoComp)

Description

Copies the layer into the specified composition. The original layer remains unchanged. Creates a new Layer

object with the same values as this one, and prepends the new object to the layers collection in the target

CompItem. Retrieve the copy using intoComp.layer(1).

Copying in a layer changes the index positions of previously existing layers in the target composition. This is

the same as copying and pasting a layer through the user interface.

Parameters

intoCompThe target composition, and CompItem object.

ok, Xavier got ahead

UQg
UQgCorrect answer
Legend
November 4, 2016

You can use layer.copyToComp(whichComp):

app.project.item(c).item(e).layer(1).copyToComp(myComp);

The above line evaluates to undefined, ie copyToComp returns nothing.

The created layer is first in myComp layers stack: that's how you retrieve it afterwards.

Xavier

vigi42Author
Participating Frequently
November 4, 2016

Works perfectly.

Thank you