I reduced the script so it’s easier to read and tried to remake the FOR sentences to be cleaner… I save the sources in an array first and then convert everything to a placeholder. finally I set the proxy for the placeholder based on the sources array.
But the problem still there and is the same error… If I apply the script on a new file with some files imported, it works the first time, but if you UNDO and try to apply it again… doesn’t work.
Could it be that After effects doesn’t update correctly the sources files after undoing?
also… the base code to set proxy always work… the problem is just when I try to add the feature of replacing with placeholder.
app.beginUndoGroup(“setproxytoself”);
var allSelectedSources= new Array();
for (i=1 ; i <= app.project.numItems ; i++){
var pItem=app.project.item(i);
if (pItem.selected==true){
var pSource=pItem.mainSource.file;
allSelectedSources[i]=pSource;
};
};
for (a=1 ; a <= app.project.numItems ; a++){
var pItem=app.project.item(a);
if (pItem.selected==true){
pItem.replaceWithPlaceholder('placeHolder',1920,1080,30,3)
pItem.setProxy(allSelectedSources[a])
};
};