Lisp Functions Overview

In the following, an symbol labels an argument description.

Due to better readability, in the names of some functions not only lower but also upper case characters are used. You can, however, use either case in function calls.


 

Function Definitions

Function Description
(defun symbol argument_list term...) Defines a command or function

Error Handling

Function Description
(alert string string string) Displays a message box
message
title
system icon
(*settrace* [<integer> [integer]]) Sets the mode for tracing of Lisp routines and functions.
trace mode flag
react time in seconds
(trace symbol) Provides a debugging aid that displays the return value each time the specified function is evaluated.
function
(untrace symbol) Clears the debugging mode for the specified function.
function
(*error* <string>) ... is the function for Error-Handling
error message

        ^ Top of Page

System Functions

Function Description
(command arguments ...) Executes a built-in command with the arguments supplied
(delcmd string) Deactivates a specified command
command name
(actcmd string) Re-activates a specified command
command name
(getcname string) Retrieves the primary (underscored) name of a built-in command. A primary command has always an English name
command name
(getvar string) Retrieves system variable settings
variable name
(setvar string value) Sets a system variable to a specified value
variable name
variable value
(findfile string [value]) Searches for a file
file name
condition
(getfiled string string string integer) Provides a dialog for file selection
Dialog caption
Preset filename
Preset extension
Control flag
(getcolorindex [point_list] [flag]) Displays the Colors dialog box allowing the user to select a color
(initdia [flag]) Determines that certain commands which normally invoke a dialog box be performed at the command line when flag is set to 0.

        ^ Top of Page

Geometric Utilities

Function Description
(distance point_list point_list) Calculates the distance between two given points
starting point
end point
(angle point_list point_list) Calculates the angle between two point
starting point
end point
(polar point_list real real) Returns a 3D point
point
angle
distance
(inters point_list point_list point_list point_list [value]) Returns the intersection of two lines each specified by two endpoints
(osnap point_list string) Snaps to a significant point on an entity (object snap)
(textbox list) Returns the corners of a bounding box of a text entity

        ^ Top of Page

User Input

Function Description
(initget [integer] [string]) Initializes the next user input function
(getreal [string]) Prompts the user to enter a real number
(getstring [value] [string]) Prompts the user to enter a string
(getpoint [point_list] [string]) Prompts the user to specify a point
(getcorner point_list [string]) Prompts the user to specify a second corner of an rectangle
(getdist [point] [prompt]) Prompts the user to specify a distance
(getangle [point_list] [string]) Prompts the user to specify an angle
(getorient [point_list] [string]) Prompts the user to specify an angle takes into account ANGBASE)
(getkword [string]) Prompts the user to select an option
(getint [string]) Prompts the user to enter an integer value

        ^ Top of Page

Conversion

Function Description
(rtos real [integer [integer]]) Real number to String conversion
floating-point number
mode
precision
(distof string [integer]) Distance to Float conversion
(angtos real [integer [integer]]) Angle to String conversion
angle
mode
precision
(angtof string [integer]) Angle to Float conversion
(symbtos value) Returns any Lisp expressions in a string

        ^ Top of Page

Coordinate System Transformation

Function Description
(trans point_list value value integer) Transforms a point from one coordinate system to another
point
from
to
transformation

        ^ Top of Page

Selection Sets

Function Description
(ssget [string] [point [point]] [point_list] [assoc_list]) Creates a selection set.
. mode
point
point
point list
filter list
(ssadd [Ename [SelSet]]) Adds an entity to a selection set
entity name
selection set
(ssdel Ename SelSet) Deletes an entity from a selection set
entity name
selection set
(sslength SelSet) Returns the length of a selection set
selection set
(ssname SelSet integer) Returns the n-th element of a selection set
selection set
element number
(ssmemb Ename SelSet) Verifies if an entity is member of a selection set
entity name
selection set
(ssdbno SelSet) Returns the drawing database number (id) the selection set belongs to
selection set

        ^ Top of Page

