|
![]() |
This is not a function in the usual sense. Rather, it is a undefined, reserved symbol. When you define it, it takes the place of the built-in error routine.
When *error* is not defined, and AutoLISP encounters an error, the built-in error routine takes over and does two things: (1) it displays "error:" then an appropriate error message, and (2) it dumps the offending program code to the screen to help you figure out how to fix the program.
When you define *error*, then that new error routine (1) determines what to do when an error occurs including what messages (if any) it displays, and (2) does not dump any code to screen. The built-in error routine will send your error routine a string, so your error routine must have one variable in its variable list to receive that string. What your error routine does with that string is up to you.
For example, consider the following possible definition of *error*:
(defun *error* (str)
(princ "---ERROR---")
(cond
((= str "divide by zero") (princ "Cannot divide by zero"))
((= str "null function") (princ "Function not defined,
not loaded, or misspelled"))
(1 (princ str))
)
(princ)
)
When an error occurs, AutoLISP calls this function instead of its usual
error routine, and passes an appropriate error message string to it, but
does not dump any code to screen.
(ver) returns the string "AutoLISP Release 14.0 (en)" assuming
you are using Release 14 in the English language.
(startapp "explorer") starts the Windows explorer
After (setq ap "notepad" fi "bom.txt")
(startapp ap fi) starts the Windows Notepad and opens or creates
the file BOM.TXT
(alert "Diameter larger than needed") Places the message "Diameter
... " in a dialog box with an "OK" button which the user must click before
proceeding.
(help "acad") displays the default AutoCAD help utility
(help) same as above
(help "acad" "arc") displays help on the ARC command
Compare setfunhelp below.
(setfunhelp "c:mslot" "acad" "mslot") Establishes context sensitive
help so that, if the user is running the "c:mslot" AutoLISP command and
presses F1, the AutoCAD help utility will access the "acad" help file ("acad.hlp"),
and display the section on "mslot". Requires modification of the
help file with software designed for WinHelp files such as the Microsoft
Help Workshop. Compare help above.
(atoms-family 0) returns a list of all currently defined symbols,
as symbols
(atoms-family 1) returns a list of all currently defined symbols,
as strings
When you want to get a report on just certain symbols, an optional second argument can be supplied consisting of a list including one or more symbol names as strings. In this case atoms-family returns a list which includes, for each symbol in the supplied list, its name if it is defined, or nil if it is not defined.
(atoms-family 1 (list "func8" "func9" "sqrt"))
would return ("FUNC8" nil "SQRT") if func8 were a user-defined
function, and func9 were not defined. Of course, sqrt is a built-in
function, so its name is also returned.
(atoms-family 0 (list "func8" "func9" "sqrt"))
would return (FUNC8 nil SQRT) for the same reasons as above.
(quote a) returns A (the symbol A as opposed to the value assigned
to A)
'a returns the same as the above
'(* p q) returns (* p q)
(eval 5.0) returns 5.0
(eval (+ 2 6)) returns 8
After (setq a 12.7 b 'a)
(eval a) returns 12.7
(eval 'b) returns A
(eval b) returns 12.7
(read "Once") returns ONCE
(read "(Once upon a time)") returns (ONCE UPON A TIME)
(read "(Once every 34.56 minutes)") returns (ONCE EVERY 34.56
MINUTES)
(getenv "WINDIR") might return something like "C:\\WINDOWS" in
Windows 95
(getenv "ACAD") returns the set of folders which makes up the
search path as listed under Preferences, Files tab, Support file search
path
(getenv "PATH") returns the AutoCAD search path along with the
operating system path
(grread) returns a list of coded input information with the first element of the list indicating the source of the input, such as:
(2 66) -- letter B (upper case) from
keyboard
(3 (6.5 3.25 0.0)) -- coordinates of
point selected with pointer
(4 8) -- 9th box of screen menu selected
(numbers start at 0)
(11 0) -- right mouse button pressed
(numbers start at 0 after the pick button)
(grread 1) might return:
(5 (4.375886 3.998572)) -- drag coordinates of pointer. The optional first argument (1) enables tracking.
(grread nil 4 2) enables a "pickbox" type cursor until a point
is picked, at which time a code 3 list is returned as illustrated above.
The second argument enables a cursor type change, and the third argument
determines the type of cursor.
(grtext) may restore graphics text areas to their normal text
(grtext 0 "ELEPHANT") prints "ELEPHANT" in the first box (cell)
of the screen menu area. The first argument determines the box number,
starting at zero for the first box. The number of screen boxes available
varies with the size of the AutoCAD window, and can be retrieved from system
variable SCREENBOXES.
(grtext -1 "TUSKS") prints "TUSKS" in the mode-status line (same
effect as setting system variable MODEMACRO).
(grdraw (list 2 2) (list 4 4) 5) draws a vector from 2,2 to 4,4
in color 5 (blue)
After (setq p1 (list 5 0) p2 (list 0 5))
(grdraw p1 p2 3 1) draws a vector from 5,0 to 0,5 in color 3
(green), highlighted
(grvecs (list 1 (list 2 2) (list 4 2) 3 (list 4 2) (list 4 4) 5 (list
4 4) (list 2 4) 6 (list 2 4) (list 2 2))) draws four vectors as follows:
from 2,2 to 4,2 in color 1 (red)
from 4,2 to 4,4 in color 3 (green)
from 4,4 to 2,4 in color 5 (blue)
from 2,4 to 2,2 in color 6 (magenta)
The list must contain an even number of pairs of point lists.
The color numbers preceding each pair of point lists are optional.