It looks like you're new here. If you want to get involved, click one of these buttons!
Hello,
Say I have a script that adds a shape, and another script the deletes some shapes.
Is there a way to enable Undo/Redo functionality? i.e., can I register my modifications to the layout into some undo/redo queue?
Presently, when I click on Undo, it undoes whatever happened before I ran the script, which really isn't the desired behaviour.
Thank you
Lukas
Comments
Pasting from E4K's "Draw a box, with undo.lym". You'll have to translate to python.
Sorry to hijack the thread.. but Matthias: I observed a strange behavior related to redraw:
If I put this line after puts msg:
Then the box does get created but isn't visible on the screen until you zoom or pan. Because the MessageBox is hijacking the redraw I suppose. Can we get around this somehow -- e.g. by calling something like a redraw method somewhere?
Thanks,
David
Thank you David.
I confirm that undo/redo works. However, I also confirm the bug you found.
Another thing I found is that if you don't call "commit", you have a problem:
Here's the code:
Hi all,
thanks for mention these topics.
Basically the layout will be in "under construction" mode until you commit the transaction. The reasoning behind this mode is that during a sequence of operations the layout object may be in some invalid state: for example if you delete a cell before you delete the instances of the cell then you have a temporary state where cell instances may point to non-existing cells.
The idea of "commit" is both to release the layout from this state and also to mark the end of a sequence of operations which start with a consistent state and end with one. It's important to call "commit" to leave the state - that's why it's in the "ensure" branch in Ruby and will always be executed this way. The equivalent in Python is "finally".
Apparently opening a message box confuses the program since that will enter the event loop while the layout is still in "under construction" mode. The modifications on the layout have already requested a redraw (triggered by the event loop), but the drawing engine will reject drawing of "under construction" layouts in order not to compromise stability. I think you can easily work around this issue by putting the message box after the "commit".
Matthias