Entity Handling

Function Description
(entget Ename [list]) Returns entity information
(entmod list) Modifies an entity
(entmake [list]) Creates an entity
(entmakex list) Creates a new entity (graphical or non-graphical) with a data list
(entdel Ename) Deletes an entity
(entnext [Ename]) Returns the entity name that follows the given entity in the drawing database
(entlast) Returns the last entity added to the drawing database
(handent string) Returns the entity name to the entity that has the specified reference
(entsel [string]) Prompts the user to select an entity
(entupd Ename) Updates an complex entity after modifications
(entpos integer) Sets the database pointer

        ^ Top of Page

Drawing Database Symbol Tables

Function Description
(tblnext string [value]) Returns the next table-entry
(tblsearch string string) Searches a table-entry
(tblmake list) Generates a new table-entry
(tblmod list) Modifies a table-entry
(tblset string string) Sets an entry as the current
(tblrename string string string) Renames a table-entry
(tbldel string string) Deletes a table-entry
(tblpurge string flag) Deletes all not referenced entries of a table
(tblobjname string string) Returns the entity name (Ename) of a given drawing database table entry
(snvalid string [flag]) Tests whether a drawing database symbol table entry has valid characters

        ^ Top of Page

Dictionaries

Function Description
(dictadd dictionary item newobj) Adds a non-graphical object to the specified dictionary
(dictnext dictionary [flag]) Retrieves the next item in a dictionary
(dictremove dictionary item) Removes an entry from the specified dictionary
(dictrename dictionary old new) Renames an item of a dictionary
(dictsearch dictionary item [next]) Searches a dictionary for an item
(namedobjdict) Returns the entity name of the current drawing's named object dictionary, which is the root of all non-graphical objects in the drawing

        ^ Top of Page

Extended Entity Data

Function Description
(regapp string) Registers an application name
(xdroom entity) Determines the free space size in bytes available for an extended entity data
(xdsize list) Determines the size in bytes necessary to keep an extended entity data

        ^ Top of Page

Arithmetical Functions

Function Description
(+ number number ...) Addition
(- number number ...) Subtraction
(* numbernumber ...) Multiplication
(/ number number ...) Division
(~ integer) Bitwise NOT
(1+ number) Increment
(1- number) Decrement
(abs number) Absolute value of a number
(atan number [number]) Arc tangent of an angle supplied in radians
(cos number) Cosine of an angle
(exp number) Returns e raised to power number, where e is the base of the natural logarithm
(expt number1 number2) Returns number1 to number2
(fix number) Converts a real number to an integer
(float number) Converts a given number into a real number
(gcd number number ...) Returns the greatest common denominator of the given numbers
(log number) Returns the natural logarithm of a given number
(logand integer integer ...) Logical bitwise AND
(logior integer integer ...) Logical bitwise OR
(lsh integer integer) Logical bitwise shift
(max number number ...) Returns the largest number
(min number number ...) Returns the smallest number
(minusp number) Tests if the number is negative
pi Constant 3.141593
(rem number1 number2) Divides number1 by number2 and returns the remainder
(sin number) Sine of an angle
(sqrt number) Square root of a number
(tan number) Tangent of an angle
(zerop number) Zero or floating-point zero

        ^ Top of Page

Symbol Handling

Function Description
(atom term) Returns T if term is an atom
(atoms-family 0|1 [string_list]) Returns a list of all atoms currently defined
(boundp value) Tests if the specified atom has a value
(not argument) Returns T if argument is nil
(null object) Returns T if argument is nil
(numberp object) Returns T if its argument is any kind of number
(quote object) Simply returns object
'object Identical to (quote ...)
(set symbol value) Sets the value of an quoted symbol to an expression
(setq symbol value [symbol value] ...) Sets the value of a symbol to an expression
(type object) Returns the data type

        ^ Top of Page

Display Control

