Undo Begin and End.

Undo Begin and End.

mdhutchinson
Advisor Advisor
2,361 Views
6 Replies
Message 1 of 7

Undo Begin and End.

mdhutchinson
Advisor
Advisor
I am writting a large application in Vlisp.
I am using "undo" "mark" "back" extensively for my
"Cancel" buttons. If the user "Cancels" then the undo features of my app undoes what the application did to
the drawing in the mean time.
However, I would like to use "Begin and "End"
I understand that this makes a "U" undo all the actions
that were done between the "Begin" and the "End" switches
undo as if they were done by a single opperation.
Trouble is I cannot seem to get it to do this.
I want to allow the user, once he closes my application
to do "U" to simple undo all the actions that were done
the last time the application was running.
Thoughts?
0 Likes
2,362 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Use:

(defun c:test ( / )

(command "UNDO" "BEGIN")

<<your lisp goes here>>

(command "UNDO" "END")

) ; end defun

 

The command undo will undo the application above, or use (command "UNDO"
1)

Works for me.
--
Jeroen Berkers
A2k - W98SE


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
am writting a large application in Vlisp.
I am using "undo" "mark" "back"
extensively for my
"Cancel" buttons. If the user "Cancels" then the undo
features of my app undoes what the application did to
the drawing in the
mean time.
However, I would like to use "Begin and "End"
I understand
that this makes a "U" undo all the actions
that were done between the
"Begin" and the "End" switches
undo as if they were done by a single
opperation.
Trouble is I cannot seem to get it to do this.
I want to
allow the user, once he closes my application
to do "U" to simple undo all
the actions that were done
the last time the application was running.

Thoughts?
0 Likes
Message 3 of 7

Anonymous
Not applicable
hutch,

You might want try these.

;by John Uhden
(setq *acad* (vlax-get-acad-object))
(defun UndoBegin ()
(vla-StartUndoMark (vla-get-activedocument *acad*))
)
(defun UndoEnd ()
(vla-EndUndoMark (vla-get-activedocument *acad*))
)

They avoid an annoying problem with command versions. If objects are
selected before the program runs, (command "undo" "begin") will deselect.

Joe Burke

---------------------------------------------------------------
"hutch" wrote in message
news:f178bc0.-1@WebX.maYIadrTaRb...
I am writting a large application in Vlisp.
I am using "undo" "mark" "back" extensively for my
"Cancel" buttons. If the user "Cancels" then the undo features of my app
undoes what the application did to
the drawing in the mean time.
However, I would like to use "Begin and "End"
I understand that this makes a "U" undo all the actions
that were done between the "Begin" and the "End" switches
undo as if they were done by a single opperation.
Trouble is I cannot seem to get it to do this.
I want to allow the user, once he closes my application
to do "U" to simple undo all the actions that were done
the last time the application was running.
Thoughts?
0 Likes
Message 4 of 7

Anonymous
Not applicable
I know I'm belated (been on vacation), but as nice as Joe is to offer a little
ActiveX answer, there is a documented limitation...
You can't use Undo/Marks/Backs in the middle of an Undo/Begin/End sequence,
ActiveX or otherwise. They're just plain ignored. For that VEDIT thingy I
offered in the LDT NG, I actually had to store each edit in memory to be able to
provide both incremental and global Undos. Yes... a very large PITA.

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ


"hutch" wrote in message
news:f178bc0.-1@WebX.maYIadrTaRb...
> I am writting a large application in Vlisp.
> I am using "undo" "mark" "back" extensively for my
> "Cancel" buttons. If the user "Cancels" then the undo features of my app
undoes what the application did to
> the drawing in the mean time.
> However, I would like to use "Begin and "End"
> I understand that this makes a "U" undo all the actions
> that were done between the "Begin" and the "End" switches
> undo as if they were done by a single opperation.
> Trouble is I cannot seem to get it to do this.
> I want to allow the user, once he closes my application
> to do "U" to simple undo all the actions that were done
> the last time the application was running.
> Thoughts?
0 Likes
Message 5 of 7

Anonymous
Not applicable
Hi John,

That's interesting and good to know. But I think the question was how to use
Undo/Begin/End in lieu of Undo/Marks/Backs. Or maybe I'm misreading it.

