Hello, all!
So there's a thing that has been annoying me ever since I learned to use CommandGroup - it does group the actions, but it still redraws selection nodes when undoing. Here's an example:
Sub UndoJunk()
ActiveDocument.BeginCommandGroup "UndoJunk"
Dim A As Integer Dim S As Shape Set S = ActiveLayer.CreateEllipse2(0, 0, 1) For A = 0 To 100 S.Move 1, 0 Next A ActiveDocument.EndCommandGroup
End Sub
When you undo you get this line of dots that takes quite a while to redraw, especially if you had a decent amount of operations. For this simple example VirtualLayers may be the answer, but in my case I'm doing some more advanced things which involve checking for curve intersections using DisplayCurve, IntersectsWith, IsPointInside etc.
So my question is - is there a way to avoid this undo junk and just instantly jump back a step?
I'm on X6, btw, perhaps this has been fixed in following versions, who knows.
fwiw. You can speed it up by using
Optimization=True
blah, blah, blah
ActiveDocument.EndCommandGroup
Optimization = False
ActiveWindow.Refresh
joe said:I can understand if CorelDRAW's undo system works by basically tracing your steps backwards, but why it wants to redraw the selections while doing so is beyond me.
This a huge problem for macros and one I've tried to resolve myself with little success...
The best idea I had to remove undo events was to create a document from the shapes you want to process, do you stuff then move the shapes back to the original document (closing the original). If you replace the shape then then operation becomes a single undo as the events are associated with their parent document.
I touched on it with the tree node discussion a few months back. While treenodes seem to be very unstable when used cross documents (on X7 at least) you could either save, import then delete the file or just copy and paste it back in. The only draw back is its annoying to overwrite what you have on your clipboard and fairly slow to import but I guess that depends on the user and how long your macro takes to run in the first place.
I would be very helpful if someone could come up with a reliable solution that doesn't have these issues.
My knowledge is pretty shallow here, so consider this to be more of a question than an answer...
It seems to me that relief from some of the visual "undo junk" might be had by performing the undo from within a macro, e.g.
Sub undo_it() Optimization = True ActiveDocument.Undo Optimization = False Application.RefreshEnd Sub
Are there compelling reasons not to do it that way?