Skip to main content
Participant
June 14, 2017
Answered

#include preprocessor works on ExtendScript but not in Illustrator as standalone script

  • June 14, 2017
  • 1 reply
  • 3695 views

Hi!

When I do an include of a jsx file (that is on the same folder as the main jsx), everything works fine running from ExtendScript.

If I copy the files to the Illustrator's scripts folder and run it from Illustrator, nothing happens.

I tried adding different preprocessors to the file I want to include, but solved nothing.

If I copy the code to the main file, everything works as intended.

I also tried having all my code on the main file, and add a include to an empty file. When I do this, I no longer can run the script. Which makes me think that is something related to preprocessor directives. Maybe ExtendScript adds something that I'm missing.

Booth files are on the same folder and the code is something like:

/*

* The main jsx

*/

#target illustrator

      #targetengine main

#include "thingToInclude.jsx"

main();

function main()

{

    // The GUI code

}

/*

* The jsx to include

*/

#target illustrator

function bridgeTalkMessage()

{

    // Bridgetalk Code

}

function functionForBridgeTalk()

{

    // function for BridgeTalk

}

Thanks!

This topic has been closed for replies.
Correct answer Disposition_Dev

hard to know exactly because of the placeholder code you've posted, but a potential issue based on the syntax used above is that you must use absolute paths to the file to include.

#include "~/Desktop/Path/To/File.jsx"

another thing to check is to make sure the script you're running in illustrator is indeed a jsx and not a .js

In my experience you can't run a native js file from File > Scripts. It just fails silently.

Hope this helps..

1 reply

Disposition_Dev
Disposition_DevCorrect answer
Legend
June 14, 2017

hard to know exactly because of the placeholder code you've posted, but a potential issue based on the syntax used above is that you must use absolute paths to the file to include.

#include "~/Desktop/Path/To/File.jsx"

another thing to check is to make sure the script you're running in illustrator is indeed a jsx and not a .js

In my experience you can't run a native js file from File > Scripts. It just fails silently.

Hope this helps..

Participant
June 14, 2017

"you must use absolute paths to the file to include"- this, thanks!

My bad, I didn't realize that it's only absolute paths... That sucks.

Since they give you examples with "#include "../include/lib.jsxinc"" I thought it had predefined set of include paths.

Disposition_Dev
Legend
June 14, 2017

I allow for the possibility that I could be wrong on that.. I've always used absolute paths because i've had trouble otherwise.

I know there are ways to spoof a relative path by extracting the location of the script that's being executed, but i don't know the syntax for doing so. There are lots of smart people around here that do know, however. I'm sure one of them will chime in here.

Also, to all of the aforementioned smart people, if i'm wrong about the absolute/relative path thing, i'd surely like to know about it.