Joe Burke

"John Uhden" wrote in message
news:F739C0B419E7D6FC8A7948030B318587@in.WebX.maYIadrTaRb...
> I know I'm belated (been on vacation), but as nice as Joe is to offer a
little
> ActiveX answer, there is a documented limitation...
> You can't use Undo/Marks/Backs in the middle of an Undo/Begin/End
sequence,
> ActiveX or otherwise. They're just plain ignored. For that VEDIT thingy
I
> offered in the LDT NG, I actually had to store each edit in memory to be
able to
> provide both incremental and global Undos. Yes... a very large PITA.
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> http://www.cadlantic.com
> Sea Girt, NJ
>
>
> "hutch" wrote in message
> news:f178bc0.-1@WebX.maYIadrTaRb...
> > I am writting a large application in Vlisp.
> > I am using "undo" "mark" "back" extensively for my
> > "Cancel" buttons. If the user "Cancels" then the undo features of my app
> undoes what the application did to
> > the drawing in the mean time.
> > However, I would like to use "Begin and "End"
> > I understand that this makes a "U" undo all the actions
> > that were done between the "Begin" and the "End" switches
> > undo as if they were done by a single opperation.
> > Trouble is I cannot seem to get it to do this.
> > I want to allow the user, once he closes my application
> > to do "U" to simple undo all the actions that were done
> > the last time the application was running.
> > Thoughts?
>
0 Likes
Message 6 of 7

Anonymous
Not applicable
Autodesk's undo- & error-handlers provided with ACAD.MNL do a very good job
for me (I only needed to add (command "_.UNDO" "_E") in the body of
*MERRMSG*). I have a renamed copy of it, which loads together with my
CUSTOM.MNS & I have it working.

My commands now look like this:

(defun C:SAMPLE (/ ...)
(setq M:ERR *ERROR* *ERROR* *MERRMSG*)
(ai_undo_push)
...
(ai_sysvar '(... ... ...))
...
all my stuff goes here
...
(ai_sysvar nil)
(ai_undo_pop)
(setq *ERROR* M:ERR M:ERR nil)
(princ)
)

If I need to have actions undone inside the command body depending on user
input or because of a pre-designed sequence of actions (e.g. to insert
temporarily some file for preview & then to remove it when the user is ready
to continue), I enclose that part of the code in a (command "_.UNDO" "_M")
... (command "_.UNDO" "_B").

If the user hits or cancels a dialog, or there is an (exit) statement
in the code whatsoever, a single "U" is enough to restore AutoCAD to its
state before the command was invoked. And this is true also if the break
appeared in-between (command "_.UNDO" "_M") ... (command "_.UNDO" "_B").

Of course, you need to mind your considerations where to put error- &
undo-handlers. I put them only in the (defun C:...) & never in the lower
level functions that C:... relies on. I also don't have cross-calls betwen
C:..s - if I need such, I define just a new stub C:... command, put the
undo- & error-handling there & keep the commonly referenced part as a lower
level function. Also, don't forget that you cannot have nested
"UNDO"-"BE"s...

Spend some time studying that part of ACAD.MNL. To me that was very useful.
Hope this helps you.

Cheers,
Andrey
0 Likes
Message 7 of 7

Anonymous
Not applicable
Don't use Marks.

Search this ng for the reasons.


--
R. Robert Bell, MCSE
www.AcadX.com


"Andrey Marinov" wrote in message
news:8563DCEAA24952EA14B1915CE8D3E651@in.WebX.maYIadrTaRb...
| If I need to have actions undone inside the command body depending on user
| input or because of a pre-designed sequence of actions (e.g. to insert
| temporarily some file for preview & then to remove it when the user is
ready
| to continue), I enclose that part of the code in a (command "_.UNDO" "_M")
| ... (command "_.UNDO" "_B").
|
| If the user hits or cancels a dialog, or there is an (exit)
statement
| in the code whatsoever, a single "U" is enough to restore AutoCAD to its
| state before the command was invoked. And this is true also if the break
| appeared in-between (command "_.UNDO" "_M") ... (command "_.UNDO" "_B").
|
0 Likes