UCS Follow

UCS Follow

C.Utzinger
Collaborator Collaborator
1,102 Views
6 Replies
Message 1 of 7

UCS Follow

C.Utzinger
Collaborator
Collaborator

Hello

 

Is there a possibility to turn back "ucsfollow" automatically to 0 in case of cancelling the Routine by user (ESC ESC ESC...) 🙂 ?

 

 

 

(defun c:<BKSDrehen()
	(command "bksymbol" "au")
	(setvar "ucsfollow" 1)
	(princ "\nUCSFOLLLOW = 1")
	(princ "\nAusrichtung wählen: ")
	(command "_ucs" "_z" pause pause)
	(setvar "ucsfollow" 0)
	(princ "\nUCSFOLLOW = 0")
	(prin1)
) ; end of defun

 

Thank you...

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

krzysztof.psujek
Advocate
Advocate

Hi,

off course there is a possibility to bring back old variables setting during error.

You need read about error handling

for example this:

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-trapping/td-p/4886888

 

http://www.afralisp.net/autolisp/tutorials/error-trapping.php

http://www.lee-mac.com/errorhandling.html

 

 

Chris

0 Likes
Message 3 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

The code or an error could be the same... add what you want to reset in case of error.

 

(defun c:<BKSDrehen (/ *error*)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg)))
    (setvar "ucsfollow" 0)
    (princ "\nUCSFOLLOW = 0")
    (princ))
  
  (command "bksymbol" "au")
  (setvar "ucsfollow" 1)
  (princ "\nUCSFOLLLOW = 1")
  (princ "\nAusrichtung wählen: ")
  (command "_ucs" "_z" pause pause)
  (setvar "ucsfollow" 0)
  (princ "\nUCSFOLLOW = 0")
  (prin1)
  ) ; end of defun
Message 4 of 7

C.Utzinger
Collaborator
Collaborator

Thank you very much!!!

 

I just fixed a little error. There was one ")" to much.  

 

 

(defun c:<BKSDrehen (/ *error*)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    (setvar "ucsfollow" 0)
    (princ "\nUCSFOLLOW = 0")
    (princ))
  
  (command "bksymbol" "au")
  (setvar "ucsfollow" 1)
  (princ "\nUCSFOLLLOW = 1")
  (princ "\nAusrichtung wählen: ")
  (command "_ucs" "_z" pause pause)
  (setvar "ucsfollow" 0)
  (princ "\nUCSFOLLOW = 0")
  (prin1)
  ) ; end of defun
0 Likes
Message 5 of 7

ВeekeeCZ
Consultant
Consultant

@c.utzinger wrote:

Thank you very much!!!

 

I just fixed a little error. There was one ")" to much.  

 

 


It's good that you're thinking about it! Unfortunately in this case -- it was good as it was.

Message 6 of 7

C.Utzinger
Collaborator
Collaborator

Ups

 

You are wright. My fault! I had an error!!!

 

Thank you very much

0 Likes
Message 7 of 7

C.Utzinger
Collaborator
Collaborator

How can i delete the wrong solution?

0 Likes