Sei sulla pagina 1di 6

AutoLISP Functions

(getreal [prompt])

This describes all of the functions provided by AutoLISP It consists of a synopsis and a catalogue of the functions. In the synopsis, function names are grouped by topic, and each is followed by a brief description. In the catalogue, function names appear in alphabetical order, and the functions are described in detail.

(getstring [cr][prompt]) (getpoint [pt][prompt])

Prompts for user input of a real (floating-point) number. Prompts for user input of a string. Prompts for user input of a point. Prompts for user input of the corner of a rectangle. Prompts for user input of a distance. Prompts for user input of an angle. Similar to getangle, but takes into account the current value of the ANGBASE system variable. Prompts for user input of a keyword. Prompts for user input of an integer.

Synopsis of Functions
(defun sym argument-1ist expr ...)
Defines an external function (Subr).

(getcorner pt [prompt]) (getdist [pt] [prompt])

Error Handling
(*error* string) (alert string)
Prints an error message. Displays a dialogue box alerting the user with string.

(getangle [pt] [prompt])

(getorient [pt] [prompt])

(getkword [prompt]) (getint [prompt])

AutoCAD Queries and Commands


(command [arguments] ...) (getvar varname) (setvar varname value) (findfile filename)
Executes one or more AutoCAD commands. Gets the current value of an AutoCAD system variable. Sets the value of an AutoCAD system variable. Searches for a filename. Prompts the user for a filename via the standard AutoCAD file dialogue box. Finds a point via object snap.

Conversion
(rtos number [mode [precision]]) (distof string [mode])
Formats a real (floating-point) value as a string. Converts a string that displays a real value into a real (floating-point) value. Formats an angle as a string. Converts a string that displays an angle into a real (floating-point) value. Converts between real-world units.

(angtos angle [mode [precision]]) (angtof string [mode]) (cvunit value from to)

(getfiled title filename ext flags)

(osnap pt1 mode-string)

Co-ordinate System Transformation


(trans pt from to [disp])
Translates a point or displacement from one co-ordinate system to another.

Geometric Utilities
(distance pt1 pt2) (angle pt1 pt2) (polar pt angle dist)
Finds the distance between two points. Finds the angle between two lines. Finds a point via polar co-ordinates. Finds the intersection of two lines. Returns the diagonal co-ordinates of a box that encloses a text entity.

Display Control

(prin1 [expr [file-desc]]) (princ [expr [file-desc]]) (print [expr [file-desc]]) (prompt msg)

(inters pt1 pt2 pt3 pt4 [onseg]) (textbox elist)

Prints a message on the text screen or to an open file. Prints a message on the text screen or to an open file. Prints a message on the text screen or to an open file. Displays a message on the prompt line. Displays and activates menus.
Page 1

User Input
(initget [bits] [string])
Determines valid user input for the next call to a get xxx function.

(menucmd string)

(redraw [ename [mode]]) (graphscr) (textscr) (textpage)

Redraws the current graphics screen. Displays the current graphics screen. Displays the current text screen. Same as textscr, but clears the text screen first.

(entdel ename) (entnext [ename]) (entlast) (handent handle) (entsel [prompt]) (nentsel [prompt])

Deletes (and undeletes) entities in the drawing. Finds the next entity in the drawing.

Finds the last entity in the drawing. Finds an entity by its handle. Prompts user to select an entity by specifying a point. Like entsel, but returns additional data for nested entities. Similar to nentsel but returns a full 3D 4x4 matrix and enables the program to specify the pick point. Updates the screen image of an entity.

Low-level Graphics
(grclear)
Clears the graphics screen. Draws a vector in the current viewport. Draws multiple vectors in the current viewport. Reads from an input device. Displays text in the menu, mode, or status area of the graphics screen.

(grdraw from to colour [highlight]) (grvecs vlist [trans])

(nentselp [prompt] [pt])

(grread [track] [allkeys [curtype]]) (grtext [box text [highlight]])

(entupd ename)

Extended Entity Data


(regapp application) (xdsize list)
Registers the applications extended entity data. Returns the amount of memory (in bytes) that a list of extended entity data will occupy. Returns the amount of memory (in bytes) that an entity has available for extended data.

Wild Card Matching


(wcmatch string pattern)
Matches a string to a wild card pattern.

Selection Sets

(ssget [mode] [pt1 [pt2]] [pt-list] [filter-list]) (ssadd [ename [ss]]) (ssdel ename ss) (sslength ss) (ssname ss index) (ssmemb ename ss)
Gets a selection set. Adds an entity to a selection set (or creates a new set). Deletes an entity from a selection set. Returns the number of entities in a selection set. Returns the name of an entity in a selection set. Checks whether an entity is a member of a selection set.

