Skip to main content
Known Participant
October 7, 2022
Answered

Action calling a script ignores selection[0] calls

  • October 7, 2022
  • 2 replies
  • 1111 views

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();
}

 

 

 

This topic has been closed for replies.
Correct answer Sergey Osokin

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


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

2 replies

Sergey Osokin
Inspiring
October 7, 2022

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.

Known Participant
October 7, 2022

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.

Sergey Osokin
Inspiring
October 7, 2022

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.

Charu Rajput
Community Expert
Community Expert
October 7, 2022

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
Known Participant
October 7, 2022

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