ArticleslgStudy

computer science

AutoLISP

AutoLISP is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand AutoLISP rather than just read about it. In short: 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. 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 Auto…

AutoLISP — main illustration
AutoLISP — illustration

Key takeaways

  • AutoLISP belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect AutoLISP to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of AutoLISP from memory before moving on to harder problems.

Reference excerpt

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. 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). A subset of AutoLISP functions is included in the browser-based AutoCAD web app.

Features 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 and 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 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.

History 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 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++. As of January 31, 2014, 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. 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).

Examples A simple Hello world program in AutoLISP would be:

Note the final line inside the function definition: when evaluated with no arguments, the 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 code defines a new function 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 rest of the function name pointlabel as a regular command at the command prompt. 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 no parameters, and contains one local variable ('pnt'). The above example could also be written to use the built-in AutoCAD commands from inside the AutolISP code to create the point and text objects, instead of creating them directly via the entmake function; however, such approach is susceptible to changes to the command prompts between AutoCAD releases.

References

External links AutoLISP FAQ

Illustrations

AutoLISP illustration

Worked examples

Example 1 — a first encounter with AutoLISP

Start with the simplest possible case. Write down what AutoLISP claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to AutoLISP before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about AutoLISP ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of AutoLISP

In research
AutoLISP appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses AutoLISP in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
AutoLISP is common in secondary-school and first-year university syllabi. It links to neighbouring topics AutoCAD, Computer-aided design software, Dynamically scoped programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for AutoLISP outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “AutoLISP” →

How to study AutoLISP in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what AutoLISP means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain AutoLISP out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is AutoLISP in simple terms?

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. Neither the application programming interface (API) nor the interprete…

Why does AutoLISP matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study AutoLISP?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on AutoLISP.

Tags

  • AutoCAD
  • Computer-aided design software
  • Dynamically scoped programming languages
  • Lisp programming language family
  • Scripting languages

Keep exploring