Highlighted

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

Participant ,
Aug 16, 2020

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by Silly-V | Adobe Community Professional

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!

TOPICS
Scripting

Views

111

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

Participant ,
Aug 16, 2020

Copy link to clipboard

Copied

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.

Adobe Community Professional
Correct answer by Silly-V | Adobe Community Professional

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!

TOPICS
Scripting

Views

112

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 16, 2020 0
Engaged ,
Aug 16, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0
Participant ,
Aug 16, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0
Engaged ,
Aug 16, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0
Adobe Community Professional ,
Aug 16, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 1
Participant ,
Aug 16, 2020

Copy link to clipboard

Copied

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.

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0
Adobe Community Professional ,
Aug 16, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0
Contributor ,
Aug 16, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 16, 2020 0
Adobe Community Professional ,
Aug 17, 2020

Copy link to clipboard

Copied

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 17, 2020 1
Contributor ,
Aug 17, 2020

Copy link to clipboard

Copied

Ah! Thanks.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 17, 2020 0
Adobe Community Professional ,
Aug 17, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 17, 2020 0
Resources