Function Description
(prin1 [object [FileDescriptor]]) Prints a message in the Command Window or writes it to an open file
(princ [object [FileDescriptor]]) Prints a message in the Command Window or writes it to an open file
(print [object [FileDescriptor]]) Prints a message in the Command Window or writes it to a file (like prin1, but with a preceding CR and a space following)
(prompt string) Displays a message in the Command Window
(terpri) Outputs a new-line in the Command Window
(grread [integer [integer]]) Reads from an input device
draw mode
cursor type
(redraw [string [integer]]) Refreshes the current drawing display or redraw an entity
entity name
mode
(graphscr) Closes the Command Window
(textscr) Opens the Command Window
(textpage) Opens the Command Window

        ^ Top of Page

Text Strings

Function Description
(read string) Retrieves the first atom or list from the given string and returns it according to its data type
(read-char [FileDescriptor]) Reads a single character from either the keyboard buffer or from an open file optionally
(read-line [FileDescriptor]) Reads a string from the keyboard buffer or from an open file optionally
(strcase string [value]) Converts a given string to a new upper case or lower case string
(strcat string string ...) Returns a new string concatenating two or more strings
(strlen string string ...) Returns the sum of the length (number of characters) of all strings given as argument to the function
(substr string integer [integer]) Returns a new - partial - string based on a given string
(write-char integer [FileDescriptor]) Writes a single character to a file displays it in the Command Window
(write-line string [FileDescriptor]) Writes a string to a file or displays it in the Command Window
(stringsort list) Sorts a list of string-items alphabetically, ascending
(acad_strlsort list) Sorts a list of strings in alphabethical order
(wcmatch string string) Allows a wild card pattern match search on a string

        ^ Top of Page

String Processing Functions

Function Description
(vl-string->list string) Converts a string to a list of character codes
(vl-string-elt string position) Returns an ASCII code of the character at a specified position (the first character is position 0)
(vl-string-left-trim characters string) Removes the specified characters from the beginning of a string
(vl-string-mismatch string1 string2 [position1 [position2 [case_flag]]]) Returns the length of the longest common substring of two text strings, starting at specified positions
(vl-string-position code string [position [backward]]) Searches a string for a character with a specified code, starting at a specified position. Both forward and backward searches are possible
(vl-string-right-trim characters string) Removes the specified characters from the end of a string
(vl-string-search pattern string [position]) Searches a string for a specified pattern, starting at a specified position
(vl-string-subst new pattern string [position]) Substitutes a character sequence within a string for another, starting at a specified position

(vl-string-translate set1 set2 string) Replaces characters of one set in a string with characters of another set
(vl-string-trim characters string) Removes the specified characters from the beginning and end of a string

        ^ Top of Page

Type Conversion

Function Description
(ascii string) Converts the first character of string into its ASCII-Code that is returned as integer
(atof string) Converts a given string to a floating-point number that is returned
(atoi string) Converts a given string to an integer
(chr integer) Converts an ASCII code (given as integer) into its equivalent single-character-string
(itoa integer) Returns the given integer as string

        ^ Top of Page

Comparison / Conditions

