• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script-created Illustrator Palette disappears when in the presence of #include

Participant ,
Nov 16, 2017 Nov 16, 2017

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.

TOPICS
Scripting

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Nov 17, 2017 Nov 17, 2017

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

...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Nov 16, 2017 Nov 16, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 16, 2017 Nov 16, 2017

Copy link to clipboard

Copied

Good idea -- I'll try that at the end of the day if I can't find a solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 17, 2017 Nov 17, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

LATEST

Thank you very much ) It works ))

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines