AutoLISP Function
Quick Reference
50+ AutoLISP functions for AutoCAD automation — math, geometry, entity access, selection sets, list operations, and command execution. Search by function name or category.
Returns sum of all arguments. (+ 2 3 4) → 9. Accepts integers and reals. Result type: integer if all args are integers, real if any arg is real.
Returns difference. (- 10 3 2) → 5. With one argument, negates: (- 5) → -5. Same type rules as +.
Returns product. (* 2 3 4) → 24. Same type rules as + and -.
Returns quotient. (/ 10 3) → 3 (integer division). (/ 10.0 3) → 3.33333 (real division). Use float arg for real result.
Returns n + 1. (1+ 5) → 6. Works with integers and reals. Not the same as (+ n 1) — 1+ is a dedicated function.
Returns n - 1. (1- 5) → 4. Works with integers and reals.
Returns absolute value. (abs -5) → 5. (abs -5.5) → 5.5.
Returns sine of angle in radians. (sin 0.0) → 0.0. (sin (/ pi 2)) → 1.0. Always returns real.
Returns cosine of angle in radians. (cos 0.0) → 1.0. (cos pi) → -1.0. Always returns real.
With one arg: returns arctangent in radians. (atan 1.0) → 0.785398 (π/4). With two args: returns arctangent of a/b, handling quadrant correctly (like atan2 in C).
Returns square root as real. (sqrt 16) → 4.0. Always returns real regardless of input type.
Returns base raised to power exp. (expt 2 3) → 8. (expt 2.0 0.5) → 1.41421.
Returns greatest common divisor of two positive integers. (gcd 12 18) → 6. Arguments must be integers.
Returns remainder of integer division. (rem 10 3) → 1. Sign follows first argument.
Returns T if all arguments are non-nil, nil otherwise. Short-circuits on first nil. (and T T nil) → nil.
Returns T if any argument is non-nil, nil otherwise. Short-circuits on first non-nil. (or nil T nil) → T.
Returns T if argument is nil, nil otherwise. (not nil) → T. (not 5) → nil. Different from null — not works on any expression.
Returns T if all arguments are numerically equal. (= 5 5) → T. (= 5 5.0) → T. (= "abc" "abc") → T.
Returns T if any pair of arguments is not equal. (/= 5 6) → T.
Returns T if each argument is less than the next. (< 1 2 3) → T. Works with numbers and strings.
Returns T if each argument is greater than the next. (> 3 2 1) → T.
Returns T if each argument is less than or equal to the next. (<= 1 1 2) → T.
Returns T if each argument is greater than or equal to the next. (>= 3 3 2) → T.
Returns 3D distance between two points. (distance '(0 0 0) '(3 4 0)) → 5.0. Points must be lists of 2 or 3 reals.
Returns angle in radians from p1 to p2 (XY plane only). (angle '(0 0) '(1 0)) → 0.0. (angle '(0 0) '(0 1)) → 1.5708 (π/2).
Returns a point at given angle (radians) and distance from pt. (polar '(0 0) 0.0 5.0) → (5.0 0.0). Extremely useful for calculating points in AutoLISP.
Returns intersection point of two lines defined by point pairs. Optional 5th arg nil extends lines. (inters '(0 0) '(10 10) '(0 10) '(10 0)) → (5.0 5.0).
Returns snap point using OSNAP mode string. (osnap pt "midp") returns midpoint of nearest entity. Modes: "endp","midp","cen","int","nea","nod","qua","tan","per","ins","app". Returns nil if no snap found.
Returns angle from p1 to p2 in radians (XY plane). To convert to degrees: (* (/ (angle p1 p2) pi) 180).
Converts value between units. (cvunit 1 "inch" "mm") → 25.4. Uses acad.unt file. Supports distance, area, volume, angle, mass, and temperature units.
Transforms point between coordinate systems. from/to can be: 0=WCS, 1=UCS, 2=DCS, or an entity name. (trans pt 1 0) converts from UCS to WCS.
Returns association list (DXF group codes) for entity. (entget (entlast)) returns data for last entity. Key codes: 0=type, 8=layer, 10=start point, 11=end point, 40=radius.
Returns entity name of the last non-deleted entity in the drawing. Common pattern: (setq ent (entlast)) before creating entities to track them.
Returns entity name of the next entity in the database. (entnext nil) returns first entity. Used to iterate through all entities. Returns nil at end.
Creates a new entity from DXF group code list. (entmake (list '(0 ."CIRCLE") '(8 ."0") '(10 0.0 0.0 0.0) '(40 . 5.0))). Faster than command for bulk creation.
Modifies an entity using updated DXF group code list. Pattern: (setq ed (entget en)) (setq ed (subst (cons 8 "NewLayer") (assoc 8 ed) ed)) (entmod ed). Changes are immediate.
Deletes or undeletes an entity. (entdel en) deletes. Calling again with same ename undeletes. Cannot delete entities in blocks.
Regenerates entity on screen after modification. Especially needed for polylines and complex entities after entmod. (entupd en) updates display.
Creates selection set. Modes: "C"=crossing, "W"=window, "L"=last, "P"=previous, "X"=all. (ssget '(0 0) '(10 10)) prompts user. (ssget "X" '((0 ."CIRCLE"))) selects all circles.
Returns entity name at index in selection set. (ssname ss 0) returns first entity. Index is 0-based. Use with ssadd/ssdel to manipulate sets.
Returns number of entities in selection set. (sslength ss) → integer count. Use to iterate: (while (< i (sslength ss)) ...).
Adds entity to selection set. (ssadd en ss) adds en to ss. If ss is nil, creates new selection set. Returns the selection set.
Removes entity from selection set. (ssdel en ss) removes en from ss. Returns ss if successful, nil if entity not in set.
Returns ename if entity is in selection set, nil otherwise. (ssmemb en ss) checks if en is in ss.
Prompts user to select entity, returns (ename pt). For nested entities (in blocks), returns the sub-entity, not the block reference. Useful for editing attributes and block contents.
Prompts user to select single entity. Returns (ename pickpoint). (entsel "\nSelect object: ") prompts with custom message.
Creates a list from arguments. (list 1 2 3) → (1 2 3). (list 0.0 0.0 0.0) creates a 3D point. Essential for coordinate data.
Returns first element of list. (car '(1 2 3)) → 1. (car '(5.0 3.0 0.0)) → 5.0 (X coordinate). nil for empty list.
Returns list without first element. (cdr '(1 2 3)) → (2 3). nil for empty or single-element list.
Returns second element. (cadr '(1 2 3)) → 2. (cadr pt) → Y coordinate. Equivalent to (car (cdr lst)).
Returns third element. (caddr '(1 2 3)) → 3. (caddr pt) → Z coordinate. Equivalent to (car (cdr (cdr lst))).
Returns element at index n (0-based). (nth 2 '(a b c d)) → c. Returns nil if index out of range.
Returns number of elements in list. (length '(1 2 3 4)) → 4. Returns 0 for nil.
Concatenates lists. (append '(1 2) '(3 4)) → (1 2 3 4). All arguments must be lists. (append nil '(1)) → (1).
Returns list in reverse order. (reverse '(1 2 3)) → (3 2 1). Useful for iterating backwards or building lists efficiently.
Searches association list for key. (assoc 8 (entget en)) returns (8 ."LayerName"). Essential for DXF group code access. Returns nil if not found.
Replaces all occurrences of old with new in list. (subst (cons 8 "NewLayer") (assoc 8 ed) ed) changes layer in entity data. Returns modified list.
Returns tail of list starting from first occurrence of expr. (member 'b '(a b c d)) → (b c d). Returns nil if not found.
Iterates over list, binding each element to item. (foreach pt ptlist (command "POINT" pt)). Executes body for each element.
Applies function to corresponding elements. (mapcar '+ '(1 2 3) '(4 5 6)) → (5 7 9). Very powerful for coordinate transformations.
Executes AutoCAD command with arguments."" = Enter. (command "CIRCLE" center radius). Use "" for command termination. Non-nil args are passed as typed. Use pauses for user input.
Prompts user to pick a point. Returns 3D point or nil. (getpoint "\nPick a point: "). Optional base point arg: (getpoint basept prompt) rubber-bands from basept.
Prompts user to pick second corner, rubber-banding from basept. Returns 3D point. Used for window selection rectangles.
Prompts user for distance. Accepts numeric input or two picks. Returns real. (getdist pt "\nEnter radius: ") rubber-bands from pt.
Prompts user for angle. Returns radians regardless of current ANGDIR/ANGBASE settings. (getangle pt "\nEnter angle: ") rubber-bands from pt.
Prompts user for string input. Returns string. (getstring T "\nEnter description: ") — T allows spaces. Without T, input terminates at space.
Prompts user for integer input. Returns integer or nil. (getint "\nEnter number of copies: ").
Prompts user for real number. Returns real or nil. (getreal "\nEnter scale factor: ").
Prompts user for keyword from initget list. Must call (initget) first. (initget 1 "Yes No") (getkword "\nContinue? [Yes/No]: ") → "Yes" or "No".
Sets input options for next getxxx call. Bits: 1=no null, 2=no zero, 4=no negative, 8=no limits check, 32=use dashed lines, 64=disable Z. Keywords string: "Yes No Cancel".
Displays message on command line. (prompt "\nProcessing..."). Returns nil. Use \n for new line. For dialog messages, use alert or msgbox.
Prints expression without quotes or newlines. (princ "Hello") prints Hello. Returns its argument. Common in error handlers: (princ) suppresses return value display.
Prints expression on new line with quotes for strings. (print "Hello") prints "Hello" on new line. Returns expression. Used for debugging.
Displays modal dialog with message and OK button. (alert "File not found!"). Message limited to ~132 characters. Returns nil.
Returns value of AutoCAD system variable. (getvar "DIMSCALE") → current dimscale. (getvar "CLAYER") → current layer name. Returns integer, real, string, or list.
Sets AutoCAD system variable. (setvar "OSMODE" 0) disables all osnaps. (setvar "CMDECHO" 0) suppresses command prompts. Always restore original values after use.
Sets value of quoted symbol. (set 'myvar 5) → 5. Rare — use setq instead. Useful when symbol name is computed at runtime.
Most common assignment. (setq x 10 y 20 z 30) assigns multiple variables. Each pair: symbol (not quoted) and value. Returns last value.
Defines a function. (defun c:MYCMD () (alert "Hello")) creates command MYCMD. Args: (/ local vars) for locals, () for none. c: prefix makes it an AutoCAD command.
Anonymous function. (mapcar (lambda (x) (* x 2)) '(1 2 3)) → (2 4 6). Used with mapcar and apply. No name — defined inline.
Calls function with list as arguments. (apply '+ '(1 2 3 4)) → 10. (apply 'strcat '("a" "b" "c")) → "abc". Useful when argument count is dynamic.
Concatenates strings. (strcat "Hello" " " "World") → "Hello World". All arguments must be strings. nil causes error.
Converts integer to string. (itoa 42) → "42". For reals, use (rtos n 2 2) → "42.00" (mode 2=decimal, precision 2).
Converts string to integer. (atoi "42") → 42. (atoi "42.9") → 42 (truncates). Returns 0 for non-numeric strings.
Converts string to real. (atof "42.5") → 42.5. Returns 0.0 for non-numeric strings.
Converts real to formatted string. Mode: 1=scientific, 2=decimal, 3=engineering, 4=architectural, 5=fractional. (rtos 3.14159 2 2) → "3.14".
Returns length of string. (strlen "Hello") → 5. Returns 0 for empty string.
Returns substring starting at position (1-based). (substr "Hello World" 7 5) → "World". Optional length arg; without it, returns to end.
Executes body while test is non-nil. (while (< i 10) (setq i (1+ i))). Returns value of last expression in body. Common for iteration.
Evaluates then if test is non-nil, else otherwise. (if (> x 0) "positive" "non-positive"). else is optional. Single expression per branch — use (progn) for multiple.
Multi-branch conditional. Evaluates tests in order, returns first matching result. T as last test = default. (cond ((= x 1) "one") ((= x 2) "two") (T "other")).
Groups multiple expressions into one. Used with if/while. (if test (progn (setq x 1) (setq y 2))). Returns value of last expression.
Executes body n times. (repeat 5 (command "POINT" (getpoint))). Returns value of last evaluation. n is evaluated once at start.
Loads Visual LISP COM extension. Required before using vlax, vla-, and vl- functions. Call once at start of script. Enables ActiveX automation and extended entity access.
AutoLISP Advanced Efficiency Guide
AutoLISP Efficiency Optimization & Best Practices
Defun with c: prefix creates AutoCAD commands
A function named with the c: prefix becomes an AutoCAD command. (defun c:HELLO () (alert "Hi!")) lets you type HELLO at the command line. Local variables go after the slash: (defun c:MYCMD (/ pt rad) ...). Always use error handler (defun *error* msg ...) to restore system variables on exit.
Use entmake instead of command for bulk creation
When creating many entities, (entmake ...) is 10-100× faster than (command ...). entmake bypasses the command processor and writes directly to the drawing database. Pattern: build a DXF group code list with required codes (0=type, 8=layer, 10=point, etc.) and call (entmake list). No screen redraw needed during creation.
Essential AutoCAD & 2D Drafting Utilities
Clean drawing lag, check DWG format releases, and customize keyboard aliases
progeCAD Keyboard Shortcuts & Command Aliases Guide
Interactive index of progeCAD keyboard shortcuts, function keys, and AutoCAD-compatible aliases.
AutoCAD DWG to Scalable Vector Graphics (SVG) Web Converter
Convert AutoCAD DWG blueprints to clean, scalable W3C SVG vector graphics. Retain functional CAD layers, true colors, and crisp zooming for web dashboards.
CNC M-Code Quick Reference Table (Fanuc / Haas / Siemens)
Complete searchable reference of CNC M-codes for machine functions: spindle, coolant, tool changes, program control, and optional stops.
AutoLISP LSP Script Encryption (FAS/VLX) Online Portal
Objective reviews & direct portal: Encrypt AutoLISP source code into compiled FAS or VLX bytecode blocks online to protect IP.
AutoLISP Batch Drawing Purge & Audit Script Generator
Generate customized AutoLISP (.lsp) macro routines to batch clean unreferenced blocks, purge regapps, fix scales, and audit DWG files.
Drawing Lag & Database Cleaner
Purge orphan regapps, unreferenced DGN linestyles, and block bloat causing viewport freezing.
Engineering Methodology & Design Standards: AutoLISP Function Quick Reference
Discipline: CAD Interoperability, Additive Manufacturing & BIM Standards
Governing Mathematical Formulation
In professional CAD Interoperability, Additive Manufacturing & BIM Standards workflows, accurate sizing and performance verification require consistent unit normalization and adherence to closed-form analytical mechanics. This AutoLISP Function Quick Reference utility implements the standardized engineering formulation:
Standardized parametric evaluation for AutoLISP Function Quick ReferenceComplete AutoLISP function reference: math, geometry, entity access, selection sets, list manipulation, and command execution for AutoCAD scripting. Every input change triggers an instant client-side recalculation across all coupled dependent variables, enabling rapid sensitivity analysis during preliminary and detailed CAD design phases.
Applicable Codes, Standards & CAD Integration
Validate unit system headers ($INSUNITS in DWG/DXF, FILE_SCHEMA in STEP/IFC) and enforce watertight manifold topology before dispatching files to downstream CAM, 3D printing, or BIM coordination.
Engineering Verification Note: Analytical models assume homogeneous material behavior, steady-state boundary loading, and consistent dimensional units. Always apply appropriate service factors, corrosion allowances, or load and resistance factor design (LRFD / ASD) safety margins required by your governing code.
Frequently Asked Engineering Questions
Technical reference & verification guidelines for AutoLISP Function Quick Reference
What governing equation and methodology does the AutoLISP Function Quick Reference use?
The AutoLISP Function Quick Reference evaluates complete autolisp function reference: math, geometry, entity access, selection sets, list manipulation, and command execution for autocad scripting within the CAD Interoperability, Additive Manufacturing & BIM Standards domain using the governing formulation: Standardized parametric evaluation for AutoLISP Function Quick Reference. All intermediate quantities are computed in double-precision floating-point arithmetic to prevent cumulative rounding drift before final design verification.
Which international engineering standards apply to AutoLISP Function Quick Reference calculations?
Calculations and boundary assumptions in this utility align with recognized industry references including ISO 10303-21 (STEP AP214/AP242), ISO 16739-1 (IFC4 OpenBIM), ISO/ASTM 52900 (Additive Manufacturing), AIA CAD Layer Guidelines / ISO 19650. When preparing formal calculation packages or P.E. stamp submittals, always verify local jurisdictional code amendments and project-specific safety factors.
How should I integrate results from the AutoLISP Function Quick Reference into my CAD or BIM workflow?
Validate unit system headers ($INSUNITS in DWG/DXF, FILE_SCHEMA in STEP/IFC) and enforce watertight manifold topology before dispatching files to downstream CAM, 3D printing, or BIM coordination. Using the baseline benchmark (standard nominal boundary parameters for AutoLISP Function Quick Reference), the solver yields verified design compliance metrics for AutoLISP Function Quick Reference, which can be directly cross-referenced against your parametric 3D assembly constraints, 2D fabrication drawings, or bill of materials (BOM).