Defines a function
(defun sym ([arguments] [/ variables...]) expr...)
If you do not declare any arguments or local symbols, you must supply an empty set of parentheses after the function name.
If duplicate argument or symbol names are specified, AutoLISP uses the first occurrence of each name and ignores the following occurrences.
The result of the last expression evaluated.
WarningNever use the name of a built-in function
or symbol for the sym argument to defun. This overwrites
the original definition and makes the built-in function or symbol
inaccessible. To get a list of built-in and previously defined functions,
use the atoms-family function.
(defun myfunc (x y) ...) Function takes two arguments
(defun myfunc (/ a b) ...) Function has two local variables
(defun myfunc (x / temp) ...) One argument, one local variable
(defun myfunc () ...) No arguments or local variables
See Also
-
The
Symbol and Function Handling topic in the AutoLISP Developer's Guide.