AfraLISP - Learn AutoLISP for AutoCAD productivity

AutoLISP Functions

by Kenny Ramage

An alphabetic list of AutoLISP functions.

Symbol A B C D E F G I L M N O P Q R S T U V W Z

Symbol

(*error* <STRING>)

User-definable error function.

(+ <NUMBER> <NUMBER> ...)

Returns the sum of two or more numbers.

(- <NUMBER> <NUMBER> ...)

Returns the difference of two or more numbers.

(* <NUMBER> <NUMBER> ...)

Returns the product of two or more numbers.

(/ <NUMBER> <NUMBER> ...)

Returns the quotient of two or more numbers.

(= <NUMBER> <NUMBER> ...)

Returns T if the numbers are equal, nil if not.

(/= <NUMB1> <NUMB2>)

Returns T if the numbers are not equal, nil if they are.

(< <NUMB1> <NUMB2>)

Returns T if <NUMB1> is less than <NUMB2>.

(<= <NUMB1> <NUMB2>)

Returns T if <NUMB1> is equal to or less than <NUMB2>.

(> <NUMB1> <NUMB2>)

Returns T if <NUMB1>is greater than <NUMB2>.

(>= <NUMB1> <NUMB2>)

Returns T if <NUMB1> is equal to or greater than <NUMB2>.

(~ <NUMBER>)

Returns the bitwise of <NUMBER>.

(1+ <NUMBER>)

Returns the <NUMBER> increased by one.

(1- <NUMBER>)

Returns the <NUMBER> decreased by one.

A

(abs <NUMBER>)

Returns the absolute value of <NUMBER>.

(and <EXPR> ...)

Returns the logical AND of a list of expressions. Returns nil if expressions are nil.

(angle <PT1> <PT2>)

Returns the angle in radians between two points.

(angtos <ANGLE>[<MODE><PRECIS.>])

Returns the angle as a string. Mode 0=Degrees,1=Deg Min Sec, 2=Grads,3=Radians,4=Surveyor

(append <EXPR> ....)

Returns a number of lists as one list.

(apply <FUNCTION> <LIST>)

Executes function with the arguments given as a list.

(ascii <STRING>)

Returns ascii value of first character of a string.

(assoc <ITEM><ALIST>)

Searches <ALIST> for <ITEM>.

(atan <NUM1> [<NUM2>])

Returns the arctangent of <NUM1> or <NUM1>/<NUM2>.

(atof <STRING>)

Returns the conversion of a string into a real.

(atoi <STRING>)

Returns the conversion of a string into an integer.

(atom <ITEM>)

Returns T if <ITEM> is not a list.

B

(Boole <FUNC> <NUMB1> <NUMB2)

Returns Boolean bitwise truth comparisons. <NUMB>'s must be integers.

(boundp <ATOM>)

Returns T if <ATOM> has a value bound to it.

C

(car <LIST>)

Returns the first element of a list.

(caar <LIST>)

Returns first element of the first element of a list.

(cadar <LIST>)

Returns last element of the first element of a list.

(cadr <LIST>)

Returns the second element of a list.

(caddr <LIST>)

Returns the third element of a list.

(cdr <LIST>)

Returns all but the first element of a list.

(cdar <LIST>)

Returns second element of the first element of list.

(cddr <LIST>)

Returns all but first element of last element list.

(chr <NUMBER>)

Returns the string represented by an ascii value.

(close <FILENAME>)

Closes a file.

(command <ARGS>...)

Executes an AutoCAD command.

(cond (<TEST1><RESULT1>)...)

Evaluates any number of lists as arguments.

(cons <NEW FIRST ELEMENT><LIST>)

Contructs a new list.

(cos <ANGLE>)

Returns the cosine of an angle.

D

(defun <SYM><ARG LIST><EXPR>...)

Defines an AutoLISP function.

(distance <PT1> <PT2>)

Returns the distance between two points.

E

(entnext [<ENAME>])

Returns the first non-deleted entity after <ENAME>.

(entlast)

Returns the last non-deleted entity in the database.

(entsel [<PROMPT>])

Selects a single entity by a point pick.

(entdel <ENAME>)

Deletes the entity <ENAME> or undeletes it if it

has already been deleted.

