0

I have illustrator scripts that select Layers and other scripts that move items to named layers.

I want to create one file where I can name all the layers as variables, I have some experience with PHP and I understand the include function. I need something similar that will work with JS.

I have tried the code from this link - jQuery.getScript

But I am getting errors, so it seems I am missing something (I don't have any experience with JS). I'm not even sure if Illustrator works like that.

This is the code

var aDoc = app.activeDocument;

$.getScript( "LayerNames.js" )
  .done(function( script, textStatus ) {
    console.log( textStatus );
  })
  .fail(function( jqxhr, settings, exception ) {
    $( "div.log" ).text( "Triggered ajaxError handler." );
});

aDoc.activeLayer = aDoc.layers.getByName(layerName1);

LayerNames.js has the following code

var layerName1 = 'Background';

The error I get is $.getScript is not a function.

So, the question is, can I reference an external js file in an illustrator script and if yes, how?

RobC
  • 22,977
  • 20
  • 73
  • 80
Aasim Azam
  • 498
  • 2
  • 6
  • 23
  • 1
    Does this answer your question? [Can Adobe .jsx scripts include other script files?](https://stackoverflow.com/questions/15746335/can-adobe-jsx-scripts-include-other-script-files) – RobC Jul 14 '20 at 09:02
  • This didn't show up in any searches I did, but its basicallty the same answer. – Aasim Azam Jul 19 '20 at 21:27

1 Answers1

0

I found the answer to be

#include "sample.jsx"

This works perfectly for my case senario.

Aasim Azam
  • 498
  • 2
  • 6
  • 23