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

Import function from external script JavaScript

Community Beginner ,
Jun 08, 2020 Jun 08, 2020

Hi, everyone!

I'm quite new to scripting in Illustrator, so I was wondering whether I could write a file with a few funcitons that I use most often (like utilities in python) and call them from this file into a different script instead of writing them every time. Like that:

```

// internal_file.js

from external_file import Function

```

Unfortunately, I was unable to do it with the standard js methods and I suppose, it's because Illustrator scripting uses a basic version of js that doesn't have all the methods and objects. Has anyone found a way around?

TOPICS
Import and export , Scripting , Third party plugins
2.0K
Translate
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 , Jun 08, 2020 Jun 08, 2020

Hi, you can include external scripts uisng the following commands

#include "fileName"

 Example :

#include "utility.jsx"

 

Let us know if you are looking for this or something else.

 

 

Translate
Adobe
Community Expert ,
Jun 08, 2020 Jun 08, 2020

Hi, you can include external scripts uisng the following commands

#include "fileName"

 Example :

#include "utility.jsx"

 

Let us know if you are looking for this or something else.

 

 

Best regards
Translate
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 ,
Jun 08, 2020 Jun 08, 2020

It worked, thanks a lot!

Translate
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
Engaged ,
Apr 21, 2023 Apr 21, 2023
LATEST

I have been using either #include or //@include on many of my scripts. However I have been looking at swtiching to idjs. I am wondering how to do the same thing. I have tried to use require and or import with no success. What is the correct solution to this?

Translate
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