AutoLisp - Liste des fonctions

Publié le par tea che

AUTOLISP FUNCTION LIST (R12)


Page récupérée à l'adresse : http://personales.unican.es/togoresr/Lspfun-e.html




Arithmetic Functions

+ (+ number number .....) Returns the sum of numbers within parenthesis. Addition.
- (- number [number .....]) Subtracts second number from first number and returns difference. Subtraction.
* (* number [number .....]) Returns product, left to right, of all numbers. Multiplication.
/ (/ number [number .....]) Divides first number by second and returns difference. Division.
~ (~ number) Returns bitwise NOT (complement) of a number.
1+ (1+ number) Returns number increased by 1.
1- (1- number) Returns number decreased by 1.
abs (abs number) Returns the absolute value of number.
atan (atan num1 [num2]) Returns the arctangent of a number in radians. If num1 & num2, returns arctangent of num1/num2 in radians. If num2 is zero then atan returns an angle plus or minus 1.570796 radians (+90 or -90 degrees) per sign of num1.
cos (cos angle) Returns the cosign of an angle, where angle is radians.
exp (exp number) Returns the constant e raised to the number power as a real number.
expt (expt base power) Returns base raised to power. Unless both are integers a real is returned.
fix (fix number) Converts number to an integer number. number can be either real or integer. Real number is converted to integer by truncation, 5.8 returns 5, no rounding.
float (float number) Converts number to a real number. number can be either real or integer.
gcd (gcd num1 num2) Returns the greatest common denominator of two numbers which must be integers.
log (log number) Returns the natural log of number as a real number.
logand (logand integer integer .....) Returns integer as result of logical bitwise AND of a list of numbers which must be integers.
logior (logior integer .....) Returns integer as result of logical bitwise inclusive OR of a list of numbers which must be integers.
lsh (lsh number numbits) Returns the logical bitwise shift of a number by a given number of bits. Arguments must be integers, returns integer.
max (max number number .....) Returns the largest number of numbers given.
min (min number number .....) Returns the smallest number of numbers given.
minusp (minusp item) Returns T if item is a real or integer and evaluates to a negative value. Returns nil otherwise.
pi (pi) Not a function, evaluates to constant pi, approximately 3.1415926.
rem (rem num1 num2 .....) Returns remainder of division of num1 by num2.
sin (sin angle) Returns sin of angle as a real number expressing radians.
sqrt (sqrt number) Returns square root of number as a real number.
zerop (zerop item) Verifies item is a real or integer that evaluates to zero.

AutoCAD Queries & Commands

command (command ["arguments"] .....) Executes one or more AutoCAD commands from within AutoLISP. Always returns nil. Arguments can be reals, integers, strings or points corresponding to successive prompts of given command which is always the first argument. Null string, "", is equal to on the keyboard. Command without arguments is equal to Ctrl+C, or cancel. When AutoLISP encounters PAUSE as an argument it will wait for user input. The getXXX functions cannot be used inside of the command function. Dtext & Sketch cannot be used with the command function.
getvar (getvar "variable_name") Gets the current value of an AutoCAD system variable which must be enclosed within double quotes. Returns nil if variable is unknown.
findfile (findfile "filename.ext" ) Searches for filename. Search path is (in order of search) Current Directory, Directory containing Current Drawing File, Directories specified with the SET ACAD=statement (if this is set), the Directory containing the AutoCAD Program files. You must supply the extention if it matters. Returns Path/Filename.Ext if found, nil if not.
getfiled (getfiled "title" "filename" "ext" flags) Prompts the user for a filename with AutoCAD file dialog box. Title is lable for the dialog box. Filename is default filename. Ext is default filename extension. In both cases wildcards may be used for all or part of default definitions. Flags 1 - Request for creation of new file. 2 - Disables Type It function of dialog box. 4 - Allows arbitrary extension. 8 - Does library search (see above) for filename entered
osnap (osnap pt "mode_string") Finds a 3D-point using a standard object snap entered as a string. Several osnaps may be used but they must be separated by commas.
setvar (setvar "variable_name" value) Sets the value of AutoCAD system variable, variable_name to given value. Variable name must be enclosed in double quotes. The variable ANGBASE interprets the given value as radians. The variable SNAPANG interprets the given value as radians relative to the default direction for 0 degrees. Both of these are different from using setvar at the command line. Be aware when you use these in AutoLISP.


Conversion

