AutoLISP | |
Paradigms: | --> |
Family: | Lisp |
Designer: | David Betz |
Developers: | Autodesk, Basis Software |
Latest Release Version: | 13 |
Typing: | dynamic |
Scope: | dynamic |
Platform: | IA-32 |
Operating System: | Linux |
File Formats: | --> |
Dialects: | Vital-LISP, Visual LISP |
Influenced By: | Lisp, XLISP |
AutoLISP is a dialect of the programming language Lisp built specifically for use with the full version of AutoCAD and its derivatives, which include AutoCAD Civil 3D, AutoCAD Map 3D, AutoCAD Architecture and AutoCAD Mechanical.[1] Neither the application programming interface (API) nor the interpreter 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, dynamically scoped, dynamically typed Lisp language 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.[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-in graphical user interface (GUI) mini- or domain-specific language (DSL), 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.[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 by Autodesk in favor of more fashionable development environments like Visual Basic for Applications (VBA), .NET Framework, and ObjectARX. However, it has remained AutoCAD's main user customizing language.
Vital-LISP, a considerably enhanced version of AutoLISP including an integrated development environment (IDE), debugger, 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 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, and C++., 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 other computer-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]
A simple Hello world program in AutoLISP would be:princ
function returns a null symbol, which is not displayed by the AutoCAD command-line interface. As the AutoCAD command line functions as a read–eval–print loop (REPL), this would normally print "Hello World!" to the command line, followed immediately by the return value of the call to princ
. Therefore, without the final call to the princ
function, the result of this would be:
Hello World!"\nHello World!"
The prin1
function may also be used to achieve the same result.
A more complex example is:
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.