Function Description
(= atom atom ...) Comparison: Equal
(/= atom atom ...) Comparison: Not equal
(< atom atom ...) Comparison: Less than
(<= atom atom ...) Comparison: Less than or equal
(> atom atom ...) Comparison: Greater than
(>= atom atom ...) Comparison: Greater than or equal
(and term term ...) Logical AND
(or value value ...) Logical OR
(boole bit_value integer integer ...) Performs a general bitwise Boolean function
(eq term term) Evaluates if two terms are identical
(equal value value [number]) Tests if two expressions have the same result
(cond
    (value value value ... )
    [(value value value ... )] ...
)
Is the primary conditional function
(if <value> <value>
    [<value> value value [value]
)
Performs an conditional evaluation
test expression
then expression
[else expression]
(repeat integer value ...) Executes a given expression n times
(while value value ...) The while construct allows iteration to continue until the specified expression evaluates to nil

        ^ Top of Page

List Handling and Manipulation

Function Description
(append list list ...) Adds any number of lists together. Returns a new list
(assoc value assoc_list) Searches an association list assoc_list for key
(car list) Returns the first element of an list
(cdr list) Returns a new list without the first element of a given list
(c????r list) Combinations of car and cdr up to four levels
(cons value list|atom) Constructs a new list
(foreach symbol list value ...) Steps through a given list assigning each element to the specified symbol and evaluating the specified expression for each element of the list
(last list) Returns the last element of a list
(length list) Returns the number of elements in a list
(list value ...) Creates a list out of expressions supplied as arguments to the function
(listp value) Verifies if element is a list
(mapcar func_symb list_1 ... list_n) Operates on successive elements of the lists list_1 ... list_n
(member value list) Searches the given list for an element and returns the remaining portion of the list
(nth integer list) Returns the nth element of list (n counting starts with 0)
(reverse list) Reverses the given list and returns a new list
(subst old_element new_element list) Copies a list substituting old_element by new_element

        ^ Top of Page

File Access and Handling

Function Description
(close FileDescriptor) Closes the specified open file
(load FileName [value]) Loads an existing Lisp file
(open FileName FileMode) Open the specified file to read or write.
FileMode can be:
     "r" open file to read<br />
     "w" open file to write<br />
     "a" open file to append
(vl-file-copy source destination [append]) Copies the contents of a source file to a destination file
(vl-file-delete file) Removes the file with a specified name
(vl-file-directory-p name) Verifies if the argument is a folder name
(vl-file-rename old new) Renames a file or a folder
(vl-file-size name) Determines the size of a file in bytes
(vl-file-systime name) Determines the date and time when a file has last been modified
(vl-filename-base name) Extracts the plain file name (without path and extension) from a file name
(vl-filename-directory name) Extracts out the path from a full file name
(vl-filename-extension name) Returns the extension of a file name
(vl-filename-mktemp [pattern] [folder [extension]]) Calculates a unique file name(i.e., different from names of the existing files) for a temporary file

        ^ Top of Page

Function Handling

Function Description
(apply func_symbol list) Executes a function, where arguments are taken from list
(eval value) Returns the result of a Lisp expression
(exit) Terminates the current application
(lambda argument_list value ...) Allows the definition of an anonymous function
(progn value value ...) Evaluates one expression after the other grouped in progn.
(quit) Terminates (cancels) the current application and returns to the command prompt.
(*settrace* [integer [integer]] ) Sets the mode for tracing of Lisp routines and functions.
Trace mode
Time in seconds

        ^ Top of Page

Application Handling

Function Description
(ver) Returns a string containing the information on the current version of the Lisp Interpreter
(getenv [string] [string] [string]) Retrieves a string value assigned to
  • a list containing the environment variables as found in the "CAD Path" section of the application INI file
  • a certain environment variable from the "CAD Path" section of the application INI file,
  • a specific registration within an ASCII configuration file (like an INI or other parameter file), or
  • a system environment variable
(setenv name value) Assigns a new value to a specified environment variable
(getcfg string) Retrieves application data from the [APPDATA] section of the appdata.ini file
(setcfg string string) Writes application data to the section [APPDATA] of the appdata.ini file

        ^ Top of Page

Help

Function Description
(help [string [string [string]]]) Calls WinHelp with a specified help topic
Topic
Help filename
Command
(setfunhelp string string string) Set a help topic belonging to a function
Function
Topic
Helpfile

        ^ Top of Page

Dialog Box Functions

Function Description
(load_dialog string) Loads a dialog box description file (file of type .dcl)
File name
(unload_dialog number) Unloads a dialog box
ID
(new_dialog dialog_name dialog_id [default_action [position]]) Displays a dialog box
(start_dialog) Starts the dialog box
(done_dialog [flag]) Terminates the dialog box
status
(term_dialog) Terminates all dialog boxes
(action_tile key expression) Respond when a dialog box tile is clicked
(mode_tile key mode) Sets the mode of a dialog box tile
(get_tile key) Determines the value a tile of a dialog box is set to
(get_attr key) Determines the attribute a key of a dialog box is set to
(set-tile key value) Sets the value of a dialog box tile
(client_data_tile tile_key data) Associates data with a dialog box tile

        ^ Top of Page

Viewports / Views Handling

Function Description
(vports) Returns a description of all Viewports in the current drawing
(setview list [viewport_id]) Establishes a 3D view for a specified viewport of the current drawing

        ^ Top of Page

Application Utility Functions

Function Description
(acad_colordlg number [flag]) Displays the color selection dialog box
(startapp string [string]) Executes an external OS application
(menugroup group) Verifies that a menu group is loaded

        ^ Top of Page

Windows® Registry Handling Functions

Function Description
(vl-registry-write key [entry [value]]) Creates a Windows® registry key or writes an entry with a specified value
(vl-registry-read key [entry]) Reads a Windows® registry key entry
(vl-registry-delete key [entry]) Deletes a Windows® registry key or removes an entry from a Windows® registry key
(vl-registry-descendents key [flag]) Lists the subkeys of a key or the entries of a key from the Windows® registry

        ^ Top of Page

Curve and Entity Analyzing Functions

Function Description
(vlax-curve-getArea ename) Calculates the area inside a curve or polyline
(vlax-curve-isClosed ename) Determines whether an entity is closed (that is, its start and end point coincide)
(vlax-curve-isPlanar ename) Determines whether an entity is planar
(vlax-curve-isPeriodic ename) Determines whether a curve is periodic
(vlax-curve-getStartPoint ename) Finds coordinates of the start point of a specified entity
(vlax-curve-getEndPoint ename) Finds the coordinates of the end point of a specified entity
(vlax-curve-getPointAtDist ename distance) Finds the coordinates of the point on an entity and at a specified distance from the start point
(vlax-curve-getDistAtPoint ename point) Finds the distance between the start point of an entity and a specified point on the entity
(vlax-curve-getClosestPointTo ename point [extension]) Finds the coordinates of the point that is on an entity and is the closest to a specified point
(vlax-curve-getClosestPointToProjection ename point normal [extension]) Finds the coordinates of the point that is on an entity and, after projection onto a specified plane, is the closest to a specified point
(vlax-curve-getStartParam ename) Calculates the value of the parameter at the start point of a specified entity
(vlax-curve-getEndParam ename) Calculates the value of the parameter at the end point of a specified entity
(vlax-curve-getParamAtDist ename distance) Calculates the value of the parameter at a point that is at a specified distance from the starting point on a specified entity
(vlax-curve-getParamAtPoint ename point) Calculates the value of the parameter at a specified point on a specified entity
(vlax-curve-getDistAtParam ename parameter) Calculates the length of the section of an entity between start point and the point which has a specified value of the parameter
(vlax-curve-getPointAtParam ename parameter) Finds a point of an entity which has a specified value of the parameter
(vlax-curve-getFirstDeriv ename parameter) Computes the first derivative at a specified point on a specified entity
(vlax-curve-getSecondDeriv ename parameter) Computes the second derivative at a specified point on a specified entity

        ^ Top of Page

Memory Management (Legacy)

Function Description
(mem) Displays the memory status for Lisp. Returns always nil.
(vmon) Provided for compatibility with other Lisp implementations (virtual memory management). Returns always nil.
(alloc integer) Provided for compatibility with other Lisp implementations (memory allocation function). Returns always 0.
(expand integer) Provided for compatibility with other Lisp implementations (memory expansion function). Returns always 0.
(gc) Provided for compatibility with other Lisp implementations ("garbage collection"; memory release function). Returns always nil.

        ^ Top of Page