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

Action calling a script ignores selection[0] calls

Explorer ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

This script works if I call it via menu  file/scripts/scriptname,   but when I assign an action to run it, the action ignores the selection[0] calls.  I'm trying to get this script to run with a function key.

 

 

if ( app.documents.length > 0) {
    doc = app.activeDocument;

selection[0].embed()
app.executeMenuCommand ("releaseMask")
app.executeMenuCommand ("ungroup")
selection[0].remove();
}

 

 

 

TOPICS
Scripting

Views

254

Translate

Translate

Report

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

Enthusiast , Oct 07, 2022 Oct 07, 2022

You are using the wrong way to add the script to the action. Add scripts via "Insert menu item".

add-script-to-action.gif

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

Hi,

If I understand you mean, you can not embed() using the actions?

I tried, and I see that embed can not be recorded.

Best regards

Votes

Translate

Translate

Report

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
Explorer ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

Yeah it seems making an action to run a script, limits what the script can do.

Votes

Translate

Translate

Report

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
Enthusiast ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

Tell us more about it. What happens on the screen, does an error show up? What version of Adobe Illustrator, Mac OS, Windows? Could you show us an example file? I added your script to a new Action and ran it on the linked EPS. The script executed. Illustrator CC 2019/2022, Mac OS.

Votes

Translate

Translate

Report

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
Explorer ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

That's the whole script 🙂 . I run on windows 11 with cc, so should be latest. When I add the script to action, I can see the two executeMenu commands show up as individual action items, but the embed, and remove do not. So when I run it, I get the error clippin mask unavailable, but if I embed it manually first, does not error, but also does not remove the clipping area. It seems when action added it, it stripped out the embed and remove.   One thing I'm trying is to loop through the selected items ( I have 3 linked image items selected), then running the script on those, but haven't had luck with that yet. I can try running on mac also. I'll upload some files tomorrow. Thanks for taking a look.

Votes

Translate

Translate

Report

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
Enthusiast ,
Oct 06, 2022 Oct 06, 2022

Copy link to clipboard

Copied

Show a screenshot of your Action panel. Or you can record a video of you adding an action and calling it. I don't quite understand how you can see the individual script commands in the Action panel? Only the script file is added there.
action.jpg

Votes

Translate

Translate

Report

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 ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

@Sergey Osokin 

Did you add the script in the actions? Or you records the Embed action?

Best regards

Votes

Translate

Translate

Report

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
Enthusiast ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

As I wrote in the screenshot, this is a JS file added to the action. gstewartjr wrote that the script inside the action doesn't work. I didn't see any reason why it wouldn't work in the test. 

Votes

Translate

Translate

Report

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
Explorer ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

Here is video of adding script to action. Thanks guys for helping on this!

Votes

Translate

Translate

Report

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
Enthusiast ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

You are using the wrong way to add the script to the action. Add scripts via "Insert menu item".

add-script-to-action.gif

Votes

Translate

Translate

Report

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
Explorer ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

LATEST

OMG thanks! It works. 

Votes

Translate

Translate

Report

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