ascii (ascii "string") Returns first character of string as ASCII code equivalent.
angtof (angtof "string" [mode]) Converts string representing an angle to a real number, returns result as radians. Mode specifies units in which string is formatted. Values are as allowed for system variable AUNITS.
angtos (angtos angle [mode [precision]]) Converts angle (a real, in radians) to a string according to mode (values allowed by AUNITS ) and precision (number of decimal places.) The variable UNITMODE affects spaces if surveyor's units are specified by mode.
atof (atof "string") Converts string to a real number.
atoi (atoi "string") Converts string to an integer number.
chr (chr integer) Converts integer representing ASCII code to single-character string, that is to say it does the opposite of the ascii function.
cvunit (cvunit value from to) Converts between various real-world units, as listed in acad.unt.
distof (distof "string" [mode]) Converts string real to real value number according to mode (values as allowed by LUNITS system variable.)
itoa (itoa integer) Converts integer numbers to strings.
rtos (rtos number [mode [precision]]) Converts real numbers to strings according to mode (values allowed by AUNITS ) and precision (number of decimal places.) The variable UNITMODE affects spaces if surveyor's units are used by mode


Display Control

graphscr (graphscr) Display the current graphics screen, switch from the text screen to the graphics screen.
menucmd (menucmd "string") Display and activate menus. String argument takes the form of "section=submenu" according to the following section options: $ - Screen Menu, B1-B4 - Button Menus 1 thru 4, I - Icon Menu, P0-P16 - Pop Menus 1 thru 16, T1-T4 - Tablet Menus 1 thru 4, A1-A4 - AUX Menus 1 thru 4, M - for DIESEL string expressions.
princ (princ [expression [file-description]]) Prints message on text screen or to open file.
print (print [expression [file-description]]) Prints message on text screen or to open file.
print1 (print1 [expression [file-description]]) Prints message on text screen or to open file.
prompt (prompt message) Displays message on the prompt (command) line.
redraw (redraw [entity_name[mode]]) Redraws current graphics screen or individual entity.
terpri (terpri) Prints a new line to the screen, see \n in Control Characters.
textscr (textscr) Displays current text screen.
textpage (textpage) Displays cleared text screen.
vports (vports) Returns current viewport configuration descriptors.


Entity Handling

entdel (entdel entity_name) Deletes (or Undeletes) entities.
entget (entget entity_name [applist]) Gets definition data of entity, applist is for extended data.
entlast (entlast) Returns last undeleted entity name in drawing.
entmake (entmake [entity_list]) Creates new entity in drawing, returns definition data if successful.
entmod (entmod entity_list) Modifies existing definition data of an entity.
entnext (entnext [entity_name]) Returns entity name of next entity in drawing.
entsel (entsel [prompt]) Returns entity name & point used to select entity.
entupd (entupd entity_name) Updates graphic image of an entity on screen.
handent (handent handle) Returns entity name associated with handle.
nentsel (nentsel [prompt]) Returns as entsel but provides access to insert entities.
nentselp (nentselp [prompt] [pt]) Like nentsel, but returns 3D 4x4 matrix.


Equality and Conditional Functions

= (=atom atom .....) Tests equality in numbers & strings, returns t if true, nil if not.
/=(/=atom atom .....) Tests not equal in numbers & strings, returns t if true, nil if not.
< (< atom atom .....) Tests if 1st atom is less than 2nd atom, returns t if true, nil if not.
<= (<=atom atom .....) Tests if less than or equal to as above.
> (> atom atom .....) Tests if 1st atom is greater than 2nd atom, returns t if true & nil if not.
>= (>=atom atom .....) Tests if greater than or equal to as above.
and (and expression .....) Returns t if all expressions true, nil if any evaluates to nil.
boole (boole func int1 int2 ....) General bitwise Boolean function.
cond (cond ((test1)(result1 .....))((test2)(result2.....)) .....) Evaluates first item in each list (test) until one returns a value other than nil, then evaluates the expressions (results) and returns value of final expression. Primary conditional function in AutoLISP.
eq (eq expression_1 expression_2) Determines if two expressions are identical.
equal (equal expression_1 expression_2 [fuzz]) Determines if two expressions are equal within a certain tolerance.
if (if test_expression then_expression [else_expression]) Conditional evaluation of expressions (if then else).
or (or expression .....) Returns t if any expression true, nil if none are.
repeat (repeat number expression .....) Evaluates expression(s) a given number of times.
while (while test_expression expression .....) While test is true evaluates enclosed expressions.


File Handling

close (close file_description) Closes a file.
load (load file_name [on_failure]) Loads an AutoLISP file for use in a drawing.
open (open file_name mode) Opens a file for AutoLISP I/O functions.


Function Handling

