Skip to main content
Participant
September 11, 2024
Question

Script to call scripts with actions.

  • September 11, 2024
  • 1 reply
  • 342 views

Hello, I'm a complete begginer to Illustrator scripting and I hope you can help me with this problem. I'm trying to:
Call an action within an action set using Jsx. My problem is that using app.doScript() to call on the action does not load the steps in the action that uses scripts.

Ex. ACTION1
1. Alignment
2. Color
3. JSX Script

If I just run ACTION1 on its own, it completes all steps. But when I use app.doScript(), it runs steps 1 and 2, but gets a "currently not available" on step 3. I know that I can just use a single script to achieve the objective of all 3 steps, but I have multiple actions that have combinations of recorded steps + script so I can't redo them all.

Is there  a way around this?

This topic has been closed for replies.

1 reply

jduncan
Community Expert
Community Expert
September 11, 2024

This comes up quite a bit here actually. Basically, Ai ExtendScript is single threaded so when you initiate an action from a script (first thread) and that action tries to run another script (second thread) Ai is waiting for the first thread to end before it can move on to the second.

 

You could try calling the second script from within the first script like below or skip the use of an action and write those steps in the script (if doable).

 

// do you stuff from script one
var doc = app.activeDocument;

// call your action (without the other script call)
app.doScript("hey", "example");

// run your second script from here instead of the action
var s = new File(Folder.desktop + "/example.jsx");
$.evalFile(s);