Jump to content

AutoLisp Error Handling - Command in Custom Error Causes Error


RonnieMoore

Recommended Posts

My error trapper crashes when (command "layer"...) is run. The following is returned. ; error: An error has occurred inside the *error* functionFunction

 

The error trapper works fine when (command "layer"...) is not included.

 

;====================== Error Trapper
(defun MyExit (msg)
 (command "-layer" "off" "ToolTracker" "")
 (close file)
 (setvar "highlight" 1)
 (setvar "cmdecho" 1)
 (alert "Tool Tracker Stopped")
 (princ)
)

Edited by RonnieMoore
Link to comment
Share on other sites

Is this error handler localized within your main routine?

 

Where are you restoring the default error handler, as your error handler is not doing so?

 

So that we might be able to better assist you, please post the rest of your code, as more information is needed.

 

Cheers

Link to comment
Share on other sites

Is this error handler localized within your main routine? No

 

(defun C:TrackToolRT (/ *error*)
 (setq *error* MyExit)

... rest of main code

 (MyExit nil)
)

Edited by RonnieMoore
Link to comment
Share on other sites

Is the error handler being used in conjunction with a reactor callback function?

 

Also:

 

  • It would be better to ensure that the file symbol is correctly defined, rather than assume that it points to a file descriptor.

 

  • System variables should be reset to their original values, not the values that you choose.

(defun myexit ( msg / ent )
   (if
       (and
           (setq ent (tblobjname "layer" "ToolTracker"))
           (setq ent (entget ent))
       )
       (entmod (subst (cons 62 (- (abs (cdr (assoc 62 ent))))) (assoc 62 ent) ent))
   )
   (if (= 'file (type file))
       (close file)
   )
   (princ)
)

Link to comment
Share on other sites

Lee Mac

 

Thanks. That method eliminates my error in my error trap. Any idea however, why the command version resulted in an error since it is suppose to accomplish the same thing?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...