sivapathasunderam Posted April 22, 2021 Posted April 22, 2021 1.) Is this a typical error function ? 2.) How this works? (when there is error on my code, this will break the program correct) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (prompt (strcat "\nError: " errmsg)) ); if 3.) Can i add this to my lisps, if required when it's required to update further . . . Quote
mhupp Posted April 22, 2021 Posted April 22, 2021 (edited) 1. Yes 2. If the error contains any of the following in the wcwatch it will not display the error message that is all. if its a different error it will display that error. The lisp has already stopped due to the error. Example: type ZE command Autocad zoom extents and waits for object selection. *hit esc key* error: Function Cancled 3. Yes just add it before or after your code. more details here or here This is my zoom Extents macro it has a second "command" to zoom to object if i select anything but usually just hit esc and dont want to see an error when i do. ;;------------------------------------------------------------------------------------------------------------;; ;; Zoom Extents Then Zoom to object if needed (defun C:ZE (/ SS *error*) (defun *error* (errmsg) (if (not (member errmsg '( "Console Break" "Function cancelled"))) (princ (strcat "\nError: " errmsg)) ) ) (vl-cmdf "_.Zoom" "E") (if (setq SS (ssget)) (progn (vl-cmdf "_.Zoom" "OB" SS "") (vl-cmdf "_.Zoom" "0.95x") ) ) ) Edited April 23, 2021 by mhupp 1 Quote
Lee Mac Posted April 22, 2021 Posted April 22, 2021 A minor point, but always be sure to declare the redefined *error* symbol as local to the function (i.e. within the list of local arguments & variables), so that the scope of the redefinition is limited to the function in which it is redefined; without this declaration, you are redefining the error function globally and therefore affecting all other AutoLISP functions defined within the active document namespace. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.