Learn Autolisp - 10 Code Examples & CST Typing Practice Test
AutoLISP is a dialect of the Lisp programming language built specifically for automating tasks, customizing workflows, and extending functionality within Autodesk AutoCAD software, enabling rapid development of scripts and commands to enhance CAD productivity.
View all 10 Autolisp code examples →
Learn AUTOLISP with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
Simple AutoLISP Routine to Draw a Line
(defun c:DrawLine ()
(prompt "\nSelect first point: ")
(setq p1 (getpoint))
(prompt "\nSelect second point: ")
(setq p2 (getpoint))
(command "_.LINE" p1 p2 "")
(princ)
)
A basic AutoLISP function that prompts the user for two points and draws a line between them in AutoCAD.
AutoLISP Loop to Draw Multiple Circles
(defun c:DrawCircles ()
(setq center (getpoint "\nSelect center point: "))
(setq radius 1)
(repeat 5
(command "_.CIRCLE" center radius)
(setq radius (+ radius 2))
)
(princ)
)
This AutoLISP script draws 5 circles with increasing radii at a fixed center point.
Draw Rectangle Using AutoLISP
(defun c:DrawRectangle ()
(setq p1 (getpoint "\nFirst corner: "))
(setq p2 (getpoint "\nOpposite corner: "))
(command "_.RECTANGLE" p1 p2)
(princ)
)
Prompts user for two corners and draws a rectangle.
Draw a Polyline in AutoLISP
(defun c:DrawPolyline ()
(setq pts '())
(prompt "\nPick points, press Enter to finish")
(while (setq pt (getpoint))
(setq pts (append pts (list pt)))
)
(command "_.PLINE" (apply 'append pts) "")
(princ)
)
Creates a polyline from user-specified points.
Draw Concentric Circles
(defun c:ConcentricCircles ()
(setq center (getpoint "\nCenter point: "))
(setq radius 2)
(repeat 5
(command "_.CIRCLE" center radius)
(setq radius (+ radius 2))
)
(princ)
)
Draws concentric circles with increasing radii.
Move Selected Objects
(defun c:MoveObjects ()
(setq ss (ssget))
(setq base (getpoint "\nBase point: "))
(setq target (getpoint "\nTarget point: "))
(command "_.MOVE" ss "" base target)
(princ)
)
Moves selected objects by a vector defined by two points.
Scale Selected Objects
(defun c:ScaleObjects ()
(setq ss (ssget))
(setq base (getpoint "\nBase point: "))
(setq factor (getreal "\nScale factor: "))
(command "_.SCALE" ss "" base factor)
(princ)
)
Scales objects by a user-defined factor.
Rotate Selected Objects
(defun c:RotateObjects ()
(setq ss (ssget))
(setq base (getpoint "\nBase point: "))
(setq angle (getangle base "\nRotation angle: "))
(command "_.ROTATE" ss "" base angle)
(princ)
)
Rotates selected objects around a base point by a specified angle.
Erase Selected Objects
(defun c:EraseObjects ()
(setq ss (ssget))
(command "_.ERASE" ss "")
(princ)
)
Deletes selected objects from the drawing.
Create Text at a Point
(defun c:CreateText ()
(setq pt (getpoint "\nInsertion point: "))
(setq txt (getstring "\nEnter text: "))
(command "_.TEXT" pt 1 0 txt)
(princ)
)
Prompts for a point and a string, and creates a text object.
Frequently Asked Questions about Autolisp
What is Autolisp?
AutoLISP is a dialect of the Lisp programming language built specifically for automating tasks, customizing workflows, and extending functionality within Autodesk AutoCAD software, enabling rapid development of scripts and commands to enhance CAD productivity.
What are the primary use cases for Autolisp?
Automating drawing modifications. Custom command creation. Batch plotting and file management. Parametric drawing generation. Data extraction and CAD reporting
What are the strengths of Autolisp?
Rapid automation of repetitive CAD tasks. No external compiler needed. Highly flexible scripting with Lisp logic. Direct access to drawing database. Strong integration with AutoCAD commands
What are the limitations of Autolisp?
Only works within AutoCAD environment. Performance limited for extremely large drawings. Not suitable for real-time CAD applications. Visual customization is limited compared to .NET API. Older syntax may be less familiar to new developers
How can I practice Autolisp typing speed?
CodeSpeedTest offers 10+ real Autolisp code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.