November 23, 2014

ACA 2015: Cannot invoke (command) from *error* without...

Several people in the Autodesk AutoCAD® Architecture General Discussion Group have experienced problems when trying to run AutoLISP routines in which an error condition is encountered. Instead of the usual, often helpful, error message at the Command: line, this error shows up, instead:
Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).

This appears to happen even when the first thing you do in a drawing is evaluate a LISP expression with an error, for example, by typing (alert 1) at the Command: prompt and then pressing ENTER.

If you were hoping for a more informative error message, so you could try to work out what went wrong, you will want to reset the initial definition of the *error* function to what it should be:
(defun *error* (msg) (princ "error: ") (princ msg) (princ))

One way to get this code loaded into every drawing you open would be to include it in your ACADDOC.lsp file (if you have one; if not, you can create one). This file needs to be somewhere in the AutoCAD Search path (and be the first on of that name found); if your firm has a standard ACADDOC.lsp file and you do not have rights to edit it, you may want to discuss having this code added to it with your CAD Manager. You will also want to have the folder in which the ACADDOC.lsp is placed be designated as a Trusted Path (Files tab of Options dialog) if you have SECURELOAD set to 1 to avoid the nag dialog about loading it. If SECURELOAD is set to 2, you have to have the ACADDOC.lsp file in a Trusted Path folder, or the file will not load at all.

There are other ways to get this code loaded with each file, if using ACADDOC.lsp does not work for your situation. The easiest would be to open Notepad and paste the code above into it, then save the file with a name of your choosing and a LSP extension, again, to a folder that has been designated as a Trusted Path. Then add that file to your Startup Suite in the Load/Unload Applications dialog (APPLOAD command).

I am not sure why the *error* function is not properly initialized, but running the above code when opening a drawing or creating a new drawing will resolve this issue and give you the expected error messages.

No comments: