FORUMS: list search recent posts

Replacing layers with comps Script

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Igor Stikic
Replacing layers with comps Script
on Jan 5, 2016 at 12:47:22 pm

Hi,

i need to frequently change 100+ layers in several comps with compositions. (Alt + Hold and move is to slow)The Layers and the comps are the same name but I can't figure out how to wright that script. I create simple project with 6 items to replace for example. So please help me out.

If you look in screenshot I need in Comp "Portfolio 1080p" to replace Layers "Photo 1", "Photo 2"... with Comps marked with red. Problem is that "Photo 5" and "Photo 6" are in different comps, and "Photo 1" repeat it self.

Thank you in advance!



var projectItems = app.project.items;
var i = 1;
var j = 1;
var x = 1;
var str= '';
for(i=1; i &lt; projectItems.length; i++){
var item = projectItems[i].name;
if(item.name == "Portfolio 1080p"){
alert(1);
for(j=1; j &lt;= 7; j++){
var newItem = null;
if(item.layer(j).name != "5 Folio"){
if(item.layer(j).name != "6 Folio"){
alert(2);
for(x =1; x &lt; projectItems.length; x++){
if(item.layer(j).name == projectItems[x].name){
alert(3);
newItem = projectItems[x];
item.replaceSource(newItem, false);
}
}
}
}
}
}
}


Igor Stikic


Return to posts index


Dan Ebberts
Re: Replacing layers with comps Script
on Jan 5, 2016 at 6:33:35 pm

I think I'd do it like this:


function getComp(theName){
for (var i = 1; i <= app.project.numItems; i++){
if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name == theName)){
return app.project.item(i);
}
}
return null;
}

function main(){
var myComp = getComp("Portfolio 1080p");
if (myComp == null){
alert ("Can't find comp 'Portfolio 1080p'");
return;
}
var photoComp;
var photoCompName;
for (var i = 1; i <= myComp.numLayers; i++){
photoCompName = myComp.layer(i).name.split(".")[0];
photoComp = getComp(photoCompName);
if (photoComp == null){
alert ("Can't find comp '" + photoCompName + "'");
return;
}
myComp.layer(i).replaceSource(photoComp,false);
}
}

main();



Dan



Return to posts index

Igor Stikic
Re: Replacing layers with comps Script
on Jan 6, 2016 at 10:21:34 am

Thank you very very much!

Igor Stikic


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]