(entget <ENAME>)

Returns <ENAME> from the database as a list.

(entmod <ENAME>)

Updates <ENAME> in the database. NOT for blocks or polylines

(entupd <ENAME>)

Updates <ENAME> in the database. Use for polylines or blocks.

(eq <EXPR1> <EXPR2>)

Returns T if expressions are bound to same object.

(equal <EXPR1> <EXPR2>)

Returns T if the expressions are equal.

(eval <EXPR>)

Evalutes an expression.

(exp <NUMBER>)

Returns E to the power <NUMBER>.

(expt <BASE> <NUMBER>)

Returns <BASE> to the power <NUMBER>.

F

(findfile <FILENAME>)

Searches all paths to find <FILENAME>.

(fix <NUMBER>)

Converts <NUMBER> to an integer.

(float <NUMBER>)

Converts <NUMBER> to a real.

(foreach <NAME><LIST><EXPR>)

Evaluates <EXPR> for each element in the <LIST> and assigns to <NAME>.

G

(gcd <NUM1> <NUM2>)

Returns the greatest common denominator.

(getangle [<PT>][<PROMPT>])

Pauses for input of an angle at optional starting point <PT>.

(getcorner [<PT>][<PROMPT>])

Getpoint function - draws triangle as crosshairs move.

(getdist [<PT>][<PROMPT>])

Pauses for input of distance at optional start point.

(getenv [<VARIABLE>])

Returns string value assigned to a system variable.

(getkword [<PROMPT>])

Requests a keyword from the user.

(getorient [<PT>][<PROMPT>])

Returns angle in radians from current orientation.

(getpoint [<PT>][<PROMPT>])

Pauses for input of an angle at optional point <PT>.

(getreal [<PROMPT>])

Pauses for input of a real number.

(getstring [<CR>][<PROMPT>])

Pauses for input of a string.

(getvar <varname>)

Retrieves the value of an AutoCAD system variable.

(graphscr)

Flips from text screen to graphics screen.

(grclear)

Clears the graphics screen.

(grdraw <from><to><color>[<highlight>])

Draws a vector between two points.

(grtext <box><text><highlight>])

Write to text portion of graphics screen.

(grread <track>)

Allows AutoLISP to read AutoCADs input devices.

I

(if <testexpr><thenexpr>[<elseexpr>])

Conditionally evaluates expressions.

(inters <pt1><pt2><pt3><pt4>[<onseg>])

Returns the intersection point of two lines. If <ONSEG> is greater than 0 the intersection may lie past the endpoints of the lines.

(itoa <number>)

Returns the conversion of an integer to a string.

L

(lambda <arguments><expr>...)

Defines an "anonymous" function.

(last <list>)

Returns the last element in <LIST>.

(length <list>)

Returns the number of elements in <LIST>.

(list <expr>)

Returns the list of a number of expressions.

(listp <list>)

Returns T if the item is a list.

(load <filename>)

Loads an AutoLISP program in memory.

(log <number>)

Returns natural log of <NUMBER> as a real.

(logand <number><number>...)

Returns the logical bitwise AND of a list of numbers.

(logior <number><number>...)

Returns the logical bitwise OR of a list of numbers.

(lsh <numb1><numbits>)

Returns the logical bitwise SHIFT operator of <NUM1> by <NUMBITS>

M

(mapcar <function><list1>...<listn>)

Executes <FUNCTION> on the elements of <LIST1> through <LIST2>.

(max <number><number>...)

Returns the maximum of the numbers given.

(member <expr><list>)

Searches <LIST> for first occurence of <EXPR> and returns the remainder of the list.

(menucmd <string>)

Switch between pages in an AutoCAD menu.

(min <NUMBER><NUMBER>...)

Returns the smallest of the numbers given.

(minusp <ITEM>)

Returns T if the item is negative.

N

(not <ITEM>)

Returns T if the expression is nil.

(nth <n><LIST>)

Returns the "nth" element of <LIST>.

(null <ITEM>)

Returns T if <ITEM> is bound to nil.

(numberp <ITEM>)

Returns T if <ITEM> is an integer or a real.

O

(open <FILENAME><MODE>)

Opens a file.

(or <EXPR>...)

Returns the logical OR of a list of expressions.

