-
Find and Replace the item from bin to comp.
Hello,
I’m trying to replaceSource of a layer from the project bin/root to the Active Comp of particular Layer, also the position of the replaced layer has to match the position of the exisiting layer.
I did happen to come up with a script that happened to be having lots of errors.Can you guys help me with this to figure out to achieve this, please…..
Attaching a screenshot reference

function getItem(theName){
for (var i =1; i <= app.project.numItems; i++){
if ((app.project.item(i)) && (app.project.item(i).name == theName)){
return app.project.item(i);
}
}
return null;
}function replaceFile(){
var myComp = app.project.activeItem;
var myItems = myItem;
var myLayers = myComp.layer('blue.png');
myItem.layer('blue.png').property("Position").setValue([positionValues[0],positionValues[1],positionValues[2]]);
if (myLayers.length == myItems.length){
for (var i = 0; i < myLayers.length; i++){
myLayers[i].replaceSource(myItems[i],false);
}
}else{
alert("Number of selected layers and bin items does't match.");
}var itemName = "pink.png";
var myItem = getItem(itemName);
// alert(itemName + (myComp == null ? " not " : " ") + "found.");
replaceFile();