AutoLISP: History and Future

Website Developer
8 min readMar 10, 2021

AutoLISP is a programming language introduced in 1986. It was made by Autodesk specifically for use along with their AutoCAD family of products. The AutoCAD software and its derivatives (AutoCAD Map 3D, AutoCAD Architecture, and AutoCAD Mechanical) are computer-aided design programs, used by engineers, graphic designers, architects, and other professionals. AutoLISP is based on XLISP, a dialect of the Lisp programming language.

AutoLISP is a very simple language to learn even if you do not know any other languages, given that you have a modest understanding of AutoCAD software to start with. This is because the language is aimed towards designers, and not necessarily programmers. It is a very popular language among AutoCAD users because it can save them a lot of time by completing mundane tasks automatically.

Along with its ease of use, for beginners and professionals alike, it can sometimes reduce hours or days of work down to writing a simple program. For pretty much any task that you could perform manually in AutoCAD, the AutoLISP language is more than likely to have a function to allow you to automate it.

Origins

Lisp, the family of programming languages that AutoLISP is based on, was first created to represent mathematical notation in code. In the early days, it was often used the field of AI research. Lisp was created in 1958 at the Massachusetts Institute of Technology (MIT) by John McCarthy. He published its design in a paper in 1960 titled “Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I”.

Many of the concepts present in Lisp, such as recursion and list-processing, were already present in Information Processing Language (IPL), the earliest AI language, from which Lisp borrowed several functions. Other functions were unique to Lisp and new at the time, this combination of ideas made Lisp a unique programming language as well as an effective mathematical system.

The first Lisp interpreter ran on an IBM 704 and was implemented by Steve Russel. It used punch cards, a piece of stiff paper that was used to store computer data where holes were punched either by hand or by a machine. The presence or absence of a hole would represent data or a set of instructions to the computer.

Two years after John McCarthy had published its design, Mike Levin and Tim Hart created the first complete Lisp compiler in 1962. A compiler is a program that converts the high level, understandable to humans language (such as the examples of code later in this paper), and converts it into machine-language instructions that can be understood by the computer. Compilers are extremely useful, so the programmer can focus on writing code.

AutoLISP, a dialect of Lisp that Autodesk had created in hopes of aiding users of their programs, was shown to the public in 1982 and was implemented into AutoCAD in a 1986 release of the software. Since AutoCAD is a design software, most of the core functionality of AutoLISP is based on geometry, manipulating graphics, or calculations such as drawing different shapes or calculating the total length or area of a given shape or layer.

AutoLISP lacks in certain basic Lisp features such as keyboard macros, functions with a variable number of parameters, arrays, and other removed features from the base Lisp, but retains other regular Lisp features.

AutoLISP was updated for several years, up until 1995, but has since not been further developed by Autodesk who aimed to replace the language with development environments.

A notably improved version of AutoLISP named Vital-LISP was being developed and sold by third-party software company Basis Software, which included several features not included in AutoLISP. Vital-LISP also included its own IDE, debugger, and compiler. Autodesk bought Vital-LISP and renamed it Visual LISP. Visual LISP would be sold in addition to AutoCAD starting in 1997.

Visual LISP would continue to be updated by Autodesk until their 1999 release of the product, serving as an upgrade or replacement for AutoLISP. Since then, Autodesk has moved away from updating Visual LISP and instead moved towards other customization environments. Other coding environments used for AutoCAD customization include:

  • ObjectARX (also published by AutoCAD for use with their products)
  • Microsoft’s .NET framework
  • Visual Basic for Applications (VBA) — also developed by Microsoft — which, extraneously, is regarded as the “most dreaded” language, based on a Stack Overflow survey in 2020 and 2019.
  • Autodesk stopped supporting older VBA versions starting in 2014, in a continuing plan to start moving towards .NET for customization instead.

Despite AutoCAD attempting to move away from AutoLISP in favor of other environments, AutoLISP has maintained a strong following. AutoLISP has such a strong following, in fact, that even other competing computer-aided design programs such as DraftSight, Bricscad, IntelliCAD, and others started to implement AutoLISP functionality into their own program. This is in an attempt to signal to users who are already familiar with AutoLISP that their program is a viable alternative.

Syntax