(osnap <PT><MODE-STRING>)

Returns a point by applying the osnap command.

P

(polar <PT><ANGLE><DISTANCE>)

Returns point at <ANGLE> and <DISTANCE> from <PT>.

(prin1 <EXPR>[<FILENAME>])

Prints <EXPR> on the screen or to <FILENAME>.

(princ <EXPR>[<FILENAME>])

Same as prin1 except control character are printed without expansion.

(print <EXPR>[<FILENAME>])

Same as prin1 except a new line is printed before <EXPR> and a space is printed after.

(progn <EXPR>...)

Evalutes each expression sequentially.

(prompt <MSG>)

Displays <MSG> on the screen PROMPT area.

Q

(quote <EXPR>)

Returns <EXPR> unevaluated.

R

(read <STRING>)

Returns the first LIST obtained from <STRING>.

(read-char [<FILENAME>])

Returns a character from the keyboard buffer or from <FILENAME>.

(read-line [<FILENAME>])

Returns a string from the keyboard buffer or from <FILENAME>.

(redraw [<ENAME>][<MODE>])

Redraws either entire drawing, or <ENAME> in <MODE>.

(rem <NUM1> <NUM2> ...)

Returns the remainder of <NUM1>/<NUM2>.

(repeat <NUMBER> <EXPR> ...)

Evaluates each expression <NUMBER> times.

(reverse <LIST>)

Returns a list reversed.

(rtos <NUMBER> [<MODE><PRECIS>])

Returns a real number as a string.

S

(set <SYM><EXPR>)

Sets the value of a sysmbol name.

(setq <SYM1><EXPR1>...)

Sets the value of <SYM1> to <EXPR1>.

(setvar <VARNAME><VALUE>)

Sets a system variable to <VALUE>.

(sin <ANGLE>)

Returns the sine of an angle.

(sqrt <NUMBER>)

Returns the square root of <NUMBER>.

(ssget [<MODE>][<PT1><PT2>])

Returns a selection set.

(sslength <SS>)

Returns the number of entities in selection set <SS>.

(ssname <SS><INDEX>)

Returns the name of the <INDEX>th entity in selection set <SS>.

(ssadd [<ENAME>][<SS>])

Adds entities to selections sets.

(ssdel [<ENAME>][<SS>])

Deletes entities from selections sets.

(ssmemb [<ENAME>][<SS>])

Returns <ENAME> if <ENAME> is a member of selections set <SS>.

(strcase <STRING>[<WHICH>)]

Returns <STRING> as upper case if <WHICH> is nill. If <WHICH> is not nill the returned string will be all lower case.

(strcat <STRING1><STRING2>..)

Concatenates a series of strings.

(strlen <STRING>)

Returns the number of characters in a string.

(subst <NEWITEM><OLDITEM><LIST>)

Substitutes <NEWITEM> for <OLDITEM> in <LIST>.

(substr <STRING><START><LENGTH>)

Returns a substring of <STRING> begining at <START> of <LENGTH> characters.

T

(tblnext <NAME> [<rewind>])

Scans symbol table for next entity.

(tblsearch <NAME><SYM>[<setnext>])

Searches entire symbol table for <NAME>.

(terpri)

Prints a new line on the screen.

(textscr)

Flips from graphics screen to text screen.

(trace <FUNCTIONS>...)

Debugging aid that returns the last function name.

(trans <PT><FROM><TO>[<DISP>])

Translates a point <PT> from one coordinate system to another.

(type <ITEM>)

Returns the type of <ITEM>.

U

(untrace <FUNCTIONS>...)

Clears the trace floag for <FUNCTIONS>.

V

(ver)

Returns AutoLISP version number.

(vmon)

Enables AutoLISP virtual function pager.

(vports)

Returns a list of currently active viewports.

W

(while <TESTEXPR><EXPR>)

Evaluates <TESTEXPR> and if not nill executes <EXPR>.

(write-char <NUM> [<FILENAME>])

Writes the character represented by the ASCII value of

<NUM> to the screen or to <FILENAME>.

(write-line <STRING> [<FILENAME>])

Writes <STRING> to the screen or to <FILENAME>.

Z

(zerop <ITEM>)

Returns T if <ITEM> evaluates to zero.