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

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

Participant ,
Aug 16, 2020 Aug 16, 2020

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.

TOPICS
Scripting
1.0K
Translate
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 2 Correct answers

Valorous Hero , Aug 17, 2020 Aug 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!

Translate
Community Expert , Aug 17, 2020 Aug 17, 2020

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.

Translate
Adobe
Guide ,
Aug 16, 2020 Aug 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. 

Translate
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
Participant ,
Aug 16, 2020 Aug 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.

Translate
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
Guide ,
Aug 16, 2020 Aug 16, 2020

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

Translate
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 ,
Aug 16, 2020 Aug 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.

Translate
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
Participant ,
Aug 16, 2020 Aug 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.

 

 

Translate
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 ,
Aug 16, 2020 Aug 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.

Translate
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 ,
Aug 16, 2020 Aug 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.

Translate
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
Valorous Hero ,
Aug 17, 2020 Aug 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!

Translate
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 ,
Aug 17, 2020 Aug 17, 2020

Ah! Thanks.

Translate
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 ,
Aug 17, 2020 Aug 17, 2020
LATEST

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.

Translate
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