View Full Version : Undo causes crash after lisp routine
mweaver
2007-06-13, 02:19 PM
I have a lisp routine that uses a lot of active-x calls. I enclose the routine in within an Undo Mark/Undo end pair, and the routine runs fine. However, if, after running the routine, I try to undo through it, I see the changes undone, but then acad locks up. No error messages or warnings, just hangs.
Has anyone else experienced this and found a solution?
Mike Weaver
(vla-StartUndoMark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
(MakeBlock Block1 Block2)
(ReplaceAttributedBlocks TempBlockName Block1 0 T)
(ReplaceAttributedBlocks Block1 Block2 0 T)
(ReplaceAttributedBlocks Block2 TempBlockName 0 T)
(vla-endundomark doc)
T.Willey
2007-06-13, 04:55 PM
It is caused by using "undo" "mark". If you issue it as a command the same thing has happened to me, so I have had to add error code that will end the mark.
mweaver
2007-06-14, 08:11 PM
It is caused by using "undo" "mark". If you issue it as a command the same thing has happened to me, so I have had to add error code that will end the mark.
I've tried it both ways. The code I posted includes both undo mark and undo end. It crashes. When I took all references to the undo facility out of my code it still crashes. I also have a VBA routine exibiting the same behavior.
T.Willey
2007-06-14, 11:02 PM
I've tried it both ways. The code I posted includes both undo mark and undo end. It crashes. When I took all references to the undo facility out of my code it still crashes. I also have a VBA routine exibiting the same behavior.
If it crashes without the undo stuff then it is the code. I know that if you don't end an undo, and try to undo past it, it will sometimes crash Acad. I usually end any open undo, then start my own undo, and then end it at the end, in case something has left an undo open.
(command "_.undo" "_end")
(command "_.undo" "_group")
.. code here
(command "_.undo" "_end")
or where ActDoc = Active Document
(vla-EndUndoMark ActDoc)
(vla-StartUndoMark ActDoc)
.. code here
(vla-EndUndoMark ActDoc)
mweaver
2007-06-15, 05:13 AM
Okay. Is there any way to tell if/how many undo groups may be open? Or do I just issued a handful of undo ends and hope I've issued enough?
mweaver
2007-06-15, 05:39 AM
Okay. Is there any way to tell if/how many undo groups may be open? Or do I just issued a handful of undo ends and hope I've issued enough?
I found it. While UndoCTL = 8 there is a group open.
(while (= 8 (getvar "undoctl"))
(command "._undo" "e")
)
I'll put this in my routine and see if that solves the problem.
Thanks for the help,
Mike
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.