Floating panel to run script
Hello, would be happy if someone may point out how to run a script from a floating panel button.
below fails to be able to run the script once the button is hit.
The script it is talking to runs perfectly fine on its own, but the button script is failling to call it correctly.
The script says there is no document but i have one open...
Many thanks
Smyth
//@target illustrator
//@targetengine "persistent"
//@strict on
// Suppress warning
app.preferences.setBooleanPreference("ShowExternalJSXWarning", false);
var win = new Window('palette', 'Run Custom Script', undefined, { closeButton:true });
win.alignChildren = ['fill', 'top'];
var runBtn = win.add('button', undefined, 'Run Grids V2.jsx');
runBtn.onClick = function() {
var scriptPath = "C:/Program Files/Adobe/Adobe Illustrator 2021/Presets/en_US/Scripts/Grids V2.jsx";
var scriptFile = new File(scriptPath);
if (!scriptFile.exists) {
alert("Script not found at:\n" + scriptFile.fsName);
return;
}
try {
$.evalFile(scriptFile);
} catch (e) {
alert("Could not execute script:\n\n" + e);
}
};
win.center();
win.show();
