HOME

TheInfoList



OR:

AutoLISP is a
dialect The term dialect (from Latin , , from the Ancient Greek word , 'discourse', from , 'through' and , 'I speak') can refer to either of two distinctly different types of linguistic phenomena: One usage refers to a variety of a language that is ...
of the programming language
Lisp A lisp is a speech impairment in which a person misarticulates sibilants (, , , , , , , ). These misarticulations often result in unclear speech. Types * A frontal lisp occurs when the tongue is placed anterior to the target. Interdental lispin ...
built specifically for use with the full version of
AutoCAD AutoCAD is a commercial computer-aided design (CAD) and drafting software application. Developed and marketed by Autodesk, AutoCAD was first released in December 1982 as a desktop app running on microcomputers with internal graphics controllers. ...
and its derivatives, which include '' AutoCAD Map 3D'', ''
AutoCAD Architecture AutoCAD Architecture (abbreviated as ACA) is a version of Autodesk's flagship product, AutoCAD, with tools and functions specially suited to architectural work. Architectural objects have a relationship to one another and interact with each other ...
'' and ''
AutoCAD Mechanical AutoCAD is a commercial computer-aided design (CAD) and drafting software application. Developed and marketed by Autodesk, AutoCAD was first released in December 1982 as a desktop app running on microcomputers with internal graphics controllers. ...
''. Neither the
application programming interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how ...
(API) nor the interpreter to execute AutoLISP code are included in the AutoCAD LT product line. 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 Waste collection is a part of the process of waste management. It is the transfer of solid waste from the point of use and disposal to the point of treatment or landfill. Waste collection also includes the curbside collection of recyclabl ...
, 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. 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 The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, ins ...
(GUI) mini- or
domain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging ...
(DSL), the
Dialog Control Language 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. Features and usage Unlike othe ...
, for creating modal dialog boxes with automated layout, within AutoCAD.


History

AutoLISP was derived from an early version of
XLISP XLISP is a family of Lisp (programming language), Lisp implementations written by David Betz and first released in 1983. The first version was a Lisp with object-oriented programming, object-oriented extensions for computers with limited power. Th ...
, 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 Autodesk, Inc. is an American multinational software corporation that makes software products and services for the architecture, engineering, construction, manufacturing, media, education, and entertainment industries. Autodesk is headquartere ...
in favor of more fashionable development environments like
Visual Basic for Applications 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 support ...
(VBA),
.NET Framework The .NET Framework (pronounced as "''dot net"'') is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until bein ...
, and
ObjectARX ObjectARX (AutoCAD Runtime eXtension) is an API for customizing and extending AutoCAD. The ObjectARX SDK is published by Autodesk and freely available under license from Autodesk. The ObjectARX SDK consists primarily of C++ headers and libraries th ...
. However, it has remained AutoCAD's main user customizing language. ''Vital-LISP'', a considerably enhanced version of AutoLISP including an
integrated development environment An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools ...
(IDE),
debugger A debugger or debugging tool is a computer program used to test and debug other programs (the "target" program). The main use of a debugger is to run the target program under controlled conditions that permit the programmer to track its executi ...
,
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
, and
ActiveX ActiveX is a deprecated software framework created by Microsoft that adapts its earlier Component Object Model (COM) and Object Linking and Embedding (OLE) technologies for content downloaded from a network, particularly from the World Wide We ...
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 Autodesk, Inc. is an American multinational software corporation that makes software products and services for the architecture, engineering, construction, manufacturing, media, education, and entertainment industries. Autodesk is headquartere ...
has ceased major enhancements to Visual LISP and focused more effort on VBA and .NET, and
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
. , Autodesk no longer supports VBA versions older than 7.1. This is 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 Computer-aided design (CAD) is the use of computers (or ) to aid in the creation, modification, analysis, or optimization of a design. This software is used to increase the productivity of the designer, improve the quality of design, improve co ...
(CAD) application vendors add it to their products.
Bricscad 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 LedasRalph ...
,
IntelliCAD 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 AutoCA ...
, 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 ''Hello'' is a salutation or greeting in the English language. It is first attested in writing from 1826. Early uses ''Hello'', with that spelling, was used in publications in the U.S. as early as the 18 October 1826 edition of the '' Norwich ...
in AutoLISP would be: (defun hello ( ) (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 A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
. As the AutoCAD command line functions as a
read–eval–print loop A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written ...
(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: (defun c:pointlabel ( / pnt ) (if (setq pnt (getpoint "\nSpecify point: ")) (progn (entmake (list '(0 . "POINT") (cons 10 (trans pnt 1 0)) ) ) (entmake (list '(0 . "TEXT") (cons 10 (trans (cons (+ (car pnt) 0.6) (cdr pnt)) 1 0)) (cons 40 (getvar 'textsize)) (cons 1 (strcat "X:" (rtos (car pnt)) " Y:" (rtos (cadr pnt)))) ) ) ) ) (princ) ) The above code defines a new
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
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 A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
, and contains one
local variable In computer science, a local variable is a variable that is given ''local scope''. A local variable reference in the function or block in which it is declared overrides the same variable name in the larger scope. In programming languages with o ...
('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.


References


External links


AutoLISP FAQ
{{Authority control
Lisp A lisp is a speech impairment in which a person misarticulates sibilants (, , , , , , , ). These misarticulations often result in unclear speech. Types * A frontal lisp occurs when the tongue is placed anterior to the target. Interdental lispin ...
Lisp programming language family Computer-aided design software Scripting languages