(xdroom ename)

Symbol Tables
(tblnext table-name [rewind])
Finds the next item in a symbol table. Searches for a symbol in a symbol table.

(tblsearch table-name symbol [setnext])

General Functions Arithmetic


(+ number number ...)
Returns the sum of all numbers. Subtracts the second number from the first and returns the difference. Returns the product of all numbers. Divides the first number by the second and returns the quotient. Returns the bitwise NOT of number. Returns number incremented by 1.
Page 2

Entity Handling
(entget ename [applist]) (entmod elist) (entmake [elist])
Gets the definition data of an entity. Modifies the definition data of an entity. Makes a new entity and appends it to the drawing database.

(- number [number ....]) (* number [number ...]) (/ number [number ...]) (~ number) (1+ number)

(1- number) (abs number) (atan num1 [num2]) (cos angle) (exp number) (expt base power) (fix number) (float number)
(gcd num1

Returns number decremented by 1. Returns the absolute value of number. Returns the arctangent of a number in radians. Returns the cosine of an angle. Returns a value raised to the number power (natural antilog). Returns base raised to power. Returns the conversion of a number into an integer. Returns the conversion of a number into a real value. Returns the greatest common denominator of two numbers. Returns the natural log of a number as a real value. Returns the result of a logical bitwise AND of a list of numbers. Returns the result of a logical bitwise inclusive OR of a list of numbers. Returns the logical bitwise shift of a number by a given number of bits. Returns the largest of the numbers given. Returns the smallest of the numbers given. Verifies that I t em is a real or integer and evaluates to a negative value. Evaluates to constant p. Divides two numbers and returns the remainder. Returns the sine of an angle as a real value. Returns the square root of a number as a real value. Verifies that item is a real number or an integer that evaluates to zero.

(atom item)

(atoms-family format [symlist]) (boundp atom) (not item) (null item) (numberp item) (quote expr ...) (set sym expr)

Verifies that item is an atom. Returns a list of previously defined functions. Verifies that a value has been bound to an atom. Verifies that item is nil. Verifies that item is bound to fill. Verifies that item is a real or an integer. Returns an expression unevaluated. Sets the value of a quoted symbol to that of an expression. Sets the value of one or more symbols to that of an expression. Returns the type of I t em.

num2)

(setq sym1 expr1 [sym2 expr2] ...) (type item)

(log number)

(logand number number ...) (logior integer ...) (lsh num1 numbits)

Text Strings
(read string) (read-char [file-desc]) (read-line [file-desc])
Returns the first list or atom obtained from the string. Reads a single character from the keyboard or from an open file. Reads a string from the keyboard or from an open file. Returns a copy of a string with all characters converted to upper or lowercase. Returns the concatenation of one or more strings. Returns the length, in characters, of a string. Returns a substring of a string. Writes one character, described by an ASCII code, to the screen or an open file. Writes a string to the screen or to an open file.

(max number number ...) (min number number ...) (minusp item) pi (rem num1 num2 ...) (sin angle) (sqrt number) (zerop item)

(strcase string [which])

(strcat string1 [string2]) (strlen [string])

(substr string start [length]) (write-char num [file-desc])

(write-line string [file-desc])

Symbol Handling

Page 3

Conversion
(ascii string)
Returns the conversion of the first character of a string into its ASCII character code. Returns the conversion of a string into a real value. Returns the conversion of a string into an integer. Returns the conversion of an integer representing an ASCII character code into a single character string. Returns the conversion of an integer into a string.

List Manipulation
(append expr) (assoc item alist)
Takes any number of lists and runs them together as one list. Searches an association list using I tern as a key, and returns the associated entry. Returns the first element of a list. Returns a list containing all but the first element of the list. Concatenations up to four levels deep are supported. Returns a list with the new element added to the beginning. Steps through a list and evaluates each expression for every element in the list. Creates a list from any number of expressions.

(atof string) (atoi string) (chr integer)

(car list) (cdr list)

(itoa int)

(caar list), (cadr list), (cddr list), (cadar list), etc. (cons new-first-element list) (foreach name list expr ...)

