Results 1 to 6 of 6

Thread: Undo causes crash after lisp routine

  1. #1
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Unhappy Undo causes crash after lisp routine

    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

    Code:
    (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)
    Last edited by Opie; 2007-06-19 at 07:08 PM. Reason: [CODE] tags added

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Undo causes crash after lisp routine

    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.

  3. #3
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Undo causes crash after lisp routine

    Quote Originally Posted by T.Willey
    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.

  4. #4
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Undo causes crash after lisp routine

    Quote Originally Posted by mweaver
    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.
    Code:
    (command "_.undo" "_end")
    (command "_.undo" "_group")
    .. code here
    (command "_.undo" "_end")
    or where ActDoc = Active Document
    Code:
    (vla-EndUndoMark ActDoc)
    (vla-StartUndoMark ActDoc)
    .. code here
    (vla-EndUndoMark ActDoc)

  5. #5
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Undo causes crash after lisp routine

    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?

  6. #6
    Active Member
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Undo causes crash after lisp routine

    Quote Originally Posted by mweaver
    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

Similar Threads

  1. undo groups in lisp code
    By jakob_k in forum AutoLISP
    Replies: 6
    Last Post: 2014-08-20, 09:28 PM
  2. Lisp routine keeps making my cad crash
    By LSElite in forum AutoLISP
    Replies: 1
    Last Post: 2012-12-12, 12:23 PM
  3. Help with a lisp routine to add a 12" line to this routine
    By Orbytal.edge341183 in forum AutoLISP
    Replies: 3
    Last Post: 2012-11-14, 10:33 PM
  4. Replies: 9
    Last Post: 2012-01-21, 07:58 AM
  5. using undo in a lisp...
    By timothyjturner in forum AutoLISP
    Replies: 7
    Last Post: 2006-03-03, 10:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •