Skip to main content
Known Participant
August 16, 2020
Répondu

Is there a way to prevent the redraw() command from being an undo set point

I ran into a problem in my script that redraw happened to fix for me, and now I have 5 or 6 redraw commands total... However,  I liked how one single undo command undid the entire script, but now I have to hit undo 5 or 6 times,  it's not major but just wondering if preventing this is possible.

Ce sujet a été fermé aux réponses.
Meilleure réponse par CarlosCanto

Ah! Thanks.


redraw() also helps when applying Effects or LiveTracing. Sometimes (not always) it's necessary to redraw the screen. Problem is to tell when, Illustrator is like a wild beast we have to domesticate.

3 commentaires

m1b
Community Expert
Community Expert
August 16, 2020

I don't have an answer, but I'm curious: what do the redraw() commands fix? I've mainly used them to either update the UI or to  provide intermediate levels of undo.

Silly-V
Legend
August 17, 2020

One main function is like you mentioned, you want to show the user the document's changes before the script ends.

But sometimes when doing a lot of document manipulation where artwork gets put from various documents into other documents, the script will experience some kinds of bugs that would lead you to believe that the script is working with some 'outdated' version of where the artwork is supposed to be. That's when I stick in a redraw() and sometimes it was the solution!

m1b
Community Expert
Community Expert
August 17, 2020

Ah! Thanks.

Jeff Witchel, ACI
Community Expert
Community Expert
August 16, 2020

Hmm! Not sure I understand your question, but would it help if the the Script put the View into Outline before runnng?

 

There's no redrawing when all you see is vector outlines on your screen.

Known Participant
August 16, 2020

Hmmm, that might help.  Is switching the preview a common tactic for helping with performance of scripts, it seems like it might a good strategy, just in general for scripts that do a lot of work.

 

And just to explain the original question better, say I have a script that creates 10 rectangles.  After the script finishes, pressing undo just one single time undoes all 10 rectangles at once.  But if the script creates 5 rectangles, then does a redraw(); and then creates another 5 rectangles, after it finishes, pressing undo one time no longer undoes everything, it just undoes the last 5 rectangles.  

 

It's minor, but I like the outline idea.

 

 

Jeff Witchel, ACI
Community Expert
Community Expert
August 16, 2020

Not sure, I'm not a scripter. But I found another post about it that's active right now: https://community.adobe.com/t5/illustrator/suspend-ui-during-script-execution/td-p/11362997?page=1

See the post from CarlosCanto.

femkeblanco
Legend
August 16, 2020

undo() will undo the last act.  If the last act was redraw(), I don't see how it can take you before that. 

Known Participant
August 16, 2020

I meant undoing after running a script... one undo after running the script would take me back before running any of the script, undoing dozens of commands all at once.  But now that the script has redraw's in it, each undo only goes back to the previous redraw command.

 

It's minor, but I liked it when everything was being undone with just one command, as I test things the extra undo's feel excessive.

femkeblanco
Legend
August 16, 2020

Gotya.  Still, redraw() counts as your last act, so one undo() will undo that but no further.