Copy link to clipboard
Copied
So here's a way to crash illustrator:
Create an action that does something simple like creating a rectangle. Call it "rectangle".
Create a script, lets; call it action.jsx
var actionSet = "my actions";
var action = "rectangle";
app.doScript(action, actionSet);
Running action "rectangle" is fine. As so is running the script action.jsx
So far so good.
But let's complicate matters by creating another action, bit this one is called "runscript" that plays action.jsx.
If that gets played it'll run an action to run a script to run an action. And there's where illustator falls over. You can't run two actions at the same time. Ilustrator crashes without warning.
Is there a way around this?
And don't say don't run two actions at the same time.
It's not the fact you can't run two actions at the same time, it is just a threading problem. You can read more here.
Or said best by @Disposition_Dev
"It would require multiple simultaneous threads, and Extendscript is single threaded. No process can begin until the previous one finishes, so as long as the script is still running, the action is still running, which means the script cannot call a new action."
Copy link to clipboard
Copied
It's not the fact you can't run two actions at the same time, it is just a threading problem. You can read more here.
Or said best by @Disposition_Dev
"It would require multiple simultaneous threads, and Extendscript is single threaded. No process can begin until the previous one finishes, so as long as the script is still running, the action is still running, which means the script cannot call a new action."
Copy link to clipboard
Copied
... Photoshop which suffers from the same problem, but at least Photoshop will respond with an unable to complete task type of error - rather than crashing.
Copy link to clipboard
Copied
Is there a way around this?
And don't say don't run two actions at the same time.
Why bother coming here to ask a question if you're going to pre-disregard the correct answer? Illustrator is single threaded. An action occupies that thread and does not relinquish control until the action is completed. Illustrator simply cannot do multiple nested concurrent actions. So there is no answer other than "don't run two actions at the same time".
The real solution is to just re-work your flow of control. You can still use multiple actions, you just can't nest action calls. If you have two separate actions you need to run, write a .jsx that runs both of those actions sequentially. If the problem is that you want to have an action that runs a script (which executes another action) so that you can use a hotkey to execute the script then simply don't use an action for this purpose. There are plenty of other options available for hotkeying scripts.
Lastly, I think i was able to figure out what you want to do here, but it was definitely confusing with the loose usage of the word "action" and "script" and it's definitely possible that i'm misunderstanding your goal/problem. For future questions, you can help us out (and improve the quality of the answers you receive) by being a little more intentional with word choices to avoid confusion.