Equality/Conditional
(= atom atom . .) (/= atom atom . . (< atom atom ...) (<= atom atom) (> atom atom . . (>= atom atom) (and expr ...)
The equal to relational function. The not equal to relational function. The less than relational function. The less than or equal to relational function. The greater than relational function. The greater than or equal to relational function. Returns the logical AND of a list of expressions. A general bitwise Boolean function. Primary conditional function in Autolisp. Determines whether two expressions are identical. Determines whether two expressions evaluate to the same thing. Conditionally evaluates expressions. Returns the logical OR of a list of expressions. Evaluates each expression a given number of times. Repeats the enclosed expressions while the test expression remains true.

(list expr ...)

(listp item)

(mapcar function list1 ... listn)

Verifies that Item is a list. Returns a list as the result of executing a function with the elements of lists supplied. Searches a list for an occurrence of an expression and returns the remainder of the list starting with the first occurrence of the expression. Returns the nth element of a list. Returns a list with its elements reversed. Returns a copy of a list with newitem in place of every olditem.

(member expr list)

(Boole func int1 int2 ...)

(nth n

list)

(cond (test1 result1.....).....) (eq expr1 expr2)

(reverse list)

(subst newitem olditem list)

(equal expr1 expr2 [fuzz])

File Handling
(close file-desc)
Closes a file. Loads a file of AutoLISP expressions. Opens a file for access by the AutoLISP I/O functions.

(if testexpr thenexpr [elseexpr]) (or expr ...)

(load filename [on failure]) (open filename mode)

(repeat number expr ...) (while testexpr expr ...)

Page 4

Display
(terpri) (vports)
Prints a newline on the screen. Returns a list of viewport descriptors for the current viewport configuration.

Function Handling
(apply function list) (eval expr) (exit)

Executes a function with the arguments given. Returns the result of evaluating any AutoLISP expression. Forces the current application to quit. Defines an anonymous function. Evaluates sequentially. each expression

(lambda arguments expr ...) (progn expr ...) (trace function ...) (quit) (untrace function ...)

Sets the trace flag for the specified functions. Forces the current application to quit. Clears the trace flag for specified functions.

Memory Management
(alloc number) (expand number) (gc) (mem)
Sets the segment size to a given number of nodes. Allocates node space by requesting a specified number of segments. Forces a garbage collection. Displays the current state of AutoLISPs memory.

Miscellaneous
(getenv variable-name) (ver)
Returns the string value assigned to a system environment variable. Returns a string containing the current AutoLISP version.

Page 5

Programmable Dialogue Box Functions


Detailed explanations of the following AutoLISP functions, which handle user-defined, customised dialogue boxes, are available in chapter 9 of the AutoCAD Customisation Manual This section summarises the functions in the Programmable Dialogue Box (PDB) package, grouping them by functionality. These functions call an associated DCL (Dialogue Control Language) file to display the desired dialogue box. It shows the arguments to each function.

Setting Up List Boxes and Popup Lists


(start_list key [operation [index]]) (add_list item) (end_list)
Starts processing the specified list box or popup list. Adds the specified string to the current list. Ends processing of the current list.

Opening and Closing DCL Files


(load_dialog filename)
Loads the specified DCL file. Unloads the specified DCL file.

Creating Images
(dimx_tile key) (dimy_tile key) (start_image key)
Retrieves dimensions of the specified tile. Starts creating the specified image. Draws a vector in the currently active image. Draws a filled rectangle in the currently active image. Draws an AutoCAD slide in the currently active image. Ends creation of the currently active image.

(unload_dialog dcl_id)

Opening and Closing Dialogue Boxes


(new_dialog dlgname dcl_Id [[action-expression] screen-pt]) (start_dialog)

(vector_1mage x1 y1 x2 y2 colour) (fill_image x1 y1 x2 y2 colour)

Initialises a dialogue box and displays it. Begins accepting user input from the dialogue box initialised by the new_dialog call. Terminates the current dialogue box and stops displaying it. Must be called from within an action expression or call-back function. This function also returns the current (X,Y) position of the dialogue box.

(slide_image x1 y1 x2 y2 slidename) (end_image)

(done_dialog [status])

Application-specific Data
(client_data_tile key clientdata)
Associates application managed data with the specified tile.

(term_dialog)

Terminates all current dialogue boxes as if the user had cancelled them.

Initialising Action Expressions or Callback Functions


(action_tile key action-expression)
Associates the specified tile with the action expression or call-back function.

Handling Tiles and Attributes


(mode_tile key mode) (get_attr key attribute) (get_tile key) (set_tile key value)
Sets the mode of the specified tile. Gets the DCL value of the specified attribute. Gets the run-time value of the specified tile. Sets the run-time value of the specified tile.

Page 6

Potrebbero piacerti anche