Skip to main content
Known Participant
August 16, 2020
Question

Suspend UI during script execution

  • August 16, 2020
  • 2 replies
  • 1096 views

Hi all,

Is there anyway to suspend Illustrator UI while a script executes? 

This topic has been closed for replies.

2 replies

CarlosCanto
Community Expert
Community Expert
August 16, 2020

I don't think it's possible, but you're right, redrawing the screen takes a toll on performance.

 

as a workaround, at the beginning of my scripts I turn Preview Off. Working in Outline mode is way more efficient.

 

The UI also gets constantly redrawn, so if you can work at Full Screen (no toolbars or panels) that also helps.

Charu Rajput
Community Expert
Community Expert
August 17, 2020

Thanks Carlos for this information. 🙂

I have not yet tested. But I will try to set screenMode before the automation script and when process completes we can set the screen mode back to normal.

Just adding more information to do this via script

if(app.documents.length > 0){
    app.activeDocument.views[0].screenMode = ScreenMode.FULLSCREEN
}

 I hope this helps in CEP panels as well.

 

Best regards
CarlosCanto
Community Expert
Community Expert
August 18, 2020

you're welcome, 

ScreenMode.FULLSCREEN

 used to be rock solid in previous versions. Lately it has given me mixed results, it not always work. At least setting Preview off still works, that's the real time saver.

m1b
Community Expert
Community Expert
August 16, 2020

This might not be what you want, but have you looked at userInteractionLevel?

 

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS

 

(The other UserInteractionLevel is .DISPLAYALERTS)

nearzAuthor
Known Participant
August 16, 2020

Yes I have looked at this, I believe this is only for popup alerts. 

 

For example I have a script right now that currently goes through and selects different objects one at a time, makes the edit and moves on to the next object until complete. Illustrator currently renders the preview to highlight the selection, the same as when the user is manually selecting the object. My thought process is that if illustrator does not have to update the preview at the same time as running the script then it may help script performance.

m1b
Community Expert
Community Expert
August 16, 2020

rutgers_camden, is that normal behaviour (that "Illustrator currently renders the preview to highlight the selection, the same as when the user is manually selecting the object")? In my scripts the UI doesn't seem to be updated during a script unless I explicitly call app.redraw(). Are you calling redraw?

 

CarlosCanto, that's interesting! I've never thought to do that to speed up a script, again, because I've never noticed the UI updating during execution.

 

On the contrary, I've sometimes inserted app.redraw() to give a visual update or to provide several undos vs one undo for the whole script action.

 

As a side note: in my experience, setting the selection is bizarrely *slow*. For example, a script that deletes every 2nd pageItem will be way faster than a script that selects every 2nd pageItem. Have you guys found that? So, rutgers_camden is there a way you could get your script working without the selecting part?