| AutoLISP | |
|---|---|
| Paradigms | Multi-paradigm:functional,procedural,reflective,meta |
| Family | Lisp |
| Designed by | David Betz |
| Developers | Autodesk, Basis Software |
| First appeared | January 1986; 40 years ago (1986-01) |
| Final release | 13 / February 1995; 31 years ago (1995-02) |
| Typing discipline | dynamic |
| Scope | dynamic |
| Platform | IA-32 |
| OS | Linux |
| Dialects | |
| Vital-LISP, Visual LISP | |
| Influenced by | |
| Lisp, XLISP | |
AutoLISP is adialect of the programming languageLisp built specifically for use with the full version ofAutoCAD and its derivatives, which includeAutoCAD Civil 3D,AutoCAD Map 3D,AutoCAD Architecture andAutoCAD Mechanical.[1] Neither theapplication programming interface (API) nor theinterpreter to execute AutoLISP code is included in the AutoCAD LT product line (up to Release 2023, AutoCAD LT 2024 includes AutoLISP).[2] A subset of AutoLISP functions is included in the browser-based AutoCAD web app.
AutoLISP is a small, dynamicallyscoped, dynamically typed Lisp language dialect withgarbage collection, immutable list structure, and settable symbols, lacking in such regular Lisp features asmacro system, records definition facilities, arrays, functions with variable number of arguments and let bindings. Aside from the core language, most of the primitive functions are for geometry, accessing AutoCAD's internalDWG database, or manipulation of graphical entities in AutoCAD. The properties of these graphical entities are revealed to AutoLISP asassociation lists in which values are paired with AutoCADgroup codes that indicate properties such as definitional points, radii, colors, layers, linetypes, etc. AutoCAD loads AutoLISP code from .LSP files.[3]
AutoLISP code can interact with the user through AutoCAD's graphical editor by use of primitive functions that allow the user to pick points, choose objects on screen, and input numbers and other data. AutoLisp also has a built-ingraphical user interface (GUI) mini- ordomain-specific language (DSL), theDialog Control Language, for creating modal dialog boxes with automated layout, within AutoCAD.[3]
AutoLISP was derived from an early version ofXLISP, which was created by David Betz.[4] 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 byAutodesk in favor of more fashionable development environments likeVisual Basic for Applications (VBA),.NET Framework, andObjectARX. However, it has remained AutoCAD's main user customizing language.
Vital-LISP, a considerably enhanced version of AutoLISP including anintegrated development environment (IDE),debugger,compiler, andActiveX 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 itVisual LISP, and briefly sold it as an add-on to AutoCAD release 14 released in May 1997. It was incorporated into AutoCAD 2000 released in March 1999, as a replacement for AutoLISP. Since then,Autodesk has ceased major enhancements to Visual LISP and focused more effort on VBA and.NET, andC++. As of January 31, 2014[update], Autodesk ended support for VBA versions before 7.1, as part of a long-term process of changing from VBA to .NET for user customizing.[5][6]
AutoLISP has such a strong following that othercomputer-aided design (CAD) application vendors add it to their products.Bricscad,IntelliCAD, DraftSight 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 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).[7][8]
| 1958 | 1960 | 1965 | 1970 | 1975 | 1980 | 1985 | 1990 | 1995 | 2000 | 2005 | 2010 | 2015 | 2020 | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LISP 1, 1.5,LISP 2(abandoned) | |||||||||||||||
| Maclisp | |||||||||||||||
| Interlisp | |||||||||||||||
| MDL | |||||||||||||||
| Lisp Machine Lisp | |||||||||||||||
| Scheme | R5RS | R6RS | R7RS small | ||||||||||||
| NIL | |||||||||||||||
| ZIL (Zork Implementation Language) | |||||||||||||||
| Franz Lisp | |||||||||||||||
| muLisp | |||||||||||||||
| Common Lisp | ANSI standard | ||||||||||||||
| Le Lisp | |||||||||||||||
| MIT Scheme | |||||||||||||||
| XLISP | |||||||||||||||
| T | |||||||||||||||
| Chez Scheme | |||||||||||||||
| Emacs Lisp | |||||||||||||||
| AutoLISP | |||||||||||||||
| PicoLisp | |||||||||||||||
| Gambit | |||||||||||||||
| EuLisp | |||||||||||||||
| ISLISP | |||||||||||||||
| OpenLisp | |||||||||||||||
| PLT Scheme | Racket | ||||||||||||||
| newLISP | |||||||||||||||
| GNU Guile | |||||||||||||||
| Visual LISP | |||||||||||||||
| Clojure | |||||||||||||||
| Arc | |||||||||||||||
| LFE | |||||||||||||||
| Hy | |||||||||||||||
A simpleHello world program in AutoLISP would be:
(defunhello()(princ"\nHello World!")(princ))
Note the final line inside the function definition: when evaluated with no arguments, theprinc function returns a null symbol, which is not displayed by the AutoCADcommand-line interface. As the AutoCAD command line functions as aread–eval–print loop (REPL), this would normally print "Hello World!" to the command line, followed immediately by the return value of the call toprinc. Therefore, without the final call to theprinc function, the result of this would be:
Hello World!"\nHello World!"Theprin1 function may also be used to achieve the same result.
A more complex example is:
(defunc:pointlabel(/pnt)(if(setqpnt(getpoint"\nSpecify point: "))(progn(entmake(list'(0."POINT")(cons10(transpnt10))))(entmake(list'(0."TEXT")(cons10(trans(cons(+(carpnt)0.6)(cdrpnt))10))(cons40(getvar'textsize))(cons1(strcat"X:"(rtos(carpnt))" Y:"(rtos(cadrpnt))))))))(princ))
The above code defines a newfunction which generates an AutoCAD point object at a given point, with a one-line text object displaying the X and Y coordinates beside it. The name of the function includes a special prefix 'c:', which causes AutoCAD to recognize the function as a regular command. The user, upon typing 'pointlabel' at the AutoCAD command line, would be prompted to pick a point, either by typing the X and Y coordinates, or clicking a location in the drawing. The function would then place a marker at that point, and create a one-line text object next to it, containing the X and Y coordinates of the point expressed relative to the active User Coordinate System (UCS). The function requires noparameters, and contains onelocal variable ('pnt').
The above example could also be written using built-in AutoCAD commands to achieve the same result, however this approach is susceptible to changes to the command prompts between AutoCAD releases.