Copy link to clipboard
Copied
[AI CC 2017 V21.0.0 MAC]
I am trying to create a custom palette for linking files together, and when I use the palette with #include, it constantly disappears.
I run the following JSX script from Illustrator with a document open:
#target illustrator
#targetengine 'main'
#include 'functions.inc'
var windw = new Window( "palette", 'title', undefined );
windw.show();
alert('done');
It creates a new palette window, and an alert box.
When I click Okay on the alert box, the palette disappears.
If I remove the #include, the palette remains visible, after I click Okay.
Why is the palette disappearing when I use #include?
It also disappears if I remove both the #include and the #targetengine.
After many hours of searching, I've concluded that it's impossible to use #include reliably with palette windows. Here is the workaround I settled on (thank you Silly-V).
At the top of the main document (after #target):
var ip = new File($.fileName); var scriptPath = ip.path;
function incScript(sn){ eval('#includepath ' + scriptPath + '\n#include ' + sn); }
Then when you want to use an include:
incScript('functions.jsxinc');
This assumes that the included files are in the same folder as th
...Copy link to clipboard
Copied
I'm not sure what the reason is for it not working, I have always avoided #include files with palette scripts because it was causing problems when I was sending palette functions via BridgeTalk.
But you could do file reads on your script files and use eval() to include those files in your code, to see if it solves your issue while taking advantage of keeping separate files.
Copy link to clipboard
Copied
Good idea -- I'll try that at the end of the day if I can't find a solution.
Copy link to clipboard
Copied
After many hours of searching, I've concluded that it's impossible to use #include reliably with palette windows. Here is the workaround I settled on (thank you Silly-V).
At the top of the main document (after #target):
var ip = new File($.fileName); var scriptPath = ip.path;
function incScript(sn){ eval('#includepath ' + scriptPath + '\n#include ' + sn); }
Then when you want to use an include:
incScript('functions.jsxinc');
This assumes that the included files are in the same folder as the main script.
Copy link to clipboard
Copied
Thank you very much ) It works ))