我以前从来没有遇到过extendscript的这个问题,我认为extendscript是同步的。我遍历了一个数组:对于数组中的每个对象,我打开、读取和更新一个xml,然后将其导入PPro。我认为循环比文件更新和导入完成得更快--没有文件被导入。
如果我每次都使用alert(array[i])
,那么一切都正常,但是一旦我注释掉了警报,文件就不再导入了。
function importXML(targetFile){
app.project.importFiles([targetFile], 1); // 1 == suppress UI
updateEventPanel('Media imported for ' + show);
return 'success';
}
function processXML(obj){
var shows = obj.shows;
// alert(shows.length);
var currentShow = obj.shows[0];
for(var i = 0; i < shows.length-1; i++){
var xmlDoc = obj.targetXml;
var show = obj.shows[i+1];
// alert('currentShow: ' + currentShow);
// alert('show: ' + show);
var currentValue1 = new RegExp('<Name>'+ currentShow, 'g');
var currentValue2 = new RegExp('HIGHLIGHT_VERSIONING/'+ currentShow, 'g');
var newValue1 = '<Name>'+ show;
var newValue2 = 'HIGHLIGHT_VERSIONING/'+ show;
var myFile = new File(xmlDoc);
myFile.open('e', undefined, undefined);
var inText = myFile.read();
inText = inText
.replace(currentValue1, newValue1)
.replace(currentValue2, newValue2);
myFile.seek(0);
myFile.write(inText);
myFile.close();
updateEventPanel('XML updated for ' + show);
importXML(xmlDoc);
// updateEventPanel('Media imported for ' + show);
currentShow = show;
};
}
发布于 2019-08-12 10:21:09
我以前在从静态csv文件读取数据时遇到过类似的问题……我有一个scriptUI下拉的onChange事件,但它们在读取中途超时时只填充了一半。我去寻找一个类似settimeout的函数,我发现ESTK有一个$.sleep()方法用于添加延迟:
sleep()
$.sleep(milliseconds)
milliseconds
The number of milliseconds to wait.
Suspends the calling thread for the given number of milliseconds.
During a sleep period, checks at 100 millisecond intervals to see
whether the sleep should be terminated. This can happen if there is
a break request, or if the script timeout has expired.
Returns: undefined
您可以在aenhancers estk文档中阅读关于美元对象的所有内容:https://estk.aenhancers.com/8%20-%20ExtendScript%20Tools%20and%20Features/dollar-object.html
https://stackoverflow.com/questions/57315443
复制