我已经创建了一个jsx脚本,它在illustrator中创建了一个自定义对话框,允许我将文本文件加载到字符串中。这一切似乎在Extendscript中正常工作,但是我保存它并从中独立运行它的那一刻Illustrator出现对话框然后立即消失。任何想法,我已删除所有$writeIn
语句。
我环顾四周,但似乎没有什么 代码看起来像:
function init() {
dataFile=""//Load in paths to users day file and folder where spreadsheets are stored
var readFile = File(appPath+ "pathData"+".txt");
if(readFile != null) {
readFile.open('r')
dataPath=readFile.read();
readFile.close();
dataPath=dataPath.replace(/[\n\r]/g, '');//Seems to need this as without there is a cariage return added to the end of the string somewhere in the saving of the file
};
else dataPath="Press button to set path to day folder";
readFile = File(appPath+ "pathDay"+".txt");
if(readFile != null) {
readFile.open('r')
dayPath=readFile.read();
readFile.close()
dayPath=dayPath.replace(/[\n\r]/g, '');//Seems to need this as without there is a cariage return added to the end of the string somewhere in the saving of the file
//$.writeln("dayPath=",dayPath);
};
else dayPath="Press button to set path to day folder";
var initPanel=new Window("palette","iPlot", undefined);
initPanel.orientation="column"
var group1=initPanel.add("group",undefined,"GroupOne");
group1.orientation="column"
var loadButton=group1.add("button",undefined,"Load data");
loadButton.onClick = function() {
initPanel.close();
loadFile();
};
var closeButton=group1.add("button",undefined,"Close");
closeButton.onClick = function() {
//$.writeln("Close button pressed");
initPanel.close();
};
var setipButton=group1.add("button",undefined,"Setup");
setipButton.onClick = function() {
setup()
};
initPanel.center();
initPanel.show();
return true;
}
答案 0 :(得分:2)
仅限调色板和对话框"直播"只要您的脚本运行。据我所知(勉强),只要你的脚本结束,即你想在Illustrator中的面板之外工作,Extendscript引擎认为脚本本身已经结束。
通常的解决方法是将私有资源专用于您的脚本。你可以通过创建一个专用的"引擎"来保持内存。在最顶部添加时,以下两行可以解决这个问题:
#target Illustrator
#targetengine main
如果您从Illustrator中运行脚本,则第一个已过时,但如果您从其他地方(例如从Extendscript Toolkit编辑器中)运行它,则需要它。第二个设置具有指定名称的私有引擎;在这种情况下main
,但如果您同时运行多个调色板,则每个调色板都需要唯一的名称。
请参阅http://forums.adobe.com/thread/1238745 - 特别是最后一篇文章。