Undo begin and Undo End not getting trapped in error routine

Undo begin and Undo End not getting trapped in error routine

brbowen
Contributor Contributor
612 Views
6 Replies
Message 1 of 7

Undo begin and Undo End not getting trapped in error routine

brbowen
Contributor
Contributor

In my Startup routine I have the following code.

This is what I currently use  and "._undo" "_begin" does not make any difference.

(command "._undo" "_group") 

 

In my ending routine I have the following code:

(command "._UNDO" "_END")

 

If there is no error, everything works as it should.

When there is an error, such as hitting the esc key during the program execution, it displays the error below:

Command: _COPE

Inside Radius <0.25>: *Cancel*

error: Function cancelled

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

Converting (command) calls to (command-s) is recommended.

 

This is what I get when I comment out this one line of code ;; (command "._UNDO" "_END") in my ending routine and then press the esc key during the program execution.

Command: _COPE

Inside Radius <0.25>: *Cancel*

error: Function cancelled

 

Any suggestions?

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

paullimapa
Mentor
Mentor

Try this instead of group

(command "._undo" "_mark") 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@brbowen wrote:

....

In my ending routine I have the following code:

(command "._UNDO" "_END")

....

error: Function cancelled

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

Converting (command) calls to (command-s) is recommended.

....


The simplest thing is to just do what they recommend:

 

(command-s "._UNDO" "_END")

 

There's a  (vla-...  way to go about beginning & ending Undo that gets around that by not using  (command)  for the purpose, but the simple edit should do it for you.

Kent Cooper, AIA
0 Likes
Message 4 of 7

brbowen
Contributor
Contributor
Amazing how you can overlook the obivous, when it is right there in front of you!
0 Likes
Message 5 of 7

paullimapa
Mentor
Mentor

if you're curious, here's the vla version:

(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
and
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 7

brbowen
Contributor
Contributor
Great, thanks.
0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

@paullimapa wrote:

if you're curious, here's the vla version:

(vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
and
(vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))

The way I usually do that is, at the beginning:

 

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

 

Then, both at the end of the routine and inside the *error* handler, all I need is:

 

(vla-endundomark doc)

 

And I include doc in the localized variables list.

Kent Cooper, AIA