Skip to main content
Inspiring
April 22, 2026
Question

app.selection breaks script in version - 30

  • April 22, 2026
  • 0 replies
  • 16 views

Hi everyone,

After updating Illustrator from version 30, I’ve encountered some issues in my extensions involving app.selection and app.executeMenuCommand().

It seems the variable var doc = app.activeDocument; loses its reference/value immediately after using the methods mentioned above.

Example:

  var doc = app.activeDocument;


alert(doc);
app.selection = null;
alert(doc);

First alert gives this result: 

---------------------------
Script Alert
---------------------------
[Document Untitled-2]
---------------------------
OK
---------------------------

Second alert returns:

---------------------------
Script Alert
---------------------------
[Document ]
---------------------------
OK
---------------------------

If i call same code from ExtendedScript toolkit everything works fine, when i call from extension, then its breaks.

One solution what helped to bypass this, is add “app.redraw()” sandwich.

  var doc = app.activeDocument;


alert(doc);
app.redraw();
app.selection = null;
app.redraw();
alert(doc);

The script now functions as expected. I'm not certain if this is the most efficient approach, but it resolved the issue.

Has anyone else encountered this problem and found an alternative solution?