Highlighted

Copying layer in to multiple compositions

New Here ,
Sep 06, 2020

Copy link to clipboard

Copied

Hi,

 

I'm trying to copy a background image layer in to multiple compositions without having to copy and paste to every composition.

 

I found the following code below...however I have very basic knowledge of javascript and I'm unsure how to apply this to the project.

 

for (i = 1; i<=app.project.numItems; i++){
if ((app.project.item(i).typeName=="Composition") && (i!=1)) app.project.item(1).layer(1).copyToComp(app.project.item(i));
}

 

I've tried running this on After Effects and I get the result:

 

Function app.project.item().layer is undefined

Are there specific things in the code I need to modify to make this work?

 

Thanks.

TOPICS
Expressions, How to, Scripting

Views

28

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Copying layer in to multiple compositions

New Here ,
Sep 06, 2020

Copy link to clipboard

Copied

Hi,

 

I'm trying to copy a background image layer in to multiple compositions without having to copy and paste to every composition.

 

I found the following code below...however I have very basic knowledge of javascript and I'm unsure how to apply this to the project.

 

for (i = 1; i<=app.project.numItems; i++){
if ((app.project.item(i).typeName=="Composition") && (i!=1)) app.project.item(1).layer(1).copyToComp(app.project.item(i));
}

 

I've tried running this on After Effects and I get the result:

 

Function app.project.item().layer is undefined

Are there specific things in the code I need to modify to make this work?

 

Thanks.

TOPICS
Expressions, How to, Scripting

Views

29

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 06, 2020 0
Mylenium LATEST
Most Valuable Participant ,
Sep 06, 2020

Copy link to clipboard

Copied

Well, the script has hard-wired indices for the first item in the project panel list and the first layer in that comp - assuming the first project item is evcen a comp. That's where things easily fall apart with no safeguards in place or checking e.g. for an active/ selected layer in your prototype comp. Or to put it in other words: This is the most basic, most dumb version of a script that will only ever work under the very limiuted conditions described, if at all. You need to find better code. Start by checking out tried & true scripts like True Comp Duplicator and other stuff you can find on AEScripts.com.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 06, 2020 0