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

Is it possible to reference another js file in an illustrator script?

Explorer ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

I have a JS script that selects layers and another one that moves items to a named layer.

var aDoc = app.activeDocument;
var layerName1 = 'Background';
aDoc.activeLayer = aDoc.layers.getByName(layerName1);

I want to be able to define all the Layer Names in another file and reference it into the above file and its ilk.

But I have tried to reference the file but I get errors.

The idea is to apply a shortcut to each scripts and program it to my keyboard.

Any help on this?

TOPICS
Scripting

Views

739

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

Community Expert , Jul 10, 2020 Jul 10, 2020

You can include one script in other script using 

#include "sample.jsx"

 

sample.jsx - will be complete path of your script.

 

Let us know if you need more help.

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

You can include one script in other script using 

#include "sample.jsx"

 

sample.jsx - will be complete path of your script.

 

Let us know if you need more help.

Best regards

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
Explorer ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

I have always used the extension .jsxinc in the include e.g #inlcude layers.jsxinc. I am assuming based of this it is not a requirement?

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 Expert ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

LATEST

Also note, if you are using Visual Studio Code and ExtendScript Debugger, you need "//@include", eg.

//@include "../lib/otherFile.js"

 

I don't think it matters which extension you use. I've not had trouble with .js and .jsx anyway. Using .jsxinc just seemed unnecessary so I gave it up.

 

Mark

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