Answered
Running the script a second time, ae crashes
I tried writing a script to quickly replace placeholders and it worked, but the second time I ran it, AE crashed
var myComp = app.project.activeItem;
var ml = myComp.selectedLayers[0];
if (ml.source.frameRate === 0) {
var ml_Source_FrameRate = 1;
}else{
var ml_Source_FrameRate = ml.source.frameRate;
};
function searchLayer(string) {
var itemNum = app.project.numItems;
for (searchLayerIndex = 1; searchLayerIndex <= itemNum; searchLayerIndex++) {
if (app.project.item(searchLayerIndex).name === string) {
if (app.project.item(searchLayerIndex).file.fsName === ml.source.file.fsName) {
return searchLayerIndex;
}
};
}
return false;
}
searchLayer(ml.source.name);
var ml_source_name = ml.source.name;
app.project.item(searchLayerIndex).replaceWithPlaceholder("__placeholder__", ml.source.width, ml.source.height, ml_Source_FrameRate, ml.source.duration);
ml.source.name = ml_source_name;
}
How can I modify it so that it can run the second time without ae crashing?
How can I modify it so that it can run the second time without ae crashing?
