AutoLISP

Last updated
AutoLISP
Family Lisp
Designed by David Betz
Developers Autodesk, Basis Software
First appearedJanuary 1986;37 years ago (1986-01)
Stable release
13 / February 1995;28 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 a dialect of the programming language Lisp built specifically for use with the full version of AutoCAD and its derivatives, which include 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.

Contents

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 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. [3]

History

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++. 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. [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]

19581960196519701975198019851990199520002005201020152020
 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
  Common Lisp  ANSI standard
  Le Lisp
  MIT Scheme
  T
  Chez Scheme
  Emacs Lisp
  AutoLISP
  PicoLisp
  Gambit
  EuLisp
  ISLISP
  OpenLisp
  PLT Scheme   Racket
  GNU Guile
  Visual LISP
  Clojure
  Arc
  LFE
  Hy

Examples

A simple Hello world program in AutoLISP would be:

(defunhello()(princ"\nHello World!")(princ))

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:

(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 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 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 no parameters, and contains one local 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.

Related Research Articles

<span class="mw-page-title-main">AutoCAD</span> Commercial computer-aided design (CAD) and drafting software application

AutoCAD is a 2D and 3D computer-aided design (CAD) software application for desktop, web, and mobile developed by Autodesk. It was first released in December 1982 for the CP/M and IBM PC platforms as a desktop app running on microcomputers with internal graphics controllers. Initially a DOS application, subsequent versions were later released for other platforms including Classic Mac OS (1992), Microsoft Windows (1992), web browsers (2010), iOS (2010), macOS (2010), and Android (2011).

AutoCAD DXF is a CAD data file format developed by Autodesk for enabling data interoperability between AutoCAD and other programs.

<span class="mw-page-title-main">Common Lisp</span> Programming language standard

Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ANSI INCITS 226-1994 (S20018). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived from the ANSI Common Lisp standard.

An integrated development environment (IDE) is a software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, and a debugger. Some IDEs, such as NetBeans and Eclipse, contain the necessary compiler, interpreter, or both; others, such as SharpDevelop and Lazarus, do not.

<span class="mw-page-title-main">Lisp (programming language)</span> Programming language family

Lisp is a family of programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in 1960, Lisp is the second-oldest high-level programming language still in common use, after Fortran. Lisp has changed since its early days, and many dialects have existed over its history. Today, the best-known general-purpose Lisp dialects are Common Lisp, Scheme, Racket and Clojure.

<span class="mw-page-title-main">Microsoft Access</span> Database manager part of the Microsoft Office package

Microsoft Access is a database management system (DBMS) from Microsoft that combines the relational Access Database Engine (ACE) with a graphical user interface and software-development tools. It is a member of the Microsoft 365 suite of applications, included in the Professional and higher editions or sold separately.

VBScript is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers without error handling and with subroutines and other advanced programming constructs. It can give the user complete control over many aspects of their computing environment.

Visual Basic for Applications (VBA) is an implementation of Microsoft's event-driven programming language Visual Basic 6.0 built into most desktop Microsoft Office applications. Although based on pre-.NET Visual Basic, which is no longer supported or updated by Microsoft, the VBA implementation in Office continues to be updated to support new Office features. VBA is used for professional and end-user development due to its perceived ease-of-use, Office's vast installed userbase, and extensive legacy in business.

<span class="mw-page-title-main">Genera (operating system)</span> Symbolics operating system based on Lisp

Genera is a commercial operating system and integrated development environment for Lisp machines created by Symbolics. It is essentially a fork of an earlier operating system originating on the Massachusetts Institute of Technology (MIT) AI Lab's Lisp machines which Symbolics had used in common with Lisp Machines, Inc. (LMI), and Texas Instruments (TI). Genera was also sold by Symbolics as Open Genera, which runs Genera on computers based on a Digital Equipment Corporation (DEC) Alpha processor using Tru64 UNIX. In 2021 a new version was released as Portable Genera which runs on DEC Alpha, Tru64 UNIX, x86-64 and Arm64 Linux, x86-64 and Apple Silicon M Series macOS. It is released and licensed as proprietary software.

In some programming languages, eval, short for the English evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; it may be structured representation of code, such as an abstract syntax tree, or of special type such as code. The analog for a statement is exec, which executes a string as if it were a statement; in some languages, such as Python, both are present, while in other languages only one of either eval or exec is.

<span class="mw-page-title-main">FreeBASIC</span> BASIC dialect

FreeBASIC is a free and open source multiplatform compiler and programming language based on BASIC licensed under the GNU GPL for Microsoft Windows, protected-mode MS-DOS, Linux, FreeBSD and Xbox. The Xbox version is no longer maintained.

<span class="mw-page-title-main">EAGLE (program)</span> Scriptable electronic design automation application

EAGLE is a scriptable electronic design automation (EDA) application with schematic capture, printed circuit board (PCB) layout, auto-router and computer-aided manufacturing (CAM) features. EAGLE stands for Easily Applicable Graphical Layout Editor and is developed by CadSoft Computer GmbH. The company was acquired by Autodesk Inc. in 2016 who announced to support the product up to 2026 only.

Dialog Control Language (DCL) is a high-level description language and interpreter within AutoCAD for creating simple graphical dialogs. AutoLISP extensions use it to interact with the user in the AutoCAD environment.

<span class="mw-page-title-main">Visual Basic (classic)</span> Event-driven programming language

The original Visual Basic is a third-generation event-driven programming language from Microsoft known for its Component Object Model (COM) programming model first released in 1991 and declared legacy during 2008. Microsoft intended Visual Basic to be relatively easy to learn and use. Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using Data Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects.

PC-LISP is an implementation of the Franz Lisp dialect by Peter Ashwood-Smith.

<span class="mw-page-title-main">IntelliCAD</span> CAD editor and development platform

IntelliCAD is a CAD editor and development platform with an Application Programming Interface API published by the IntelliCAD Technology Consortium ("ITC") through shared development. IntelliCAD emulates the basic interface and functions of AutoCAD, however, it is particularly able to incorporate and interchange freely between a wide variety of file types.

<span class="mw-page-title-main">BricsCAD</span> Computer-aided design software

BricsCAD is a software application for computer-aided design (CAD), developed by Bricsys nv. The company was founded in 2002 by Erik de Keyser, a longtime CAD entrepreneur. In 2011 Bricsys acquired the intellectual property rights from Ledas for constraints-based parametric design tools, permitting the development of applications in the areas of direct modeling and assembly design. Bricsys is headquartered in Ghent, Belgium, and has additional development centers in Nizhny Novgorod and Novosibirsk, Russia; Bucharest, Romania and Singapore. Bricsys is a founding member of the Open Design Alliance, and joined the BuildingSMART International consortium in December 2016.

Advance Steel is a CAD software application for 3D modeling and detailing of steel structures and automatic creation of fabrication drawings, bill of materials and NC files. It was initially developed by GRAITEC, but was acquired by Autodesk in 2013. The software runs on AutoCAD. As of March 29th, 2023 Advance Steel was put on maintenence mode, meaning no new updates will be introduced.

<span class="mw-page-title-main">Scripting language</span> Programming language for run-time events

A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.

<span class="mw-page-title-main">LFE (programming language)</span>

Lisp Flavored Erlang (LFE) is a functional, concurrent, garbage collected, general-purpose programming language and Lisp dialect built on Core Erlang and the Erlang virtual machine (BEAM). LFE builds on Erlang to provide a Lisp syntax for writing distributed, fault-tolerant, soft real-time, non-stop applications. LFE also extends Erlang to support metaprogramming with Lisp macros and an improved developer experience with a feature-rich read–eval–print loop (REPL). LFE is actively supported on all recent releases of Erlang; the oldest version of Erlang supported is R14.

References

  1. "AutoLISP" . Retrieved 14 April 2014.
  2. "AutoCAD LT vs. AutoCAD". Archived from the original on 15 April 2014. Retrieved 14 April 2014.
  3. 1 2 "AutoLISP Developer's Guide" (PDF). Retrieved 14 April 2014.
  4. "History of AutoLISP".
  5. "Microsoft Visual Basic for Applications Module FAQ" . Retrieved 14 April 2014.
  6. "VBA support in AutoCAD 2011". Archived from the original on 15 April 2014. Retrieved 14 April 2014.
  7. "BricsCAD Compare versions". Archived from the original on 2014-03-15. Retrieved 14 April 2014.
  8. "IntelliCAD CAD Platform – Features and Benefits" . Retrieved 14 April 2014.