Is there a way to reset (initialize - clear) the undo queue using autolisp?

Is there a way to reset (initialize - clear) the undo queue using autolisp?

GeryKnee
Advocate Advocate
807 Views
9 Replies
Message 1 of 10

Is there a way to reset (initialize - clear) the undo queue using autolisp?

GeryKnee
Advocate
Advocate

Hello everybody

Is there a way to reset (initialize - clear)  the undo queue using autolisp?

The goal is to ignore (_u :: "nothing to audo")  any changes to the drawing up to the present moment.

0 Likes
Accepted solutions (1)
808 Views
9 Replies
Replies (9)
Message 2 of 10

Sea-Haven
Mentor
Mentor

If you look into the help there are many settings for undo, one is using lisp is UNDOMARK.

 

(vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))

(vla-endundomark adoc)

If you do undo it will go back to the mark point.

 

AutoCAD 2024 Help | UNDO (Command) | Autodesk

0 Likes
Message 3 of 10

GeryKnee
Advocate
Advocate

 

 


;-----------------------------
(defun c:ClearUndoQueue nil
(vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
(vla-endundomark adoc)
(princ)
)

 

 

 

 


Command:
Command:
Command: _pline
Specify start point:
Current line-width is 0.000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Command:
Command:
Command: _circle Specify center point for circle or [3P/2P/Ttr (tan tan
radius)]:
Specify radius of circle or [Diameter]:
Command: ClearUndoQueue
Command:
Command: _u GROUP
Command: _u Circle GROUP
Command: _u Polyline GROUP
Command: _u PROPERTIES


instead of this , i want to see:


Command:
Command:
Command: _pline
Specify start point:
Current line-width is 0.000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Command:
Command:
Command: _circle Specify center point for circle or [3P/2P/Ttr (tan tan
radius)]:
Specify radius of circle or [Diameter]:
Command: ClearUndoQueue
Command:
Command: _u Nothing to undo
Command: _u Nothing to undo
Command: _u Nothing to undo
Command: _u Nothing to undo
Command: _u Nothing to undo
Command: _u Nothing to undo
Command: _u Nothing to undo
Command: _u Nothing to undo
Command: _u Nothing to undo

 

0 Likes
Message 4 of 10

Sea-Haven
Mentor
Mentor

The defun you made just starts and stops the undo, you need to take each line seperately put startmark at start of code and endmark at end of code.

 

Not sure if that is what you want.

0 Likes
Message 5 of 10

GeryKnee
Advocate
Advocate

I see than cannot forget the undo history ( cannot protect a drawing created untill a moment the user wants to stop going back)

 

0 Likes
Message 6 of 10

Moshe-A
Mentor
Mentor
Accepted solution

@GeryKnee  hi,

 


@GeryKnee wrote:

I see than cannot forget the undo history ( cannot protect a drawing created untill a moment the user wants to stop going back)

 


yes you can 😀

 

explore UNDO command options

 

undo control none

 

Moshe

 

Message 7 of 10

Kent1Cooper
Consultant
Consultant

This is what I use:

;; DumpUndoHistory.lsp
(defun C:DUH ()
  (setvar 'cmdecho 0)
  (command "_.undo" "_control" "_none" "_.undo" "")
  (setvar 'cmdecho 1)
  (prompt "\nDumped Undo History.")
  (princ)
)
Kent Cooper, AIA
Message 8 of 10

GeryKnee
Advocate
Advocate

Thank you Sir

Message 9 of 10

john.uhden
Mentor
Mentor

@GeryKnee ,

I doubt that there is any way to do that programmatically, but you could SAVE or SAVEAS the drawing and then reopen it.

John F. Uhden

0 Likes
Message 10 of 10

GeryKnee
Advocate
Advocate

Dear John, hello.

Thank you for your time and interest.

But as you see , I have informed the forun , the solution has been provided by kent1Kooper.

The function works.

Sincearly,
Gery

0 Likes