|This article needs additional citations for verification. (February 2012)|
AutoLISP is a dialect of Lisp programming language built specifically for use with the full version of AutoCAD and its derivatives, which include AutoCAD Map 3D, AutoCAD Architecture and AutoCAD Mechanical. Neither the application programming interface nor the interpreter to execute AutoLISP code are included in the AutoCAD LT product line.
AutoLISP is a small, dynamically scoped, dynamically typed LISP dialect with garbage collection, immutable list structure and settable symbols, lacking in such regular LISP features as macro system, records definition facilities, arrays, functions with variable number of arguments or let bindings. Aside from the core language, most of the primitive functions are for geometry, accessing AutoCAD's internal DWG database, or manipulation of graphical entities in AutoCAD. The properties of these graphical entities are revealed to AutoLISP as association lists in which values are paired with AutoCAD "group codes" that indicate properties such as definitional points, radii, colors, layers, linetypes, etc. AutoCAD loads AutoLISP code from .LSP files.
AutoLISP code can interact with the user through Autocad's graphical editor by use of primitive functions that allow user to pick points, choose objects on screen, input numbers and other data. AutoLisp also has a built-in GUI mini-language, the Dialog Control Language, for creating modal dialog boxes with automated layout, within AutoCAD.
AutoLISP was derived from an early version of XLISP, which was created by David Betz. The language was introduced in AutoCAD Version 2.18 in January 1986, and continued to be enhanced in successive releases up to Release 13 in February 1995. After that, its development was neglected by Autodesk in favor of more fashionable development environments like VBA, .NET and ObjectARX. However, it has remained AutoCAD's primary user customization language.
Vital-LISP, a considerably enhanced version of AutoLISP including an IDE, debugger and compiler, and ActiveX support, was developed and sold by third party developer Basis Software. Vital LISP was a superset of the existing AutoLISP language that added VBA-like access to the AutoCAD object model, reactors (event handling for AutoCAD objects), general ActiveX support, and some other general Lisp functions. Autodesk purchased this, renamed it Visual LISP, and briefly sold it as an add-on to AutoCAD 14 released in May 1997. It was incorporated into AutoCAD 2000 released in March 1999, as a replacement for AutoLISP. Since then Autodesk has chosen to halt major enhancements to Visual LISP in favor of focusing more effort on VBA and .NET and C++. In 2010 Autodesk informed users that VBA will no longer be enhanced.
AutoLISP has such a strong following that other CAD application vendors add it to their own products. FelixCAD, Bricscad, IntelliCAD and others have AutoLISP functionality, so that AutoLISP users can consider using them as an alternative to AutoCAD. Most development involving AutoLISP since AutoCAD 2000 is actually performed within Visual LISP since the original AutoLISP engine was replaced with the Visual LISP engine. There are thousands of utilities and applications that have been developed using AutoLISP or Visual LISP (distributed as LSP, FAS and VLX files).
;Tip1556: TR.LSP Text Rotate (C)1999, William E. Barlow, M.S. P.E. (Civil Engineer; OR,WA,CA) ;Published in Cadalyst Magazine September 1999 issue in the Hot Tip Harry Section ;http://cadtips.cadalyst.com/node/tiplisting?keywords=Tip1556 ; This LISP routine allows the user to select a line (Not a pline) ; and then select text (Not MText) and then text rotates to the ; angle of the line (defun C:TR () ; C: means execute routine a command prompt (setvar "CMDECHO" 0) ; set the variable CMDECHO to 0 (prompt "\nSelect Line: ") ; select object line (setq LINE (ssget)) ; get selection set of line (setq INDEX 0) ; establish an index (setq ENAME (ssname LINE INDEX)) ; give a name to the line (setq ELIST (entget ENAME)) ; create a list (setq PT1 (cdr (assoc 10 ELIST))) ; get end pt1 x,y,z values from set (setq VALUE11 (car PT1)) ; get x coordinate pt1 (setq VALUE12 (cadr PT1)) ; get y coordinate pt1 (setq VALUE13 (caddr PT1)) ; get z coordinate pt1 (setq PT2 (cdr (assoc 11 ELIST))) ; get end pt2 x,y,z values (setq VALUE21 (car PT2)) ; get x coordinate pt2 (setq VALUE22 (cadr PT2)) ; get y coordinate pt2 (setq VALUE23 (caddr PT2)) ; get z coordinate pt2 (setq LANGLE (angle PT1 PT2)) ; get angle of selected lline (setq P12 (/ pi 2.0)) ; do calcs (setq P32 (* pi 1.5)) (setq P2 (* pi 2.)) (if (and (>= LANGLE 0.0) (<= LANGLE P12)) (setq NARCTAN LANGLE)) (if (and (>= LANGLE P32) (<= LANGLE P2)) (setq NARCTAN LANGLE)) (if (and (>= LANGLE P12) (<= LANGLE pi)) (setq NARCTAN (+ LANGLE pi))) (if (and (>= LANGLE pi) (<= LANGLE P32)) (setq NARCTAN (- LANGLE pi))) (prompt "\nSelect Text: ") ; select object text (setq TEXTL (entget (car (entsel)))) ; get selection set of text (setq OTEXT (assoc 50 TEXTL)) ; get value from set (setq NTEXT (cons 50 NARCTAN)) ; concatentate (setq TEXTL (subst NTEXT OTEXT TEXTL)) (entmod TEXTL)) ; Modify the definition data of an object (entity)