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

Running script from actions

Engaged ,
Jun 04, 2015 Jun 04, 2015

I am using Illustrator CS4 on a Windows PC writing in JavaScript. I know I can't call an action via JavaScript in my version/language but I can load the script from an action. I call some scripts from my action set using the insert menu item in the action menu. However even if I save the actions with the scripts in the playlist Illustrator doesn't retain the scripts in the action set. Am I doing something wrong? Is there a work around?

TOPICS
Scripting
2.2K
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 04, 2015 Jun 04, 2015

Unfortunately, this has been a problem for years and there's no sign that adobe has any intention to fix it. The only current workaround i'm familiar with is to simply re-add the script to the action each time you open illustrator.. It's a pain, i know, but still better than doing part of the action and then calling the script manually.

Another option is to create a shell script that will run your action, then when the action is finished, you can run the script within your shell script.

Translate
Adobe
Community Expert ,
Jun 04, 2015 Jun 04, 2015

Unfortunately, this has been a problem for years and there's no sign that adobe has any intention to fix it. The only current workaround i'm familiar with is to simply re-add the script to the action each time you open illustrator.. It's a pain, i know, but still better than doing part of the action and then calling the script manually.

Another option is to create a shell script that will run your action, then when the action is finished, you can run the script within your shell script.

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 ,
Jun 04, 2015 Jun 04, 2015

BOOOOO  lol. Thank you for the response. I thought maybe I was doing something wrong or a preference check box I was missing. I guess I will just run the action then the script. It's not that big of a deal but every click for efficiency is important.

Thanks again!

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 Expert ,
Jun 04, 2015 Jun 04, 2015

I'm with you on that. I'm constantly fighting with my boss about things he thinks are stupid and i shouldn't spend any time on. And i always bring that up.. 5 seconds saved on one order adds up to a crap ton of saved time over the course of a year and 50,000-100,000 orders. Every click matters.

So to that end, I'd consider trying out my second suggestion. just something like this:

//begin shell script

function doActionAndScript(){

     var doc = app.activeDocument;

     app.doScript(action, set);

     //begin script you wanted to call from your action

}

doActionAndScript();

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 ,
Jun 04, 2015 Jun 04, 2015

By shell script do you mean something other than via ExtendScript? Because my version of AI doesn't support...

app.doScript(action, set);

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
Valorous Hero ,
Jun 04, 2015 Jun 04, 2015

Did you guys see this thread : Is there a way to clear or delete actions through scripting?
To have scripts be accessible by an action after restart, make sure to hover over the File menu and then reload the actions by loading an action set in the actions panel. The script should then be accessible. You just have to do this every time you restart Illustrator.

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 Expert ,
Jun 04, 2015 Jun 04, 2015
LATEST

What's the difference between doing this and just re-adding the script/menu item? To me being required to remove and re-load the set every day is 2 steps too many.

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 Expert ,
Jun 04, 2015 Jun 04, 2015

My bad, Subie.

I forgot to mention that was CS6+. CS5 and prior doesn't support actions via javascript.

By shell script i just meant a script that holds the command for the action and then the code block for the script you wanted to call. it's just a container to do the two tasks you want to perform.

could you share what you're trying to do with the action? Perhaps we can script whatever was being done with the action and avoid the action step all together and just run the entire workflow as one script.

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