(command-s) in error routine

(command-s) in error routine

Anonymous
Not applicable
1,027 Views
6 Replies
Message 1 of 7

(command-s) in error routine

Anonymous
Not applicable

Hell together

 

I changed my lisp error routines for AutoCAD 2015.

I replaced command into command-s.

By OPENDCL routines offers (*push-error-using-command*) no solution.

 

 

(defun myerr (ed)


  (if (and (/= ed "Function cancelled") (/= ed "quit / exit abort"))
    (princ (strcat "\nError: " ed)) 
  )
  (command-s)
  (command-s)
  (if (= (logand (getvar "UNDOCTL") 8) 8)
    (progn
      (command-s "_.UNDO" "_E")
      (command-s "_.U")
    )
  )
  (command-s "_.UNDO" "_A" "_ON")
  (setq *error* olderr)
  (princ)
)

 

But I note that the call (command-s) does not cancelled an open AutoCAD command.

(command) this has worked.

 

How can I stop a possiple open AutoCAD command in an error routine to continue

for example with "_UNDO" command

 

Many thanks! 

 

 

 

 

 

0 Likes
1,028 Views
6 Replies
Replies (6)
Message 2 of 7

marko_ribar
Advisor
Advisor

Just a thought... Have you tried to replace 2 lines of (command-s) with :

 

(while (> (getvar 'cmdactive) 0) (command-s ""))

 

HTH, Marko

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... the call (command-s) does not cancelled an open AutoCAD command.

(command) this has worked.

.... 


Guessing here, since I'm not at my ACAD2015 location, but in addition to marko_ribar's suggestion of using (command-s ""), you might also try (command-s nil).  I can imagine that "" [Enter] might possibly do something you don't really want if there's been an error, in certain odd-ball circumstances [accept some default value inappropriately, complete the command in a way that doesn't have complete input, or some such thing].

Kent Cooper, AIA
0 Likes
Message 4 of 7

Anonymous
Not applicable

Hello,

 

unfortunatelly an open AutoCAD command, example trim doesn't accept the instructions

 

(command-s nil)

(command-s "")

(command-s "nil")

 

Somebody still has a different solution?

 

Greetings

 

0 Likes
Message 5 of 7

marko_ribar
Advisor
Advisor

I would write error handler differently...

 

(defun myerr ( ed )
  (if (and ed (/= ed "Function cancelled") (/= ed "quit / exit abort"))
    (progn
      (if (= (logand (getvar "UNDOCTL") 8) 8)
        (progn
          (command-s "_.UNDO" "_E")
          (command-s "_.U")
        )
      )
      (command-s "_.UNDO" "_A" "_ON")
    )
  )
  (if ed (princ (strcat "\nError: " ed)))
  (setq *error* olderr)
  (princ)
)

 M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 6 of 7

dbroad
Mentor
Mentor

 

In reading the documentation for command-s, it is not allowed to be used interactively.  Each instance of (command-s <....>) would send a non-interactive command to autocad.  I would imagine that if a command was already in progress, that it might cause an error or be ignored.  The documentation recommends that if you need to use command in an error handler, such as for the purpose of cancelling a command in progress, that you use (*push-error-using-command*)

 

Example:

(defun c:test ( / *error*)

(defun *error* (msg)
 (princ msg)
(if (> (getvar "cmdactive") 0)
  (progn (command)(command))
)
(princ)
)
(*push-error-using-command*)

(command "line" "0,0")
(command-s "2,2") ;;this is an error
(command "3,3")
)

 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 7 of 7

Anonymous
Not applicable

Yes, I use intermittent (*push-error-using-command*) at the programme start and (*pop-error-mode*) on the end.

 

But for my programmes with OpenDCL dialogs the (*push-error-using-command*) statement is ineffective.

So I use the (command ".... )  function only outside an event and with a full valid parameter row and no interaktiv.

 

Thanks

 

0 Likes