UNDO mark not working correctly in lisp???

UNDO mark not working correctly in lisp???

DC-MWA
Collaborator Collaborator
1,701 Views
6 Replies
Message 1 of 7

UNDO mark not working correctly in lisp???

DC-MWA
Collaborator
Collaborator

Hi all,

I have a little routine we use for demolition work.

I'm trying to get it to have an undo group, so we can undo all activity from lisp with one undo.

Can't seem to figure out why it will not work??? Works great with other programs.

See attached...

0 Likes
Accepted solutions (1)
1,702 Views
6 Replies
Replies (6)
Message 2 of 7

dlanorh
Advisor
Advisor
Accepted solution
The error routine is not localised and so replaces the Autocad error routine for that session. There is also no undo end in the error routine to ensure a clean finish and a complete undo start-end. Any error will exit and leave the undo open

I am not one of the robots you're looking for

Message 3 of 7

scot-65
Advisor
Advisor
I gave up on command UNDO a while back.
I think it was finally fixed to now continue skipping over commands -
all the way back to "begin".

Anyhow, I now use the following and do not have any problems.
(defun c:BlaBlaBla ()
(vl-load-com)
(vla-StartUndoMark (setq *DOC* (vla-get-ActiveDocument (vlax-get-acad-object))))
...
(vla-EndUndoMark *DOC*)
(princ)
);end defun

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 4 of 7

dlanorh
Advisor
Advisor
Don't forget , if you are using 2016 or higher, you can't use command calls in an error routine. Use command-s or switch to activex.

I am not one of the robots you're looking for

0 Likes
Message 5 of 7

DC-MWA
Collaborator
Collaborator

Thank you. I am going to try this on  a couple routines I have. It seems to work well from my brief testing this morning.

0 Likes
Message 6 of 7

scot-65
Advisor
Advisor
Briefly looking at your code, and not getting fully involved,
there are a few pointers I wish to pass along.

1) Don't mess with user settings! Crosshair coloring and pickbox size
should be left alone; among other things (including OSNAP). It becomes
annoying to the user up to the point where the utility will be ignored
all together in the future. Bling only impedes workflow.

2) Gather user input before making system changes.

3) Test user input before going into the "main program".
You have an entsel that will not allow the user to exit by
right-click or [Enter]. If so, the program continues on sans
the entsel...

a) Gather user input (including DCL).
b) Test user input.
c) Set environment.
d) Execute utility. Note: No additional user input allowed here; not even "pause".
e) Reset environment.
f) Program ends - No error handler required.

Wrap the above with vla- undo markers.

By following the above structure, no error handler is required.
98% of my 180+ library does not have nor does it require any
error handlers.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 7 of 7

DC-MWA
Collaborator
Collaborator

thank you. I got a little excited about programming... went a little over board with the flashy bs.. agreed.

0 Likes