An AutoLISP program could be run entirely from inside the program by manually entering each line by hand, but this approach can be tedious. For anything longer than a couple of lines the preferred way to create AutoLISP programs is by storing the commands in an ‘lsp’ file, which can be modified as an ASCII text file in any simple text editor. Below is a simple AutoLISP program that draws a line from two specified points, the program will prompt the user to enter two points.

afrolisp.net

This file would be named “textline.lsp” and if saved in an AutoCAD search directory could be run by typing the lines “(load “testline”)” to load and “testline” to run the code inside of the program.

An if statement in AutoLISP is simple. If inherits the same syntax from Lisp.

AutoLISP has several different types of loops. The most used loops are the (while) loop, (repeat) loop, and the (for) loop. These different loops can all be used differently and are best suited for different use cases depending on what you aim to achieve.

AutoLISP has several different types of loops. The most used loops are the (while) loop, (repeat) loop, and the (for) loop. These different loops can all be used differently and are best suited for different use cases depending on what you aim to achieve.

A powerful feature of AutoLISP is recursion, but it is best to limit this to a single level of recursion at a time. It is easy to get lost having a loop within a loop within a loop (and so on). Below is an example of a (repeat) loop. The repeat loop simply repeats code a set number of times.

afralisp.net

The above code will move a circle around the screen, the number of times this happens will depend on the user input number. As you can see, the repeat function can also use variables to indicate the number of times to loop, as well as hardcoding a number, but the number must always be an integer/ whole number. If you always wanted the circle to move 10 times, you could remove the 3rd line and replace n on the 5th line after repeat with 10 (or any number).

The (while) loop is also very easy, it allows you to repeat code while a certain condition is true. The syntax is similar to what you might expect if you have experience with any other language that takes advantage of loops.

If the user knows how many times they want to loop, repeat is preferred, as it is a much simpler command. Both of these loops are used often in AutoLISP.

Lisp, and by extension AutoLISP, are known for their many nested parentheses. Nested functions, or a function within a function, allows you to write a function that evaluates another function, which can be useful for various simple or complex programs. While useful, nested functions can often result in seemingly unending parenthesis, which has led some programmers to jokingly refer to “Lisp” and an acronym for “Lost in Stupid Parenthesis”.

A common way to limit the amount of digging through parenthesis — along with good formatting — is adding comments at the end or below your functions, which lets you know where one function ends, and another begins. The syntax for comment in Lisp and AutoLISP is a semicolon that prefixes whatever line of code you do not want to be read by the compiler. Below is an example of a more complex command that uses nested functions and uses comments to increase readability.

This code prompts the user to enter a point, and then marks the point and adds a label at that point with the x and y coordinates.

Wikipedia

Having parenthesis on a new line and having comments in the way shown above is not required. However, it is not difficult to see how the nested parentheses can easily get out of hand, especially for much larger scripts.

Takeaway

Even though Autodesk started to move away from it, AutoLISP has proved as a convenient and easy to learn programming language for designers and other professionals. One of the reasons for its popularity even across programs is that other environments require the user to be familiar with another programming language beforehand.

For example, if you were to use VBA as an environment instead, you would need to understand the Visual Basic programming language, for .NET you would need to know C# first, whereas AutoLISP is much more straightforward. A programmer might know some of these languages already, but someone who is a designer first might not.

AutoLISP is a lot more straightforward (after you learn to handle the endless parenthesis) than some of the other options for AutoCAD. You can learn it with the only requirement being a basic understanding of whatever program you aim to customize, whether that be AutoCAD or one of the other programs that take advantage of AutoLISP.

AutoLISP continues to be an extremely helpful tool for designers, engineers, and the like, providing many time-saving features. Its strong community has led to it being the main AutoCAD customization tool, even with Autodesk moving towards other environments. Currently, almost all AutoLISP programs are created through Visual-LISP, as the AutoLISP compiler was replaced with Visual-LISP.

Many developers avoid learning Lisp and AutoLISP, and not without reason. The incredible amount of nested parenthesis can seem daunting and digging through them can take a lot of time. But for the reason I have detailed above and more, I would recommend AutoLISP (now Visual-LISP) to anyone who aims to create designs in any of the AutoCAD products (or any program that supports AutoLISP). Visual-LISP and AutoLISP have cemented their place in one of the most popular CAD customization environments.

--

--