apply (apply function list) Executes a function with the arguments given.
defun (defun sym argument-list expression .....) Defines an external function, a user created subroutine.
eval (eval expression) Returns the result of evaluation of any AutoLISP expression.
exit (exit) Stops current function & returns to command prompt.
lambda (lambda arguments expression .....) Defines an anonymous function.
progn (progn expression .....) Evaluates expressions individually, seen by program as one expression.
quit (quit) Stops current function & returns to command prompt.
trace (trace function .....) Debugging aid, Sets trace flag for specified functions.
untrace (untrace function .....) Debugging aid, clears trace flag.


Geometric Utilities

angle (angle pt1 pt2) Returns angle between two points in radians.
distance (distance pt1 pt2 Returns distance between two points.
inters (inters pt1 pt2 pt3 pt4 [onseg]) Returns intersection of two lines.
polar (polar point angle distance) Returns a point via polar coordinates.
textbox (textbox entity_list) Returns lower left & upper right coordinates of a box enclosing text entity.


List Manipulation

append (append expression .....) Returns one list from any number of lists.
assoc (assoc item association_list) Returns association_list entry for item.
car (car list) Returns the first element of a list.
cdr (cdr list) Returns list excepting first element.
cons (cons new_1st_element list) Returns list with new 1st element.
foreach (foreach name list expression .....) Steps through list assigning each element to name & evaluating each expression for every item in the list.
list (list expression .....) Creates list from any number of expressions.
listp (listp item) Verifies that item is list.
mapcar (mapcar function list1 .....list#) Returns list resulting from executing a function with the elements of list(s) supplied.
member (member expression list) Returns remainder of list starting with first occurrence of test expression.
nth (nth n list) Returns the n element of list (1st element in every list is numbered zero).
reverse (reverse list) Returns list with elements reversed.
subst (subst new_item old_item list) Returns list with new_item in place of every old_item.

Low Level Graphics

grclear (grclear) Clears the current viewport/graphics screen.
grdraw (grdraw from to color [highlight]) Draws vector in current viewport.
grread (grread [track][allkeys [curtype]]) Reads user input from any input device.
grtext (grtext [box text [highlight]]) Displays text in the text portions of the graphics screen.
grvecs (grvecs vlist [trans]) Draws multiple vectors in current viewport.


Symbol Handling

atom (atom item) Verifies item is an atom, that is, not a list. T if true, nil if not.
atoms-family (atoms-family format [symlist]) Returns a list of functions previously defined.
boundp (boundp atom) Verifies that atom has value bound to it.
not (not item) Verifies that item is nil.
null (null item) Verifies that item is bound to nil.
numberp (numberp item) Verifies that item is real or integer number.
quote (quote expression .....) Returns an expression unevaluated.
set (set quoted_symbol_name expression) Sets the value of a quoted symbol name to that of expression.
setq (setq symbol1 expression1 [symbol2 expression2 .....]) Sets the value of one or more symbols to that of one or more expressions.
type (type item) Returns the type of item.


Text String Functions

read (read string) Returns the first list or atom in a string.
read-char (read-char [file-description]) Reads a single character from the keyboard or an open file.
read-line (read-line [file-description]) Reads a string from the keyboard or an open file.
strcase (strcase string [which_case]) Returns string of all upper or lower case letters
strcat (strcat string1 [string2 .....]) Concatenate strings (create one string from two or more).
strlen (strlen [string] .....) Returns the number of characters in a string.
substr (substr string start [length]) Returns a substring of string from start (number) & continuing for length (number).
write-char (write-char number [file-description]) Writes one character, using ASCII code designation for character, to screen or file.
write-line (write-line string [file-description]) Writes string to screen or file.


User Input

getangle (getangle [point][prompt]) User input of angle, with prompt. Point allows rubberbanding line back to previously defined point, typical to get functions.
getcorner (getcorner point [prompt]) User input for 2nd corner of rectangle, with p
getdist (getdist [point][prompt]) User input of a distance, with prompt.
getint (getint [prompt]) User input of an integer number, with prompt.
getkword (getkword [prompt]) User input of keyword, with prompt. Used with initget below.
getorient (getorient [point][prompt]) Like getangle, but unaffected by ANGBASE & ANGDIR variables.
getpoint (getpoint [point][prompt]) User input of a point, with prompt.
getreal (getreal [prompt]) User input of a real number, with prompt.
getstring (getstring [carriage_return][prompt]) User input of string, with prompt. Non-nil carriage_return allows spaces in input-string.
initget (initget [bits][string]) Delineates valid input for next call to several functions.


Extended Entity Data

regapp (regapp application) Registers application's extended entity data.
xdroom (xdroom entity_name) Returns the space (in bytes) an entity has available for extended data.
xdsize (xdsize list) Returns the space (in bytes) a list of extended data will occupy.

Memory Management

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

Publié dans AutoLisp

Pour être informé des derniers articles, inscrivez vous :
Commenter cet article