Auto LISP
Auto LISP
Auto LISP
AutoLISP®
Reference
March 1, 1999
Copyright © 1999 Autodesk, Inc.
All Rights Reserved
AUTODESK, INC. MAKES NO WARRANTY, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, REGARDING THESE MATERIALS AND MAKES
SUCH MATERIALS AVAILABLE SOLELY ON AN “AS-IS” BASIS.
IN NO EVENT SHALL AUTODESK, INC. BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE OR USE OF THESE MATERIALS. THE SOLE AND EXCLUSIVE
LIABILITY TO AUTODESK, INC., REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED THE PURCHASE PRICE OF THE
MATERIALS DESCRIBED HEREIN.
Autodesk, Inc. reserves the right to revise and improve its products as it sees fit. This publication describes the state of this product at
the time of its publication, and may not reflect the product at all times in the future.
Autodesk Trademarks
The following are registered trademarks of Autodesk, Inc., in the USA and/or other countries: 3D Plan, 3D Props, 3D Studio, 3D Studio
MAX, 3D Studio VIZ, 3DSurfer, ADE, ADI, Advanced Modeling Extension, AEC Authority (logo), AEC-X, AME, Animator Pro, Animator
Studio, ATC, AUGI, AutoCAD, AutoCAD Data Extension, AutoCAD Development System, AutoCAD LT, AutoCAD Map, Autodesk,
Autodesk (logo), Autodesk Animator, Autodesk MapGuide, Autodesk University, Autodesk View, Autodesk WalkThrough, Autodesk
World, AutoLISP, AutoShade, AutoSketch, AutoSolid, AutoSurf, AutoVision, Biped, bringing information down to earth, CAD Overlay,
Character Studio, Design Companion, Drafix, Education by Design, Generic, Generic 3D Drafting, Generic CADD, Generic Software,
Geodyssey, Heidi, HOOPS, Hyperwire, Inside Track, Kinetix, MaterialSpec, Mechanical Desktop, Multimedia Explorer, NAAUG, Office
Series, Opus, PeopleTracker, Physique, Planix, Rastation, Softdesk, Softdesk (logo), Solution 3000, Tech Talk, Texture Universe, The AEC
Authority, The Auto Architect, TinkerTech, WHIP!, WHIP! (logo), Woodbourne, WorkCenter, and World-Creating Toolkit.
The following are trademarks of Autodesk, Inc., in the USA and/or other countries: 3D on the PC, ACAD, ActiveShapes, Actrix, Advanced
User Interface, AEC Office, AME Link, Animation Partner, Animation Player, Animation Pro Player, A Studio in Every Computer, ATLAST,
Auto-Architect, AutoCAD Architectural Desktop, AutoCAD Architectural Desktop Learning Assistance, AutoCAD Learning Assistance,
AutoCAD LT Learning Assistance, AutoCAD Simulator, AutoCAD SQL Extension, AutoCAD SQL Interface, AutoCDM, Autodesk Animator
Clips, Autodesk Animator Theatre, Autodesk Device Interface, Autodesk PhotoEDIT, Autodesk Software Developer's Kit, Autodesk View
DwgX, AutoEDM, AutoFlix, AutoLathe, AutoSnap, Built with ObjectARX (logo), ClearScale, Concept Studio, Content Explorer,
cornerStone Toolkit, Dancing Baby (image), Design Your World, Design Your World (logo) DXF, DWG Linking, DWG Unplugged, DXF,
Exegis, FLI, FLIC, GDX Driver, Generic 3D, Home Series, Kinetix (logo), MAX DWG, ObjectARX, ObjectDBX, Ooga-Chaka, Photo
Landscape, Photoscape, Plugs and Sockets, PolarSnap, Powered with Autodesk Technology, Powered with Autodesk Technology (logo),
ProConnect, Pro Landscape, QuickCAD, RadioRay, SchoolBox, SketchTools, Suddenly Everything Clicks, Supportdesk, The Dancing
Baby, Transforms Ideas Into Reality, Visual LISP, and VOLO!.
G OVERNMENT USE
Use, duplication, or disclosure by the U. S. Government is subject to restrictions as set forth in FAR 12.212 (Commercial Computer
Software-Restricted Rights) and DFAR 267.7202 (Rights in Technical Data and Computer Software), as applicable.
Contents - AutoLISP Reference
AutoLISP Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
+ .................................................................................. 19
– .................................................................................. 19
* .................................................................................. 20
/ ................................................................................... 20
= .................................................................................. 21
/= ................................................................................. 21
< .................................................................................. 22
<= ................................................................................ 23
> .................................................................................. 23
>= ................................................................................ 24
~ .................................................................................. 24
1+ ................................................................................ 25
1–................................................................................. 25
abs ............................................................................... 25
acad_colordlg.............................................................. 26
acad_helpdlg ............................................................... 26
acad_strlsort................................................................ 27
action_tile.................................................................... 27
add_list........................................................................ 28
alert ............................................................................. 29
alloc............................................................................. 30
and............................................................................... 30
angle............................................................................ 31
angtof .......................................................................... 31
angtos .......................................................................... 32
Contents | iii
append ......................................................................... 34
apply............................................................................ 34
arx ............................................................................... 35
arxload ........................................................................ 35
arxunload .................................................................... 36
ascii ............................................................................. 36
assoc............................................................................ 37
atan.............................................................................. 37
atof .............................................................................. 38
atoi .............................................................................. 39
atom ............................................................................ 39
atoms-family ............................................................... 40
autoarxload.................................................................. 41
autoload....................................................................... 42
Boole ........................................................................... 42
boundp ........................................................................ 44
caddr............................................................................ 45
cadr.............................................................................. 45
car................................................................................ 46
cdr ............................................................................... 46
chr ............................................................................... 47
client_data_tile............................................................ 48
close ............................................................................ 48
command..................................................................... 49
cond............................................................................. 50
cons ............................................................................. 51
cos ............................................................................... 52
cvunit .......................................................................... 52
defun ........................................................................... 53
defun-q ........................................................................ 54
defun-q-list-ref ............................................................ 55
defun-q-list-set............................................................ 56
dictadd......................................................................... 57
dictnext........................................................................ 58
dictremove .................................................................. 60
dictrename................................................................... 61
dictsearch .................................................................... 61
iv | Contents
dimx_tile ..................................................................... 62
dimy_tile ..................................................................... 63
distance ....................................................................... 63
distof ........................................................................... 64
done_dialog................................................................. 65
end_image................................................................... 65
end_list........................................................................ 66
entdel........................................................................... 66
entget........................................................................... 67
entlast .......................................................................... 68
entmake....................................................................... 69
entmakex..................................................................... 70
entmod ........................................................................ 71
entnext......................................................................... 73
entsel ........................................................................... 73
entupd.......................................................................... 74
eq................................................................................. 75
equal............................................................................ 76
*error*......................................................................... 78
eval.............................................................................. 78
exit .............................................................................. 79
exp............................................................................... 79
expand ......................................................................... 80
expt.............................................................................. 81
fill_image.................................................................... 81
findfile......................................................................... 82
fix ................................................................................ 83
float ............................................................................. 84
foreach ........................................................................ 84
function ....................................................................... 85
gc................................................................................. 86
gcd............................................................................... 86
get_attr ........................................................................ 87
get_tile ........................................................................ 87
getangle....................................................................... 88
getcfg .......................................................................... 89
getcname ..................................................................... 89
Contents | v
getcorner ..................................................................... 90
getdist.......................................................................... 91
getenv.......................................................................... 92
getfiled ........................................................................ 92
getint ........................................................................... 95
getkword ..................................................................... 96
getorient ...................................................................... 97
getpoint ....................................................................... 98
getreal.......................................................................... 99
getstring ...................................................................... 99
getvar ........................................................................ 100
graphscr..................................................................... 101
grclear ....................................................................... 101
grdraw ....................................................................... 101
grread ........................................................................ 102
grtext ......................................................................... 105
grvecs ........................................................................ 106
handent...................................................................... 107
help............................................................................ 108
if ................................................................................ 109
initdia ........................................................................ 110
initget ........................................................................ 111
inters.......................................................................... 114
itoa ............................................................................ 115
lambda....................................................................... 116
last ............................................................................. 117
layoutlist.................................................................... 117
length ........................................................................ 118
list.............................................................................. 118
listp............................................................................ 119
load............................................................................ 120
load_dialog................................................................ 121
log ............................................................................. 122
logand........................................................................ 122
logior ......................................................................... 123
lsh.............................................................................. 123
mapcar....................................................................... 124
vi | Contents
max............................................................................ 125
mem .......................................................................... 125
member ..................................................................... 127
menucmd................................................................... 127
menugroup ................................................................ 129
min ............................................................................ 129
minusp....................................................................... 130
mode_tile .................................................................. 130
namedobjdict............................................................. 131
nentsel ....................................................................... 131
nentselp ..................................................................... 133
new_dialog................................................................ 135
not ............................................................................. 135
nth ............................................................................. 136
null ............................................................................ 137
numberp .................................................................... 137
open........................................................................... 138
or ............................................................................... 139
osnap ......................................................................... 140
polar .......................................................................... 141
prin1 .......................................................................... 141
princ .......................................................................... 143
print ........................................................................... 143
progn ......................................................................... 144
prompt ....................................................................... 144
quit ............................................................................ 145
quote.......................................................................... 145
read............................................................................ 146
read-char ................................................................... 147
read-line .................................................................... 148
redraw ....................................................................... 148
regapp........................................................................ 149
rem ............................................................................ 150
repeat......................................................................... 151
reverse ....................................................................... 152
rtos ............................................................................ 152
set .............................................................................. 154
Contents | vii
set_tile ....................................................................... 155
setcfg ......................................................................... 155
setenv ........................................................................ 156
setfunhelp.................................................................. 156
setq ............................................................................ 158
setvar ......................................................................... 159
setview ...................................................................... 160
sin.............................................................................. 160
slide_image ............................................................... 161
snvalid ....................................................................... 162
sqrt ............................................................................ 164
ssadd.......................................................................... 164
ssdel .......................................................................... 166
ssget .......................................................................... 166
ssgetfirst .................................................................... 170
sslength ..................................................................... 170
ssmemb ..................................................................... 171
ssname....................................................................... 171
ssnamex..................................................................... 172
sssetfirst .................................................................... 175
startapp...................................................................... 177
start_dialog................................................................ 178
start_image................................................................ 178
start_list..................................................................... 179
strcase........................................................................ 179
strcat.......................................................................... 180
strlen.......................................................................... 181
subst .......................................................................... 181
substr ......................................................................... 182
tablet.......................................................................... 183
tblnext ....................................................................... 184
tblobjname ................................................................ 186
tblsearch .................................................................... 187
term_dialog ............................................................... 187
terpri.......................................................................... 188
textbox ...................................................................... 188
textpage ..................................................................... 189
viii | Contents
textscr........................................................................ 189
trace........................................................................... 189
trans........................................................................... 191
type............................................................................ 193
unload_dialog............................................................ 195
untrace....................................................................... 195
vector_image............................................................. 196
ver ............................................................................. 197
vl-acad-defun ............................................................ 198
vl-acad-undefun ........................................................ 198
vl-arx-import............................................................. 198
vl-bb-ref .................................................................... 200
vl-bb-set .................................................................... 200
vl-catch-all-apply ...................................................... 201
vl-catch-all-error-message ........................................ 202
vl-catch-all-error-p.................................................... 203
vl-cmdf...................................................................... 203
vl-consp..................................................................... 205
vl-directory-files ....................................................... 206
vl-doc-export............................................................. 206
vl-doc-import ............................................................ 207
vl-doc-ref .................................................................. 208
vl-doc-set .................................................................. 208
vl-every ..................................................................... 209
vl-exit-with-error ...................................................... 210
vl-exit-with-value...................................................... 211
vl-file-copy................................................................ 212
vl-file-delete.............................................................. 213
vl-file-directory-p...................................................... 213
vl-file-rename............................................................ 214
vl-file-size ................................................................. 215
vl-file-systime ........................................................... 215
vl-filename-base........................................................ 216
vl-filename-directory ................................................ 217
vl-filename-extension ............................................... 217
vl-filename-mktemp.................................................. 218
vl-get-resource .......................................................... 219
Contents | ix
vl-list* ....................................................................... 220
vl-list->string ............................................................ 220
vl-list-exported-functions.......................................... 221
vl-list-length.............................................................. 222
vl-list-loaded-vlx....................................................... 222
vl-load-all.................................................................. 223
vl-load-com ............................................................... 224
vl-load-reactors ......................................................... 224
vl-member-if ............................................................. 225
vl-member-if-not....................................................... 226
vl-position ................................................................. 226
vl-prin1-to-string....................................................... 227
vl-princ-to-string....................................................... 228
vl-propagate .............................................................. 228
vl-registry-delete....................................................... 229
vl-registry-descendents ............................................. 229
vl-registry-read.......................................................... 230
vl-registry-write ........................................................ 231
vl-remove .................................................................. 231
vl-remove-if .............................................................. 232
vl-remove-if-not........................................................ 233
vl-some...................................................................... 233
vl-sort ........................................................................ 234
vl-sort-i...................................................................... 235
vl-string->list ............................................................ 236
vl-string-elt................................................................ 237
vl-string-left-trim ...................................................... 237
vl-string-mismatch .................................................... 238
vl-string-position....................................................... 239
vl-string-right-trim.................................................... 240
vl-string-search ......................................................... 240
vl-string-subst ........................................................... 241
vl-string-translate...................................................... 242
vl-string-trim............................................................. 242
vl-symbol-name ........................................................ 243
vl-symbol-value ........................................................ 244
vl-symbolp ................................................................ 244
x | Contents
vl-unload-vlx............................................................. 245
vl-vbaload ................................................................. 246
vl-vbarun................................................................... 246
vl-vlx-loaded-p.......................................................... 247
vlax-3D-point............................................................ 247
vlax-add-cmd ............................................................ 248
vlax-create-object...................................................... 250
vlax-curve-getArea ................................................... 250
vlax-curve-getDistAtParam ...................................... 251
vlax-curve-getDistAtPoint........................................ 252
vlax-curve-getEndParam .......................................... 253
vlax-curve-getEndPoint ............................................ 254
vlax-curve-getParamAtDist ...................................... 254
vlax-curve-getParamAtPoint .................................... 255
vlax-curve-getPointAtDist........................................ 255
vlax-curve-getPointAtParam .................................... 256
vlax-curve-getStartParam ......................................... 257
vlax-curve-getStartPoint ........................................... 257
vlax-curve-isClosed .................................................. 258
vlax-curve-isPeriodic................................................ 258
vlax-curve-isPlanar ................................................... 259
vlax-curve-getClosestPointTo .................................. 260
vlax-curve-getClosestPointToProjection .................. 261
vlax-curve-getFirstDeriv........................................... 261
vlax-curve-getSecondDeriv ...................................... 262
vlax-dump-object...................................................... 263
vlax-ename->vla-object ............................................ 264
vlax-erased-p............................................................. 264
vlax-for...................................................................... 265
vlax-get-acad-object.................................................. 265
vlax-get-object .......................................................... 266
vlax-get-or-create-object........................................... 266
vlax-get-property ...................................................... 267
vlax-import-type-library ........................................... 268
vlax-invoke-method .................................................. 270
vlax-ldata-delete........................................................ 271
vlax-ldata-get ............................................................ 271
Contents | xi
vlax-ldata-list ............................................................ 274
vlax-ldata-put............................................................ 274
vlax-ldata-test............................................................ 275
vlax-make-safearray.................................................. 276
vlax-make-variant ..................................................... 278
vlax-map-collection .................................................. 280
vlax-method-applicable-p ......................................... 281
vlax-object-released-p............................................... 282
vlax-product-key....................................................... 283
vlax-property-available-p.......................................... 283
vlax-put-property ...................................................... 284
vlax-read-enabled-p .................................................. 285
vlax-release-object.................................................... 285
vlax-remove-cmd ...................................................... 285
vlax-safearray-fill...................................................... 286
vlax-safearray-get-dim.............................................. 288
vlax-safearray-get-element ....................................... 288
vlax-safearray-get-l-bound........................................ 289
vlax-safearray-get-u-bound....................................... 290
vlax-safearray-put-element ....................................... 291
vlax-safearray-type ................................................... 292
vlax-safearray->list ................................................... 293
vlax-tmatrix............................................................... 294
vlax-typeinfo-available-p.......................................... 295
vlax-variant-change-type .......................................... 296
vlax-variant-type....................................................... 297
vlax-variant-value ..................................................... 299
vlax-vla-object->ename ............................................ 300
vlax-write-enabled-p................................................. 300
vlisp-compile ............................................................ 300
vlr-acdb-reactor......................................................... 302
vlr-add ....................................................................... 303
vlr-added-p................................................................ 303
vlr-beep-reaction....................................................... 304
vlr-command-reactor ................................................ 304
vlr-current-reaction-name ......................................... 305
vlr-data ...................................................................... 305
xii | Contents
vlr-data-set ................................................................ 306
vlr-deepclone-reactor ................................................ 307
vlr-docmanager-reactor............................................. 308
vlr-dwg-reactor ......................................................... 310
vlr-dxf-reactor........................................................... 312
vlr-editor-reactor....................................................... 313
vlr-insert-reactor ....................................................... 316
vlr-linker-reactor....................................................... 318
vlr-lisp-reactor .......................................................... 319
vlr-miscellaneous-reactor.......................................... 320
vlr-mouse-reactor...................................................... 322
vlr-notification .......................................................... 323
vlr-object-reactor ...................................................... 323
vlr-owner-add............................................................ 326
vlr-owner-remove ..................................................... 326
vlr-owners ................................................................. 327
vlr-pers ...................................................................... 327
vlr-pers-list................................................................ 328
vlr-pers-p................................................................... 328
vlr-pers-release.......................................................... 329
vlr-reaction-names .................................................... 329
vlr-reaction-set.......................................................... 330
vlr-reactions .............................................................. 331
vlr-reactors ................................................................ 331
vlr-remove................................................................. 332
vlr-remove-all ........................................................... 333
vlr-set-notification .................................................... 334
vlr-sysvar-reactor ...................................................... 335
vlr-toolbar-reactor..................................................... 336
vlr-trace-reaction....................................................... 337
vlr-type...................................................................... 338
vlr-types .................................................................... 339
vlr-undo-reactor ........................................................ 340
vlr-wblock-reactor .................................................... 342
vlr-window-reactor ................................................... 344
vlr-xref-reactor.......................................................... 346
vports ........................................................................ 352
Contents | xiii
wcmatch .................................................................... 353
while.......................................................................... 356
write-char .................................................................. 356
write-line ................................................................... 357
xdroom ...................................................................... 358
xdsize ........................................................................ 358
zerop.......................................................................... 359
xiv | Contents
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Contents | xv
xvi | Contents
AutoLISP Reference
In This Chapter
The following is a catalog of the AutoLISP functions ■ Brief description of each function’s
use
available in AutoCAD. The functions are listed alphabet-
■ Function syntax showing the
order and type of arguments
ically.
by the function.
future releases.
17
function name
required argument(s)
optional argument(s) in brackets
18 | AutoLISP Reference
+
(add) Returns the sum of all numbers
Arguments
number A number.
Return Values
The result of the addition. If you supply only one number argument, this
function returns the result of adding it to zero. If you supply no arguments,
the function returns 0.
Examples
(+ 1 2) returns 3
(+ 1 2 3 4.5) returns 10.5
(+ 1 2 3 4.0) returns 10.0
–
(subtract) Subtracts the second and following numbers from the first and returns the
difference
Arguments
number A number.
Return Values
The result of the subtraction. If you supply more than two number argu-
ments, this function returns the result of subtracting the sum of the second
through the last numbers from the first number. If you supply only one num-
ber argument, this function subtracts the number from zero, and returns a
negative number. Supplying no arguments returns 0.
+ | 19
Examples
(- 50 40) returns 10
(- 50 40.0) returns 10.0
(- 50 40.0 2.5) returns 7.5
(- 8) returns -8
*
(multiply) Returns the product of all numbers
Arguments
number A number.
Return Values
The result of the multiplication. If you supply only one number argument,
this function returns the result of multiplying it by one; it returns the num-
ber. Supplying no arguments returns 0.
Examples
(* 2 3) returns 6
(* 2 3.0) returns 6.0
(* 2 3 4.0) returns 24.0
(* 3 -4.5) returns -13.5
(* 3) returns 3
/
(divide) Divides the first number by the product of the remaining numbers and returns
the quotient
Arguments
number A number.
Return Values
The result of the division. If you supply more than two number arguments,
this function divides the first number by the product of the second through
the last numbers, and returns the final quotient. If you supply one number
20 | AutoLISP Reference
argument, this function returns the result of dividing it by one; it returns the
number. Supplying no arguments returns 0.
Examples
(/ 100 2) returns 50
(/ 100 2.0) returns 50.0
(/ 100 20.0 2) returns 2.5
(/ 100 20 2) returns 2
(/ 4) returns 4
=
(equal to) Compares arguments for numerical equality
Arguments
numstr A number or a string.
Return Values
T, if all arguments are numerically equal, nil otherwise. If only one argument
is supplied, = returns T.
Examples
(= 4 4.0) returns T
(= 20 388) returns nil
(= 2.4 2.4 2.4) returns T
(= 499 499 500) returns nil
(= "me" "me") returns T
(= "me" "you") returns nil
/=
(not equal to) Compares arguments for numerical inequality
Arguments
numstr A number or a string.
= | 21
Return Values
T, if no two successive arguments are the same in value, nil otherwise. If only
one argument is supplied, /= returns T.
Note that the behavior of /= does not quite conform to other LISP dialects.
The standard behavior is to return T if no two arguments in the list have the
same value. In AutoLISP, /= returns T if no successive arguments have the
same value; see the examples that follow.
Examples
(/= 10 20) returns T
(/= "you" "you") returns nil
(/= 5.43 5.44) returns T
(/= 10 20 10 20 20) returns nil
(/= 10 20 10 20) returns T
Note in the last example that although there are two arguments in the list
with the same value, they do not follow one another, and thus /= evaluates
to T.
<
(less than) Returns T if each argument is numerically less than the argument to its right,
and returns nil otherwise
Arguments
numstr A number or a string.
Return Values
T, if each argument is numerically less than the argument to its right, and
returns nil otherwise. If only one argument is supplied, < returns T.
Examples
(< 10 20) returns T
(< "b" "c") returns T
(< 357 33.2) returns nil
(< 2 3 88) returns T
(< 2 3 4 4) returns nil
22 | AutoLISP Reference
<=
(less than or equal to) Returns T if each argument is numerically less than or equal to the
argument to its right, and returns nil otherwise
Arguments
numstr A number or a string.
Return Values
T, if each argument is numerically less than or equal to the argument to its
right, and returns nil otherwise. If only one argument is supplied, <= returns
T.
Examples
(<= 10 20) returns T
(<= "b" "b") returns T
(<= 357 33.2) returns nil
(<= 2 9 9) returns T
(<= 2 9 4 5) returns nil
>
(greater than) Returns T if each argument is numerically greater than the argument to
its right, and returns nil otherwise
Arguments
numstr A number or a string.
Return Values
T, if each argument is numerically greater than the argument to its right, and
nil otherwise. If only one argument is supplied, > returns T.
Examples
(> 120 17) returns T
(> "c" "b") returns T
(> 3.5 1792) returns nil
(> 77 4 2) returns T
(> 77 4 4) returns nil
<= | 23
>=
(greater than or equal to) Returns T if each argument is numerically greater than or
equal to the argument to its right, and returns nil otherwise
Arguments
numstr A number or a string.
Return Values
T, if each argument is numerically greater than or equal to the argument to
its right, and nil otherwise. If only one argument is supplied, >= returns T.
Examples
(>= 120 17) returns T
(>= "c" "c") returns T
(>= 3.5 1792) returns nil
(>= 77 4 4) returns T
(>= 77 4 9) returns nil
~
(bitwise NOT) Returns the bitwise NOT (1’s complement) of the argument
(~ int)
Arguments
int An integer.
Return Values
The bitwise NOT (1’s complement) of the argument.
Examples
(~ 3) returns -4
(~ 100) returns -101
(~ -4) returns 3
24 | AutoLISP Reference
1+
(increment) Increments a number by 1
(1+ number)
Arguments
number Any number.
Return Values
The argument, increased by 1.
Examples
(1+ 5) returns 6
(1+ -17.5) returns -16.5
1–
(decrement) Decrements a number by 1
(1– number)
Arguments
number Any number.
Return Values
The argument, reduced by 1.
Examples
(1- 5) returns 4
(1- -17.5) returns -18.5
abs
Returns the absolute value of a number
(abs number)
1+ | 25
Arguments
number Any number.
Return Values
The absolute value of the argument.
Examples
(abs 100) returns 100
(abs -100) returns 100
(abs -99.25) returns 99.25
acad_colordlg
Displays the standard AutoCAD color selection dialog box
Arguments
colornum An integer in the range 0–256 (inclusive), specifying the
AutoCAD color number to display as the initial default.
flag If set to nil, disables the BYLAYER and BYBLOCK buttons.
Omitting the flag argument or setting it to a non-nil
value enables the BYLAYER and BYBLOCK buttons.
A colornum value of 0 defaults to BYBLOCK, and a value of 256 defaults to
BYLAYER.
Return Values
The user-selected color number, or nil, if the user cancels the dialog box.
Examples
Prompt the user to select a color, and default to green if none is selected:
(acad_colordlg 3)
acad_helpdlg
Invokes the help facility (obsolete)
26 | AutoLISP Reference
This externally defined function has been replaced by the built-in function
help. It is provided for compatibility with previous releases of AutoCAD.
SEE ALSO the help function for a complete description of this function.
acad_strlsort
Sorts a list of strings by alphabetical order
Arguments
list The list of strings to be sorted.
Return Values
The list in alphabetical order. If the list is invalid or if there is not enough
memory to do the sort, acad_strlsort returns nil.
Examples
Sort a list of abbreviated month names:
Command: (setq mos '("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug"
"Sep" "Oct" "Nov" "Dec"))
("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov"
"Dec")
Command: (acad_strlsort mos)
("Apr" "Aug" "Dec" "Feb" "Jan" "Jul" "Jun" "Mar" "May" "Nov" "Oct"
"Sep")
action_tile
Assigns an action to evaluate when the user selects the specified tile in a dialog box
acad_strlsort | 27
Arguments
key A string that names the tile that triggers the action
(specified as its key attribute). This argument is case-
sensitive.
action- A string naming the expression evaluated when the tile is
expression selected.
NOTE You cannot call the AutoLISP command function from the action_tile
function.
Return Values
T
Examples
If edit1 is a text box, the action expression in the following action_tile call
is evaluated when the user exits the text box:
(action_tile "edit1" "(setq ns $value)")
SEE ALSO “Default and DCL Actions” in the Visual LISP Developer’s Guide.
add_list
Adds or modifies a string in the currently active dialog box list
(add_list string)
Before using add_list, you must open the list and initialize it with a call to
start_list. Depending on the operation specified in start_list, the string
is either added to the current list or replaces the current list item.
Arguments
string A string.
Return Values
Returns the string added to the list, if successful, nil otherwise.
28 | AutoLISP Reference
Examples
Assuming the currently active DCL file has a popup_list or list_box with a key
of longlist, the following code fragment initializes the list and adds to it the
text strings in llist.
(setq llist '("first line" "second line" "third line"))
(start_list "longlist")
(mapcar 'add_list llist)
(end_list)
After the list has been defined, the following code fragment changes the text
in the second line to "2nd line".
(start_list "longlist" 1 0)
(add_list "2nd line")
(end_list)
alert
Displays a dialog box containing an error or warning message
(alert string)
Arguments
string The string to appear in the alert box.
Return Values
nil
Examples
Display a message in an alert box:
(alert "That function is not available.")
NOTE Line length and the number of lines in an alert box are platform, device,
and window dependent. AutoCAD truncates any string that is too long to fit
inside an alert box.
alert | 29
alloc
Sets the size of the segment to be used by the expand function
(alloc n-alloc)
Arguments
n-alloc An integer indicating the amount of memory to be
allocated. The integer represents the number of symbols,
strings, usubrs, reals, and cons cells.
Return Values
The previous setting of n-alloc.
Examples
_$ (alloc 100)
1000
and
Returns the logical AND of the supplied arguments
Arguments
expr Any expression.
Return Values
Nil, if any of the expressions evaluate to nil, otherwise T. If and is issued
without arguments, it returns T.
Examples
Command: (setq a 103 b nil c "string")
"string"
Command: (and 1.4 a c)
T
Command: (and 1.4 a b c)
nil
30 | AutoLISP Reference
angle
Returns an angle in radians of a line defined by two endpoints
Arguments
pt1 An endpoint.
pt2 An endpoint.
Return Values
An angle, in radians.
The angle is measured from the X axis of the current construction plane, in
radians, with angles increasing in the counterclockwise direction. If 3D
points are supplied, they are projected onto the current construction plane.
Examples
Command: (angle '(1.0 1.0) '(1.0 4.0))
1.5708
Command: (angle '(5.0 1.33) '(2.4 1.33))
3.14159
angtof
Converts a string representing an angle into a real (floating-point) value in radians
Arguments
string A string describing an angle based on the format specified
by the mode argument. The string must be a string that
angtof can parse correctly to the specified unit. It can be
in the same form that angtos returns, or in a form that
AutoCAD allows for keyboard entry.
units Specifies the units in which the string is formatted. The
value should correspond to values allowed for the
AutoCAD system variable AUNITS. If unit is omitted,
angle | 31
angtof uses the current value of AUNITS. The following
units may be specified:
0 Degrees
1 Degrees/minutes/seconds
2 Grads
3 Radians
4 Surveyor’s units
Return Values
A real value, if successful, otherwise nil.
The angtof and angtos functions are complementary: if you pass angtof a
string created by angtos, angtof is guaranteed to return a valid value, and
vice versa (assuming the unit values match).
Examples
Command: (angtof "45.0000")
0.785398
Command: (angtof "45.0000" 3)
1.0177
angtos
Converts an angular value in radians into a string
Arguments
angle A real number, in radians.
unit An integer that specifies the angular units. If unit is
omitted, angtof uses the current value of the AutoCAD
32 | AutoLISP Reference
system variable AUNITS. The following units may be
specified:
0 Degrees
1 Degrees/minutes/seconds
2 Grads
3 Radians
4 Surveyor’s units
precision An integer specifying the number of decimal places of
precision to be returned. If omitted, angtos uses the
current setting of the AutoCAD system variable AUPREC.
The angtos function takes angle and returns it edited into a string according
to the settings of unit, precision, the AutoCAD UNITMODE system variable, and
the DIMZIN dimensioning variable.
The angtos function accepts a negative angle argument, but always reduces
it to a positive value between zero and 2 pi radians before performing the
specified conversion.
The UNITMODE system variable affects the returned string when surveyor’s
units are selected (a unit value of 4). If UNITMODE = 0, spaces are included in
the string (for example, "N 45d E"); if UNITMODE = 1, no spaces are included
in the string (for example, "N45dE").
Return Values
A string, if successful, otherwise nil.
Examples
Command: (angtos 0.785398 0 4)
"45.0000"
Command: (angtos -0.785398 0 4)
"315.0000"
Command: (angtos -0.785398 4)
"S 45d E"
NOTE Routines that use the angtos function to display arbitrary angles (those
not relative to the value of ANGBASE) should check and consider the value of
ANGBASE.
SEE ALSO the angtof function, and “String Conversions” in the Visual
LISP Developer’s Guide.
angtos | 33
append
Takes any number of lists and appends them together as one list
Arguments
list A list.
Return Values
A list with all arguments appended to the original. If no arguments are sup-
plied, append returns nil.
Examples
Command: (append '(a b) '(c d))
(A B C D)
Command: (append '((a)(b)) '((c)(d)))
((A) (B) (C) (D))
apply
Passes a list of arguments to, and executes, a specified function
Arguments
’function A function. The function argument can be either a symbol
identifying a defun, or a lambda expression.
list A list. Can be nil, if the function accepts no arguments.
Return Values
The result of the function call.
Examples
Command: (apply '+ '(1 2 3))
6
Command: (apply 'strcat '("a" "b" "c"))
"abc"
34 | AutoLISP Reference
arx
Returns a list of the currently loaded ObjectARX applications
(arx)
Return Values
A list of ObjectARX application file names; the path is not included in the file
name.
Examples
Command: (arx)
("acadapp.arx" "acmted.arx" "oleaprot.arx")
arxload
Loads an ObjectARX application
Arguments
application A quoted string or a variable that contains the name of an
executable file. You can omit the .arx extension from the
file name.
You must supply the full path name of the ObjectARX
executable file, unless the file is in a directory that is in the
AutoCAD Support File Search Path.
onfailure An expression to be executed if the load fails.
Return Values
The application name, if successful. If unsuccessful and the onfailure argu-
ment is supplied, arxload returns the value of this argument, otherwise, fail-
ure results in an error message.
If you attempt to load an application that is already loaded, arxload issues
an error message. You may want to check the currently loaded ObjectARX
applications with the arx function before using arxload.
arx | 35
Examples
Load the geomcal.arx file supplied in the AutoCAD install directory:
Command: (arxload "c:/program files/ACAD2000/geomcal.arx")
"c:/program files/acad2000/geomcal.arx"
arxunload
Unloads an ObjectARX application
Arguments
application A quoted string or a variable that contains the name of a
file that was loaded with the arxload function. You can
omit the .arx extension and the path from the file name.
onfailure An expression to be executed if the unload fails.
Return Values
The application name, if successful. If unsuccessful and the onfailure argu-
ment is supplied, arxunload returns the value of this argument, otherwise,
failure results in an error message.
Note that locked ObjectARX applications cannot be unloaded. ObjectARX
applications are locked by default.
ascii
Returns the conversion of the first character of a string into its ASCII character code (an
integer)
(ascii string)
Arguments
string A string.
36 | AutoLISP Reference
Return Values
An integer.
Examples
Command: (ascii "A")
65
Command: (ascii "a")
97
Command: (ascii "BIG")
66
assoc
Searches an association list for an element and returns that association list entry
Arguments
element Key of an element in an association list.
alist An association list to be searched.
Return Values
The alist entry, if successful. If assoc does not find element as a key in alist, it
returns nil.
Examples
Command: (setq al '((name box) (width 3) (size 4.7263) (depth 5)))
((NAME BOX) (WIDTH 3) (SIZE 4.7263) (DEPTH 5))
Command: (assoc 'size al)
(SIZE 4.7263)
Command: (assoc 'weight al)
nil
atan
Returns the arctangent of a number in radians
assoc | 37
Arguments
num1 A number.
num2 A number.
Return Values
The arctangent of num1, in radians, if only num1 is supplied. If you supply
both num1 and num2 arguments, atan returns the arctangent of num1/num2,
in radians. If num2 is zero, it returns an angle of plus or minus 1.570796 radi-
ans (+90 degrees× or –90 degrees), depending on the sign of num1. The range
of angles returned is −pi/2 to +pi/2 radians.
Examples
Command: (atan 1)
0.785398
Command: (atan 1.0)
0.785398
Command: (atan 0.5)
0.463648
Command: (atan 1.0)
0.785398
Command: (atan -1.0)
-0.785398
Command: (atan 2.0 3.0)
0.588003
Command: (atan 2.0 -3.0)
2.55359
Command: (atan 1.0 0.0)
1.5708
atof
Converts a string into a real number
(atof string)
Arguments
string A string to be converted into a real number.
Return Values
A real number.
38 | AutoLISP Reference
Examples
Command: (atof "97.1")
97.1
Command: (atof "3")
3.0
Command: (atof "3.9")
3.9
atoi
Converts a string into an integer
(atoi string)
Arguments
string A string to be converted into an integer.
Return Values
An integer.
Examples
Command: (atoi "97")
97
Command: (atoi "3")
3
Command: (atoi "3.9")
3
atom
Verifies that an item is an atom
(atom item)
Arguments
item Any AutoLISP element.
Some versions of LISP differ in their interpretation of atom, so be careful
when converting from non-AutoLISP code.
atoi | 39
Return Values
Nil if item is a list, otherwise T. Anything that is not a list is considered an
atom.
Examples
Command: (setq a '(x y z))
(X Y Z)
Command: (setq b 'a)
A
Command: (atom 'a)
T
Command: (atom a)
nil
Command: (atom 'b)
T
Command: (atom b)
T
Command: (atom '(a b c))
nil
atoms-family
Returns a list of the currently defined symbols
Arguments
format An integer value of 0 or 1 that determines the format in
which atoms-family returns the symbol names:
0 Return the symbol names as a list
1 Return the symbol names as a list of strings
symlist A list of strings that specify the symbol names you want
atoms-family to search for.
Return Values
A list of symbols. If you specify symlist, then atoms-family returns the spec-
ified symbols that are currently defined, and returns nil for those symbols
that are not defined.
40 | AutoLISP Reference
Examples
Command: (atoms-family 0)
(BNS_PRE_SEL FITSTR2LEN C:AI_SPHERE ALERT DEFUN C:BEXTEND REM_GROUP
B_RESTORE_SYSVARS BNS_CMD_EXIT LISPED FNSPLITL...
The following code verifies that the symbols CAR, CDR, and XYZ are defined,
and returns the list as strings:
Command: (atoms-family 1 '("CAR" "CDR" "XYZ"))
("CAR" "CDR" nil)
The return value shows that the symbol XYZ is not defined.
autoarxload
Predefines command names to load an associated ObjectARX file
Arguments
filename A string specifying the .arx file to be loaded when one of
the commands defined by the cmdlist argument is entered
at the Command prompt. If you omit the path from
filename, AutoCAD looks for the file in the Support File
Search Path.
cmdlist A list of strings.
Return Values
nil
Examples
The following code defines the C:APP1, C:APP2, and C:APP3 functions to load
the bonusapp.arx file:
(autoarxload "BONUSAPP" '("APP1" "APP2" "APP3"))
autoarxload | 41
autoload
Predefines command names to load an associated AutoLISP file
Arguments
filename A string specifying the .lsp file to be loaded when one of
the commands defined by the cmdlist argument is entered
at the Command prompt. If you omit the path from
filename, AutoCAD looks for the file in the Support File
Search Path.
cmdlist A list of strings.
Return Values
nil
If you associate a command with filename and that command is not defined
in the specified file, AutoCAD alerts you with an error message when you
enter the command.
Examples
The following causes AutoCAD to load the bonusapp.lsp file the first time the
APP1, APP2, or APP3 commands are entered at the Command prompt:
Boole
Serves as a general bitwise Boolean function
Arguments
operator An integer between 0 and 15 representing one of the 16
possible Boolean functions in two variables.
42 | AutoLISP Reference
int1, int2... Integers.
Note that Boole will accept a single integer argument, but
the result is unpredictable.
Successive integer arguments are bitwise (logically) combined based on this
function and on the following truth table:
0 0 8
0 1 4
1 0 2
1 1 1
Each bit of int1 is paired with the corresponding bit of int2, specifying one
horizontal row of the truth table. The resulting bit is either 0 or 1, depending
on the setting of the operator bit that corresponds to this row of the truth
table.
If the appropriate bit is set in operator, the resulting bit is 1; otherwise the
resulting bit is 0. Some of the values for operator are equivalent to the stan-
dard Boolean operations AND, OR, XOR, and NOR.
Return Values
An integer.
Boole | 43
Examples
The following specifies a logical AND of the values 12 and 5:
Command: (Boole 1 12 5)
4
You can use other values of operator to perform other Boolean operations for
which there are no standard names. For example, if operator is 4, the resulting
bits are set if the corresponding bits are set in int2 but not in int1:
Command: (Boole 4 3 14)
12
boundp
Verifies if a value is bound to a symbol
(boundp sym)
Arguments
sym A symbol.
Return Values
T if sym has a value bound to it. If no value is bound to sym, or if it has been
bound to nil, boundp returns nil. If sym is an undefined symbol, it is auto-
matically created and is bound to nil.
Examples
Command: (setq a 2 b nil)
nil
Command: (boundp 'a)
T
Command: (boundp 'b)
nil
44 | AutoLISP Reference
caddr
Returns the third element of a list
(caddr list)
In AutoLISP, cadr is frequently used to obtain the Z coordinate of a 3D point
(the third element of a list of three reals).
Arguments
list A list.
Return Values
The third element in list; or nil, if the list is empty or contains fewer than
three elements.
Examples
Command: (setq pt3 '(5.25 1.0 3.0))
(5.25 1.0 3.0)
Command: (caddr pt3)
3.0
Command: (caddr '(5.25 1.0))
nil
cadr
Returns the second element of a list
(cadr list)
In AutoLISP, cadr is frequently used to obtain the Y coordinate of a 2D or 3D
point (the second element of a list of two or three reals).
Arguments
list A list.
Return Values
The second element in list, or nil, if the list is empty or contains only one
element.
caddr | 45
Examples
Command: (setq pt2 '(5.25 1.0))
(5.25 1.0)
Command: (cadr pt2)
1.0
Command: (cadr '(4.0))
nil
Command: (cadr '(5.25 1.0 3.0))
1.0
car
Returns the first element of a list
(car list)
Arguments
list A list.
Return Values
The first element in list; or nil, if the list is empty.
Examples
Command: (car '(a b c))
A
Command: (car '((a b) c))
(A B)
Command: (car '())
nil
cdr
Returns a list containing all but the first element of the specified list
(cdr list)
46 | AutoLISP Reference
Arguments
list A list.
Return Values
A list containing all the elements of list, except the first element (but see Note
below). If the list is empty, cdr returns nil.
NOTE When the list argument is a dotted pair, cdr returns the second element
without enclosing it in a list.
Examples
Command: (cdr '(a b c))
(B C)
Command: (cdr '((a b) c))
(C)
Command: (cdr '())
nil
Command: (cdr '(a . b))
B
Command: (cdr '(1 . "Text"))
"Text"
chr
Converts an integer representing an ASCII character code into a single-character string
(chr integer)
Arguments
list An integer.
Return Values
A string containing the ASCII character code for integer. If the integer is not
in the range of 1-255, the return value is unpredictable.
Examples
Command: (chr 65)
"A"
chr | 47
Command: (chr 66)
"B"
Command: (chr 97)
"a"
client_data_tile
Associates application-managed data with a dialog box tile
Arguments
key A string that specifies a tile. This argument is case-
sensitive.
clientdata A string to be associated with the key tile. An action
expression or callback function can refer to the string as
$data.
Return Values
nil
close
Closes an open file
(close file-desc)
Arguments
file-desc A file descriptor obtained from the open function.
Return Values
Nil if file-desc is valid, otherwise results in an error message.
After a close, the file descriptor is unchanged but is no longer valid. Data
added to an open file is not actually written until the file is closed.
Examples
The following code counts the number of lines in the file somefile.txt and sets
the variable ct equal to that number:
48 | AutoLISP Reference
(setq fil "SOMEFILE.TXT")
(setq x (open fil "r") ct 0)
(while (read-line x)
(setq ct (1+ ct))
)
(close x)
command
Executes an AutoCAD command
Arguments
arguments AutoCAD commands and their options.
The arguments to the command function can be strings,
reals, integers, or points, as expected by the prompt
sequence of the executed command. A null string ( "") is
equivalent to pressing ENTER on the keyboard. Invoking
command with no argument is equivalent to pressing ESC
and cancels most AutoCAD commands.
The command function evaluates each argument and sends it to AutoCAD in
response to successive prompts. It submits command names and options as
strings, 2D points as lists of two reals, and 3D points as lists of three reals.
AutoCAD recognizes command names only when it issues a Command
prompt.
Note that if you issue command from Visual LISP, focus does not change to the
AutoCAD window. If the command requires user input, you’ll see the return
value (nil) in the Console window, but AutoCAD will be waiting for input.
You must manually activate the AutoCAD window and respond to the
prompts. Until you do so, any subsequent commands will fail.
Return Values
nil
Examples
The following example sets two variables pt1 and pt2 equal to two point val-
ues 1,1 and 1,5. It then uses the command function to issue the LINE command
and pass the two point values.
Command: (setq pt1 '(1 1) pt2 '(1 5))
(1 5)
command | 49
Command: (command "line" pt1 pt2 "")
line From point:
To point:
To point:
Command: nil
SEE ALSO the vl-cmdf function in this reference and “Command Submis-
sion” in the Visual LISP Developer’s Guide.
cond
Serves as the primary conditional function for AutoLISP
Return Values
The value of the last expression in the sublist. If there is only one expression
in the sublist (that is, if result is missing), the value of the test expression is
returned. If no arguments are supplied, cond returns nil.
50 | AutoLISP Reference
Examples
The following example uses cond to perform an absolute value calculation:
(cond
((minusp a) (- a))
(t a)
)
cons
Adds an element to the beginning of a list, or constructs a dotted list
Arguments
new-first- Element to be added to the beginning of a list. This
element element can be an atom or a list.
list-or-atom A list or an atom.
Return Values
The value returned depends on the data type of list-or-atom. If list-or-atom is
a list, cons returns that list with new-first-element added as the first item in the
list. If list-or-atom is an atom, cons returns a dotted pair consisting of new-
first-element and list-or-atom.
Examples
Command: (cons 'a '(b c d))
(A B C D)
Command: (cons '(a) '(b c d))
((A) B C D)
cons | 51
Command: (cons 'a 2)
(A . 2)
cos
Returns the cosine of an angle expressed in radians
(cos ang)
Arguments
ang An angle, in radians.
Return Values
The cosine of ang, in radians.
Examples
Command: (cos 0.0)
1.0
Command: (cos pi)
-1.0
cvunit
Converts a value from one unit of measurement to another
Arguments
value The numeric value or point list (2D or 3D point) to be
converted.
from-unit The unit that value is being converted from.
to-unit The unit that value is being converted to.
The from-unit and to-unit arguments can name any unit type found in the
acad.unt file.
52 | AutoLISP Reference
Return Values
The converted value, if successful, or nil, if either unit name is unknown
(not found in the acad.unt file), or if the two units are incompatible (for
example, trying to convert grams into years).
Examples
Command: (cvunit 1 "minute" "second")
60.0
Command: (cvunit 1 "gallon" "furlong")
nil
Command: (cvunit 1.0 "inch" "cm")
2.54
Command: (cvunit 1.0 "acre" "sq yard")
4840.0
Command: (cvunit '(1.0 2.5) "ft" "in")
(12.0 30.0)
Command: (cvunit '(1 2 3) "ft" "in")
(12.0 24.0 36.0)
NOTE If you have several values to convert in the same manner, it is more
efficient to convert the value 1.0 once and then apply the resulting value as a
scale factor in your own function or computation. This works for all predefined
units except temperature, where an offset is involved as well.
defun
Defines a function
Arguments
sym A symbol naming the function.
arguments The names of arguments expected by the function.
/ variables The names of one or more local variables for the function.
The slash preceding the variable names must be separated
from the first local name and from the last argument, if
any, by at least one space.
defun | 53
expr Any number of AutoLISP expressions to be evaluated
when the function executes.
If you do not declare any arguments or local symbols, you must supply an
empty set of parentheses after the function name.
If duplicate argument or symbol names are specified, AutoLISP uses the first
occurrence of each name and ignores the following occurrences.
Return Values
The result of the last expression evaluated.
WARNING! Never use the name of a built-in function or symbol for the sym
argument to defun. This overwrites the original definition and makes the built-in
function or symbol inaccessible. To get a list of built-in and previously defined
functions, use the atoms-family function.
Examples
(defun myfunc (x y) ...) Function takes two arguments
(defun myfunc (/ a b) ...) Function has two local variables
(defun myfunc (x / temp) ...) One argument, one local variable
(defun myfunc () ...) No arguments or local variables
SEE ALSO “Symbol and Function Handling” in the Visual LISP Developer’s
Guide.
defun-q
Defines a function as a list
Arguments
sym A symbol naming the function.
arguments The names of arguments expected by the function.
54 | AutoLISP Reference
/ variables The names of one or more local variables for the function.
The slash preceding the variable names must be separated
from the first local name and from the last argument, if
any, by at least one space.
expr Any number of AutoLISP expressions to be evaluated
when the function executes.
If you do not declare any arguments or local symbols, you must supply an
empty set of parentheses after the function name.
If duplicate argument or symbol names are specified, AutoLISP uses the first
occurrence of each name and ignores the following occurrences.
Return Values
The result of the last expression evaluated.
Examples
_$ (defun-q my-startup (x) (print (list x)))
MY-STARTUP
_$ (my-startup 5)
(5) (5)
defun-q-list-ref
Displays the list structure of function defined with defun-q
(defun-q-list-ref 'function )
Arguments
function A symbol naming the function.
Return Values
The list definition of the function, or nil, if the argument is not a list.
Examples
Define a function using defun-q:
defun-q-list-ref | 55
_$ (defun-q my-startup (x) (print (list x)))
MY-STARTUP
defun-q-list-set
Sets the value of a symbol to be a function defined by a list
Arguments
sym A symbol naming the function
list A list containing the expressions to be included in the
function.
Return Values
The sym defined.
Examples
_$ (defun-q-list-set 'foo '((x) x))
FOO
_$ (foo 3)
3
56 | AutoLISP Reference
The following illustrates how the functions respond individually, and how
the functions work after being combined using defun-q-list-set:
_$ (defun-q foo (x) (print (list 'foo x)))
FOO
_$ (foo 1)
(FOO 1) (FOO 1)
_$ (defun-q bar (x) (print (list 'bar x)))
BAR
_$ (bar 2)
(BAR 2) (BAR 2)
_$ (defun-q-list-set
'foo
(append (defun-q-list-ref 'foo)
(cdr (defun-q-list-ref 'bar))
))
FOO
_$ (foo 3)
(FOO 3)
(BAR 3) (BAR 3)
dictadd
Adds a nongraphical object to the specified dictionary
Arguments
ename Name of the dictionary the object is being added to.
symbol The key name of the object being added to the dictionary;
symbol must be a unique name that does not already exist
in the dictionary.
newobj A nongraphical object to be added to the dictionary.
As a general rule, each object added to a dictionary must be unique to that
dictionary. This is specifically a problem when adding group objects to the
group dictionary. Adding the same group object using different key names
results in duplicate group names which can send the dictnext function into
an infinite loop.
Return Values
The entity name of the object added to the dictionary.
dictadd | 57
Examples
The examples that follow create objects and add them to the named object
dictionary.
Create a dictionary entry list:
Command: (setq dictionary
(list '(0 . "DICTIONARY") '(100 . "AcDbDictionary")))
((0 . "DICTIONARY") (100 . "AcDbDictionary"))
dictnext
Finds the next item in a dictionary
Arguments
ename Name of the dictionary being viewed.
58 | AutoLISP Reference
rewind If this argument is present and is not nil, the dictionary
is rewound and the first entry in it is retrieved.
Return Values
The next entry in the specified dictionary, or nil, when the end of the dic-
tionary is reached. Entries are returned as lists of dotted pairs of DXF-type
codes and values. Deleted dictionary entries are not returned.
The dictsearch function specifies the initial entry retrieved.
Use namedobjdict to obtain the master dictionary entity name.
NOTE Once you begin stepping through the contents of a dictionary, passing
a different dictionary name to dictnext will cause the place to be lost in the orig-
inal dictionary. In other words, only one global iterator is maintained for use in
this function.
Examples
Create a dictionary and an entry as shown in the example for dictadd. Then
make another Xrecord object:
Command: (setq xname (entmakex datalist))
<Entity name: 1b62d60>
Add this Xrecord object to the dictionary, as the second record in the dictio-
nary:
Command: (dictadd newdict "DATA_RECORD_2" xname)
<Entity name: 1b62d60>
Return the entity name of the next entry in the dictionary:
Command: (cdr (car (dictnext newdict)))
<Entity name: 1bac958>
dictnext returns the name of the first entity added to the dictionary.
dictnext | 59
Rewind to the first entry in the dictionary and return the entity name of that
entry:
Command: (cdr (car (dictnext newdict T)))
<Entity name: 1bac958>
Specifying T for the optional rewind argument causes dictnext to return the
first entry in the dictionary.
dictremove
Removes an entry from the specified dictionary
Arguments
ename Name of the dictionary being modified.
symbol The entry to be removed from ename.
The dictremove function does not allow the removal of an mlinestyle from
the mlinestyle dictionary if it is actively referenced by an mline in the data-
base.
Return Values
The entity name of the removed entry. If ename is invalid or symbol is not
found, dictremove returns nil.
Examples
The following example removes the dictionary created in the dictadd exam-
ple:
Command: (dictremove (namedobjdict) "my_way_cool_dictionary")
<Entity name: 1d98950>
60 | AutoLISP Reference
SEE ALSO the dictadd, dictnext, dictrename, dictsearch, and namedobj-
dict functions.
dictrename
Renames a dictionary entry
Arguments
ename Name of the dictionary being modified.
oldsym Original key name of the entry.
newsym New key name of the entry.
Return Values
The newsym value, if the rename is successful. If either the oldname is not
present in the dictionary, or ename is invalid, or newname is invalid, or
newname is already present in the dictionary, dictrename returns nil.
Examples
The following example renames the dictionary created in the dictadd sam-
ple:
Command: (dictrename (namedobjdict) "my_way_cool_dictionary"
"An even cooler dictionary")
"An even cooler dictionary"
dictsearch
Searches a dictionary for an item
Arguments
ename Name of the dictionary being searched.
symbol A string that specifies the item to be searched for within
the dictionary.
dictrename | 61
setnext If present and not nil, the dictnext entry counter is
adjusted so the following dictnext call returns the entry
after the one returned by this dictsearch call.
Return Values
The entry for the specified item, if successful, or nil, if no entry is found.
Examples
The following example illustrates the use of dictsearch to obtain the dictio-
nary added in the dictadd example:
Command: (setq newdictlist
(dictsearch (namedobjdict) "my_way_cool_dictionary"))
((-1 . <Entity name: 1d98950>) (0 . "DICTIONARY") (5 . "52") (102 .
"{ACAD_REACTORS") (330 . <Entity name: 1d98860>) (102 . "}") (330 .
<Entity name: 1d98860>) (100 . "AcDbDictionary") (280 . 0) (281 .
1) (3 . "DATA_RECORD_1") (350 . <Entity name: 1d98958>))
dimx_tile
Retrieves the width of a tile in dialog box units
(dimx_tile key)
Arguments
key A string specifying the tile to be queried. The key
argument is case-sensitive.
Return Values
The width of the tile.
The coordinates returned are the maximum allowed within the tile. Because
coordinates are zero based, this functions return one less than the total X
dimension (X–1). The dimx_tile and dimy_tile functions are provided for
use with vector_image, fill_image, and slide_image, which require you to
specify absolute tile coordinates.
Examples
(setq tile_width (dimx_tile "my_tile"))
62 | AutoLISP Reference
dimy_tile
Retrieves the height of a tile in dialog box units
(dimy_tile key)
Arguments
key A string specifying the tile to be queried. The key
argument is case-sensitive.
Return Values
The height of the tile.
The coordinates returned are the maximum allowed within the tile. Because
coordinates are zero based, this functions return one less than the total Y
dimension (Y–1). The dimx_tile and dimy_tile functions are provided for
use with vector_image, fill_image, and slide_image, which require you to
specify absolute tile coordinates.
Examples
(setq tile_height (dimy_tile "my_tile"))
distance
Returns the 3D distance between two points
Arguments
pt1 A 2D or 3D point list.
pt1 A 2D or 3D point list.
Return Values
The distance.
If one or both of the supplied points is a 2D point, then distance ignores the
Z coordinates of any 3D points supplied and returns the 2D distance between
the points as projected into the current construction plane.
dimy_tile | 63
Examples
Command: (distance '(1.0 2.5 3.0) '(7.7 2.5 3.0))
6.7
Command: (distance '(1.0 2.0 0.5) '(3.0 4.0 0.5))
2.82843
distof
Converts a string that represents a real (floating-point) value into a real value
Arguments
string A string to be converted. The argument must be a string
that distof can parse correctly according to the units
specified by mode. It can be in the same form that rtos
returns, or in a form that AutoCAD allows for keyboard
entry.
mode The units in which the string is currently formatted. The
mode corresponds to the values allowed for the AutoCAD
system variable LUNITS. Specify one of the following
numbers for mode:
1 Scientific
2 Decimal
3 Engineering (feet and decimal inches)
4 Architectural (feet and fractional inches)
5 Fractional
Return Values
A real number, if successful, otherwise nil.
64 | AutoLISP Reference
NOTE The distof function treats modes 3 and 4 the same. That is, if mode
specifies 3 (engineering) or 4 (architectural) units, and string is in either of these
formats, distof returns the correct real value.
done_dialog
Terminates a dialog box
(done_dialog [status])
Arguments
status A positive integer that start_dialog will return instead of
returning 1 for OK or 0 for Cancel. The meaning of any
status value greater than 1 is determined by your
application.
You must call done_dialog from within an action expression or callback
function (see “action_tile”).
Return Values
A two-dimensional point list that is the (X,Y) location of the dialog box when
the user exited it.
Usage Notes
If you provide a callback for the button whose key is "accept" or "cancel"
(usually the OK and Cancel buttons), the callback must call done_dialog
explicitly. If it doesn’t, the user can be trapped in the dialog box. If you don’t
provide an explicit callback for these buttons and use the standard exit but-
tons, AutoCAD handles them automatically. Also, an explicit AutoLISP
action for the “accept” button must specify a status of 1 (or an application-
defined value); otherwise, start_dialog returns the default value, 0, which
makes it appear as if the dialog box was canceled.
end_image
Ends creation of the currently active dialog box image
(end_image)
This function is the complement of start_image.
done_dialog | 65
Return Values
nil
end_list
Ends processing of the currently active dialog box list
(end_list)
This function is the complement of start_list.
Return Values
nil
entdel
Deletes objects (entities) or restores previously deleted objects
(entdel ename)
The entity specified by ename is deleted if it is currently in the drawing. The
entdel function restores the entity to the drawing if it has been deleted pre-
viously in this editing session. Deleted entities are purged from the drawing
when the drawing is exited. The entdel function can delete both graphical
and non-graphical entities.
Arguments
ename Name of the entity to be deleted or restored.
Return Values
The entity name.
Usage Notes
The entdel function operates only on main entities. Attributes and polyline
vertices cannot be deleted independently of their parent entities. You can use
the command function to operate the ATTEDIT or PEDIT commands to modify
subentities.
66 | AutoLISP Reference
You cannot delete entities within a block definition. However, you can com-
pletely redefine a block definition, minus the entity you want deleted, with
entmake.
Examples
Get the name of the first entity in the drawing and assign it to variable e1:
Command: (setq e1 (entnext))
<Entity name: 2c90520>
entget
Retrieves an object’s (entity’s) definition data
Arguments
ename Name of the entity being queried. The ename can refer to
either a graphical or non-graphical entity.
applist A list of registered application names.
Return Values
An association list containing the entity definition of ename. If you specify
the optional applist argument, entget also returns the extended data associ-
ated with the specified applications. Objects in the list are assigned AutoCAD
DXF group codes for each part of the entity data.
Note that the DXF group codes used by AutoLISP differ slightly from the
group codes in a DXF file. The AutoLISP DXF group codes are documented in
the DXF Reference.
Examples
Assume that the last object created in the drawing is a line drawn from point
(1,2) to point (6,5). The following example shows code that retrieves the
entget | 67
entity name of the last object with the entlast function, and passes that
name to entget:
Command: (entget (entlast))
((-1 . <Entity name: 1bbd1d0>) (0 . "LINE") (330 . <Entity name:
1bbd0c8>) (5 . "6A") (100 . "AcDbEntity") (67 . 0) (410 . "Model")
(8 . "0") (100 . "AcDbLine") (10 1.0 2.0 0.0) (11 6.0 5.0 0.0) (210
0.0 0.0 1.0))
SEE ALSO the entdel, entlast, entmod, entmake, entnext, and entupd
functions. See “Entity Data Functions” in the Visual LISP Developer’s Guide.
entlast
Returns the name of the last nondeleted main object (entity) in the drawing
(entlast)
The entlast function is frequently used to obtain the name of a new entity
that has just been added with the command function. To be selected, the entity
need not be on the screen or on a thawed layer.
Return Values
An entity name, or nil, if there are no entities in the current drawing.
Examples
Set variable e1 to the name of the last entity added to the drawing:
Command: (setq e1 (entlast))
<Entity name: 2c90538>
If your application requires the name of the last nondeleted entity (main
entity or subentity), define a function such as the following and call it
instead of entlast.
(defun lastent (/ a b)
(if (setq a (entlast)) Gets last main entity
(while (setq b (entnext a)) If subentities follow, loops
until there are no more
(setq a b) subentities
)
)
a Returns last main entity
) or subentity
SEE ALSO the entdel, entget, entmod, entnext, and entsel functions.
68 | AutoLISP Reference
entmake
Creates a new entity in the drawing
(entmake [elist])
The entmake function can define both graphical and nongraphical entities.
Arguments
elist A list of entity definition data in a format similar to that
returned by the entget function. The elist argument must
contain all of the information necessary to define the
entity. If any required definition data is omitted, entmake
returns nil and the entity is rejected. If you omit optional
definition data (such as the layer), entmake uses the
default value.
The entity type (for example, CIRCLE or LINE) must be the
first or second field of the elist. If entity type is the second
field, it can be preceded only by the entity name. The
entmake function ignores the entity name when creating
the new entity. If the elist contains an entity handle,
entmake ignores that too.
Return Values
If successful, entmake returns the entity’s list of definition data. If entmake is
unable to create the entity, it returns nil.
Completion of a block definition (entmake of an endblk) returns the block’s
name rather than the entity data list normally returned. See “Creating Com-
plex Entities” in the Visual LISP Developer’s Guide for more information on
defining blocks.
Examples
The following code creates a red circle (color 62), centered at (4,4) with a
radius of 1. The optional layer and linetype fields have been omitted and
therefore assume default values.
Command: (entmake '((0 . "CIRCLE") (62 . 1) (10 4.0 4.0 0.0)
(40 . 1.0)))
((0 . "CIRCLE") (62 . 1) (10 4.0 4.0 0.0) (40 . 1.0))
entmake | 69
A group 66 code is honored only for insert objects (meaning attributes follow).
For polyline entities, the group 66 code is forced to a value of 1 (meaning
vertices follow), and for all other entities it takes a default of 0. The only entity
that can follow a polyline entity is a vertex entity.
The group code 2 (block name) of a dimension entity is optional for the
entmake function. If the block name is omitted from the entity definition list,
AutoCAD creates a new one. Otherwise, AutoCAD creates the dimension
using the name provided.
SEE ALSO the entdel, entget, and entmod functions. In the Visual LISP
Developer’s Guide, refer to “Entity Data Functions” for additional information
on creating entities in a drawing, “Adding an Entity to a Drawing” for specif-
ics on using entmake, and “Creating Complex Entities” for information on
creating complex entities.
entmakex
Makes a new object or entity, gives it a handle and entity name (but, does not assign an
owner), and then returns the new entity name
(entmakex [elist])
The entmakex function can define both graphical and nongraphical entities.
Arguments
elist A list of entity definition data in a format similar to that
returned by the entget function. The elist argument must
contain all of the information necessary to define the
entity. If any required definition data is omitted,
entmakex returns nil and the entity is rejected. If you
omit optional definition data (such as the layer), entmakex
uses the default value.
Return Values
If successful, entmakex returns the name of the entity created. If entmakex is
unable to create the entity, the function returns nil.
Examples
$ (entmakex '((0 . "CIRCLE") (62 . 1) (10 4.0 3.0 0.0) (40 . 1.0)))
<Entity name: 1d45558>
70 | AutoLISP Reference
WARNING! Objects and entities without owners are not written out to .dwg
or .dxf files. Be sure to set an owner at some point after using entmakex. For
example, you can use dictadd to set a dictionary to own an object.
entmod
Modifies the definition data of an object (entity)
(entmod elist)
The entmod function updates database information for the entity name spec-
ified by the –1 group in elist. The primary mechanism through which
AutoLISP updates the database is by retrieving entities with entget, modify-
ing the list defining an entity, and updating the entity in the database with
entmod. The entmod function can modify both graphical and nongraphical
objects.
Arguments
elist A list of entity definition data in a format similar to that
returned by the entget function.
For entity fields with floating-point values (such as
thickness), entmod accepts integer values and converts
them to floating point. Similarly, if you supply a floating-
point value for an integer entity field (such as color
number), entmod truncates it and converts it to an integer.
Return Values
If successful, entmod returns the elist supplied to it. If entmod is unable to
modify the specified entity, the function returns nil.
Examples
The following sequence of commands obtains the properties of an entity,
then modifies the entity.
Set the en1 variable to the name of the first entity in the drawing:
Command: (setq en1 (entnext))
<Entity name: 2c90520>
Set a variable named ed to the entity data of entity en1:
entmod | 71
Command: (setq ed (entget en1))
((-1 . <Entity name: 2c90520>) (0 . "CIRCLE") (5 . "4C") (100 .
"AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbCircle") (10 3.45373
6.21635 0.0) (40 . 2.94827) (210 0.0 0.0 1.0))
■ An entity’s type and handle cannot be changed. If you want to do this, use
entdel to delete the entity, then make a new entity with the command or
entmake functions.
■ The entmod function cannot change internal fields such as the entity
name in the –2 group of a seqend entity—attempts to change such fields
are ignored.
■ You cannot use the entmod function to modify a viewport entity.
You can change an entity’s space visibility field to 0 or 1 (except for viewport
objects). If you use entmod to modify an entity within a block definition, the
modification affects all instances of the block in the drawing.
Before performing an entmod on vertex entities, you should read or write the
polyline entity’s header. If the most recently processed polyline entity is dif-
ferent from the one to which the vertex belongs, width information (the 40
and 41 groups) can be lost.
WARNING! You can use entmod to modify entities within a block definition,
but doing so can create a self-referencing block, which will cause AutoCAD to
stop.
SEE ALSO the entdel, entget, entmake, and entnext functions. In the
Visual LISP Developer’s Guide, refer to “Modifying an Entity” and “Entity Data
Functions and the Graphics Screen.”
72 | AutoLISP Reference
entnext
Returns the name of the next object (entity) in the drawing
(entnext [ename])
Arguments
ename The name of an existing entity.
Return Values
If entnext is called with no arguments, it returns the entity name of the first
nondeleted entity in the database. If an ename argument is supplied to ent-
next, the function returns the entity name of the first nondeleted entity fol-
lowing ename in the database. If there is no next entity in the database, it
returns nil. The entnext function returns both main entities and subentities.
Examples
(setq e1 (entnext)) ; Sets e1 to the name of the first entity in the drawing
(setq e2 (entnext e1)) ; Sets e2 to the name of the entity following e1
Notes
The entities selected by ssget are main entities, not attributes of blocks or
vertices of polylines. You can access the internal structure of these complex
entities by walking through the subentities with entnext. Once you obtain a
subentity’s name, you can operate on it like any other entity. If you obtain
the name of a subentity with entnext, you can find the parent entity by step-
ping forward with entnext until a seqend entity is found, then extracting the
–2 group from that entity, which is the main entity’s name.
entsel
Prompts the user to select a single object (entity) by specifying a point
(entsel [msg])
Arguments
msg A prompt string to be displayed to users. If omitted,
entsel prompts with the message, "Select object."
entnext | 73
Return Values
A list whose first element is the entity name of the chosen object and whose
second element is the coordinates (in terms of the current UCS) of the point
used to pick the object.
The pick point returned by entsel does not represent a point that lies on the
selected object. The point returned is the location of the crosshairs at the
time of selection. The relationship between the pick point and the object will
vary depending on the size of the pickbox and the current zoom scale.
Examples
The following AutoCAD command sequence illustrates the use of the entsel
function and the list returned:
Command: line
From point: 1,1
To point: 6,6
To point: ENTER
Command: (setq e (entsel "Please choose an object: "))
Please choose an object: 3,3
(<Entity name: 60000014> (3.0 3.0 0.0))
entupd
Updates the screen image of an object (entity)
(entupd ename)
Arguments
ename The name of the entity to be updated on the screen.
74 | AutoLISP Reference
Return Values
The entity (ename) updated, or nil, if nothing was updated.
Examples
Assuming that the first entity in the drawing is a 3D polyline with several
vertices, the following code modifies and redisplays the polyline:
(setq e1 (entnext)) ; Sets e1 to the polyline’s entity name
(setq e2 (entnext e1)) ; Sets e2 to its first vertex
(setq ed (entget e2)) ; Sets ed to the vertex data
(setq ed
(subst '(10 1.0 2.0)
(assoc 10 ed) ; Changes the vertex’s location in ed
ed ; to point (1,2)
)
)
(entmod ed) ; Moves the vertex in the drawing
(entupd e1) ; Regenerates the polyline entity e1
eq
Determines whether two expressions are identical
eq | 75
Arguments
expr1 The expression to be compared.
expr2 The expression to compare with expr1.
Return Values
T if the two expressions are identical, nil otherwise.
Examples
Given the following assignments:
(setq f1 '(a b c))
(setq f2 '(a b c))
(setq f3 f2)
eq returns nil because f1 and f3, while containing the same value, do not
refer to the same list.
Compare f3 and f2:
Command: (eq f3 f2)
T
equal
Determines whether two expressions are equal
Arguments
expr1 The expression to be compared.
expr2 The expression to compare with expr1.
fuzz A real number defining the maximum amount by which
expr1 and expr2 can differ and still be considered equal.
When comparing two real numbers (or two lists of real numbers, as in
points), the two identical numbers can differ slightly if different methods are
76 | AutoLISP Reference
used to calculate them. You can specify a fuzz amount to compensate for the
difference that may result from the different methods of calculation.
Return Values
T if the two expressions are equal (evaluate to the same value), nil otherwise.
Examples
Given the following assignments:
(setq f1 '(a b c))
(setq f2 '(a b c))
(setq f3 f2)
(setq a 1.123456)
(setq b 1.123457)
Compare f1 to f3:
Command: (equal f1 f3)
T
Compare f3 to f2:
Command: (equal f3 f2)
T
Compare a to b:
Command: (equal a b)
nil
The a and b variables differ by an amount equal to the specified fuzz factor,
so equal considers the variables equal.
equal | 77
*error*
A user-definable error-handling function
(*error* string)
If *error* is not nil, it is executed as a function whenever an AutoLISP error
condition exists. AutoCAD passes one argument to *error*, which is a string
containing a description of the error.
Your *error* function can include calls to the command function without
arguments (for example, (command)). This will cancel a previous AutoCAD
command called with the command function.
Return Values
This function does not return, except when using vl-exit-with-value.
Examples
The following function does the same thing that the AutoLISP standard error
handler does. It prints the word "error," followed by a description:
(defun *error* (msg)
(princ "error: ")
(princ msg)
(princ)
)
eval
Returns the result of evaluating an AutoLISP expression
(eval expr)
Arguments
expr The expression to be evaluated.
Return Values
The result of the expression, after evaluation.
78 | AutoLISP Reference
Examples
First, set some variables:
Command: (setq a 123)
123
Command: (setq b 'a)
A
exit
Forces the current application to quit
(exit)
If exit is called, it returns the error message quit/exit abort and returns to the
AutoCAD Command prompt.
exp
Returns the constant e (a real number) raised to a specified power (the natural antilog)
(exp num)
Arguments
num A real number.
Return Values
A real (num), raised to its natural antilogarithm.
exit | 79
Examples
Command: (exp 1.0)
2.71828
Command: (exp 2.2)
9.02501
Command: (exp -0.4)
0.67032
expand
Allocates additional memory for AutoLISP
(expand n-expand)
Arguments
n-expand An integer indicating the amount of additional memory
to be allocated. Memory is allocated as follows:
■ n-alloc free symbols
■ n-alloc free strings
■ n-alloc free usubrs
■ n-alloc free reals
■ n-alloc * n-expand cons cells
Return Values
An integer indicating the number of free conses divided by n-alloc.
Examples
Set the segment size to 100:
_$ (alloc 100)
1000
This ensures that AutoLISP now has memory available for at least 200 addi-
tional symbols, strings, usubrs and reals each, and 8200 free conses.
80 | AutoLISP Reference
expt
Returns a number raised to a specified power
Arguments
number Any number.
power The power to raise number to.
Return Values
If both arguments are integers, the result is an integer, otherwise, the result
is a real.
Examples
Command: (expt 2 4)
16
Command: (expt 3.0 2.0)
9.0
fill_image
Draws a filled rectangle in the currently active dialog box image tile
Arguments
x1 X coordinate of the upper-left corner of the rectangle
located at (x1,y1). Must be a positive value.
y1 Y coordinate of upper-left corner. Must be a positive value.
width Width of the fill area (in pixels), relative to x1.
expt | 81
height Width of the fill area (in pixels), relative to y1.
color An AutoCAD color number, or one of the logical color
numbers shown in the following table:
Return Values
An integer representing the fill color.
Examples
(setq color -2) ;; color of AutoCAD background screen
(fill_image
0
0
(dimx_tile "slide_tile")
(dimy_tile "slide_tile")
color
)
(end_image)
findfile
Searches the AutoCAD library path for the specified file or directory
(findfile filename)
The findfile function makes no assumption about the file type or extension
of filename. If filename does not specify a drive/directory prefix, findfile
searches the AutoCAD library path. If a drive/directory prefix is supplied,
findfile looks only in that directory.
Arguments
filename Name of the file or directory to be searched for.
82 | AutoLISP Reference
Return Values
A string containing the fully qualified file name, or nil, if the specified file
or directory is not found.
The file name returned by findfile is suitable for use with the open function.
Examples
If the current directory is /acad2000 and it contains the file abc.lsp, the fol-
lowing function call retrieves the path name:
Command: (findfile "abc.lsp")
"C:\\Program Files\\ACAD2000\\abc.lsp"
If the file nosuch is not present in any of the directories on the library search
path, findfile returns nil:
Command: (findfile "nosuch")
nil
Note that prior to AutoCAD Release 14, findfile only returned a path if you
supplied a valid file name as your argument. If you supplied a directory path,
findfile returned nil even if the path existed. For example, the following
call to findfile returns a path name in AutoCAD 2000:
Command: (findfile "c:/program files/acad2000")
"C:\\program files\\acad2000"
fix
Returns the conversion of a real number into the nearest smaller integer
(fix number)
The fix function truncates number to the nearest integer by discarding the
fractional portion.
Arguments
number A real number.
fix | 83
Return Values
The integer derived from number.
If number is larger than the largest possible integer (+2,147,483,647 or
–2,147,483,648 on a 32-bit platform), fix returns a truncated real (although
integers transferred between AutoLISP and AutoCAD are restricted to 16-bit
values).
Examples
Command: (fix 3)
3
Command: (fix 3.7)
3
float
Returns the conversion of a number into a real number
(float number)
Arguments
number Any number.
Return Values
The real number derived from number.
Examples
Command: (float 3)
3.0
Command: (float 3.75)
3.75
foreach
Evaluates expressions for all members of a list
84 | AutoLISP Reference
Arguments
name Variable that each element in the list will be assigned to.
list List to be stepped through and evaluated.
expr Expression to be evaluated for each element in list.
Return Values
The result of the last expr evaluated. If no expr is specified, foreach returns
nil.
Examples
Print each element in a list:
Command: (foreach n '(a b c) (print n))
A
B
C C
foreach prints each element in the list and returns C, the last element. This
command is equivalent to the following sequence of commands:
(print a)
(print b)
(print c)
except that foreach returns the result of only the last expression evaluated.
function
Tells the Visual LISP compiler to link and optimize an argument as if it were a built-in
function
Arguments
symbol A symbol naming a function.
function | 85
lambda-expr An expression of the following form:
(LAMBDA arguments {S-expression}* )
Return Values
The result of the evaluated expression.
Examples
The Visual LISP compiler cannot optimize the quoted lambda expression in
the following code:
(mapcar
'(lambda (x) (* x x))
'(1 2 3))
After adding the function function to the expression, the compiler can opti-
mized the lambda expression. For example:
(mapcar
(function (lambda (x) (* x x)))
'(1 2 3))
gc
Forces a garbage collection, which frees up unused memory
(gc)
gcd
Returns the greatest common denominator of two integers
Arguments
int1 An integer; must be greater than 0.
int2 An integer; must be greater than 0.
Return Values
An integer representing the greatest common denominator between int1 and
int2.
86 | AutoLISP Reference
Examples
Command: (gcd 81 57)
3
Command: (gcd 12 20)
4
get_attr
Retrieves the DCL value of a dialog box attribute
Arguments
key A string that specifies the tile. This parameter is case-
sensitive.
attribute A string naming the attribute as it appears in the tile’s DCL
description.
Return Values
A string containing the attribute’s initial value as specified in its DCL descrip-
tion.
get_tile
Retrieves the current runtime value of a dialog box tile
(get_tile key)
Arguments
key A string that specifies the tile. This parameter is case-
sensitive.
Return Values
A string containing the tile’s value.
get_attr | 87
getangle
Pauses for user input of an angle, and returns that angle in radians
Arguments
pt A 2D base point in the current UCS.
The pt argument, if specified, is assumed to be the first of
two points, so the user can show AutoLISP the angle by
pointing to one other point. You can supply a 3D base
point, but the angle is always measured in the current
construction plane.
msg A string to be displayed to prompt the user.
Return Values
The angle specified by the user, in radians.
The getangle function measures angles with the zero-radian direction (set by
the ANGBASE system variable) with angles increasing in the counterclockwise
direction. The returned angle is expressed in radians with respect to the
current construction plane (the XY plane of the current UCS, at the current
elevation).
Examples
The following code examples show how different arguments can be used
with getangle:
Command: (setq ang (getangle))
Command: (setq ang (getangle '(1.0 3.5)))
Command: (setq ang (getangle "Which way? "))
Command: (setq ang (getangle '(1.0 3.5) "Which way? "))
Usage Notes
Users can specify an angle by entering a number in the AutoCAD current
angle units format. Although the current angle units format might be in
degrees, grads, or some other unit, this function always returns the angle in
radians. The user can also show AutoLISP the angle by pointing to two 2D
locations on the graphics screen. AutoCAD draws a rubber-band line from
the first point to the current crosshairs position to help you visualize the
angle.
88 | AutoLISP Reference
It is important to understand the difference between the input angle and the
angle returned by getangle. Angles that are passed to getangle are based on
the current settings of ANGDIR and ANGBASE. However, once an angle is pro-
vided, it is measured in a counterclockwise direction (ignoring ANGDIR) with
zero radians as the current setting of ANGBASE.
The user cannot enter another AutoLISP expression as the response to a
getangle request.
getcfg
Retrieves application data from the AppData section of the acad.cfg file
(getcfg cfgname)
Arguments
cfgname A string (maximum length of 496 characters) naming the
section and parameter value to retrieve.
The cfgname argument must be a string of the following form:
"AppData/application_name/section_name/.../param_name"
Return Values
Application data, if successful. If cfgname is not valid, getcfg returns nil.
Examples
Assuming the WallThk parameter in the AppData/ArchStuff section has a
value of 8, the following command retrieves that value:
Command: (getcfg "AppData/ArchStuff/WallThk")
"8"
getcname
Retrieves the localized or English name of an AutoCAD command
(getcname cname)
getcfg | 89
Arguments
cname The localized or underscored English command name;
must be 64 characters or less in length.
Return Values
If cname is not preceded by an underscore (assumed to be the localized com-
mand name), getcname returns the underscored English command name. If
cname is preceded by an underscore, getcname returns the localized com-
mand name. This function returns nil if cname is not a valid command
name.
Examples
In a French version of AutoCAD, the following is true.
(getcname "ETIRER") returns "_STRETCH"
(getcname "_STRETCH") returns "ETIRER"
getcorner
Pauses for user input of a rectangle’s second corner
(getcorner pt [msg])
The getcorner function takes a base point argument, based on the current
UCS, and draws a rectangle from that point as the user moves the crosshairs
on the screen.
The user cannot enter another AutoLISP expression in response to a
getcorner request.
Arguments
pt A point to be used as the base point.
msg A string to be displayed to prompt the user.
Return Values
The getcorner function returns a point in the current UCS, similar to get-
point. If the user supplies a 3D point, its Z coordinate is ignored. The current
elevation is used as the Z coordinate.
Examples
Command: (getcorner '(7.64935 6.02964 0.0))
(17.2066 1.47628 0.0)
90 | AutoLISP Reference
Command: (getcorner '(7.64935 6.02964 0.0) "Pick a corner")
Pick a corner(15.9584 2.40119 0.0)
getdist
Pauses for user input of a distance
Arguments
pt A 2D or 3D point to be used as the base point in the
current UCS. If pt is provided, the user is prompted for the
second point.
msg A string to be displayed to prompt the user. If no string is
supplied, AutoCAD does not display a message.
Return Values
A real number. If a 3D point is provided, the returned value is a 3D distance.
However, setting the 64 bit of the initget function instructs getdist to
ignore the Z component of 3D points and to return a 2D distance.
Examples
(setq dist (getdist))
(setq dist (getdist '(1.0 3.5)))
(setq dist (getdist "How far "))
(setq dist (getdist '(1.0 3.5) "How far? "))
getdist | 91
getenv
Returns the string value assigned to a system environment variable
(getenv variable-name)
Arguments
variable-name A string specifying the name of the variable to be read.
Environment variable names must be spelled and cased
exactly as they are stored in the system registry.
Return Values
A string representing the value assigned to the specified system variable. If
the variable does not exist, getenv returns nil.
Examples
Assume the system environment variable ACAD is set to /acad/support and
there is no variable named NOSUCH.
Command: (getenv "ACAD")
"/acad/support"
Command: (getenv "NOSUCH")
nil
getfiled
Prompts the user for a file name with the standard AutoCAD file dialog box, and returns
that file name
92 | AutoLISP Reference
Arguments
title A string specifying the dialog box label.
default A default file name to use; can be a null string ( "").
ext The default file name extension. If ext is passed as a null
string (""), it defaults to * (all file types).
If the file type dwg is included in the ext argument, the
getfiled function displays an image preview in the
dialog.
flags An integer value (a bit-coded field) that controls the
behavior of the dialog box. To set more than one
condition at a time, add the values together to create a
flags value between 0 and 15. The following flags
arguments are recognized by getfiled:
1 (bit 0) Prompt for the name of a new file to create. Do
not set this bit when you prompt for the name of an
existing file to open. In the latter case, if the user enters
the name of a file that doesn’t exist, the dialog box
displays an error message at the bottom of the box.
If this bit is set and the user chooses a file that already
exists, AutoCAD displays an alert box and offers the
choice of proceeding with or canceling the operation.
4 (bit 2) Let the user enter an arbitrary file name
extension, or no extension at all.
If this bit is not set, getfiled accepts only the extension
specified in the ext argument and appends this extension
to the file name if the user doesn’t enter it in the File text
box.
8 (bit 3) If this bit is set and bit 0 is not set, getfiled
performs a library search for the file name entered. If it
finds the file and its directory in the library search path, it
strips the path and returns only the file name. (It does not
getfiled | 93
strip the path name if it finds that a file of the same name
is in a different directory.)
If this bit is not set, getfiled returns the entire file name,
including the path name.
Set this bit if you use the dialog box to open an existing
file whose name you want to save in the drawing (or other
database).
16 (bit 4) If this bit is set, or if the default argument ends
with a path delimiter, the argument is interpreted as a
path name only. The getfiled function assumes that
there is no default file name. It displays the path in the
Look in: line and leaves the File name box blank.
32 (bit 5) If this bit is set and bit 0 is set (indicating that
a new file is being specified), users will not be warned if
they are about to overwrite an existing file. The alert box
to warn users that a file of the same name already exists
will not be displayed; the old file will just be replaced.
64 (bit 6) Do not transfer the remote file if the user
specifies a URL.
128 (bit 7) Do not allow URLs at all.
Return Values
If the dialog box obtains a file name from the user, getfiled returns a string
that specifies the file name; otherwise, it returns nil.
Examples
The following call to getfiled displays the "Select a Lisp File" dialog box:
(getfiled "Select a Lisp File" "c:/program files/acad2000/support/"
"lsp" 8)
94 | AutoLISP Reference
set by the title argument
getint
Pauses for user input of an integer, and returns that integer
(getint [msg])
Values passed to getint can range from –32,768 to +32,767. If the user enters
something other than an integer, getint displays the message "Requires an
integer value," and allows the user to try again. The users cannot enter
another AutoLISP expression as the response to a getint request.
Arguments
msg A string to be displayed to prompt the user; if omitted, no
message is displayed.
Return Values
The integer specified by the user; or nil, if the user presses ENTER without
entering an integer.
Examples
Command: (setq num (getint))
15
15
getint | 95
Command: (setq num (getint "Enter a number:"))
Enter a number:25
25
Command: (setq num (getint))
15.0
Requires an integer value.
15
15
SEE ALSO the initget function in this reference and “The getxxx Func-
tions” in the Visual LISP Developer’s Guide.
getkword
Pauses for user input of a keyword, and returns that keyword
(getkword [msg])
Valid keywords are set prior to the getkword call with the initget function.
The user cannot enter another AutoLISP expression as the response to a
getkword request.
Arguments
msg A string to be displayed to prompt the user; if omitted,
getkword does not display a prompting message.
Return Values
A string representing the keyword entered by the user, or nil, if the user
presses ENTER without typing a keyword. The function also returns nil if it
was not preceded by a call to initget to establish one or more keywords.
If the user enters a value that is not a valid keyword, getkword displays a
warning message and prompts the user to try again.
Examples
The following example shows an initial call to initget that sets up a list of
keywords (Yes and No) and disallows null input (bits value equal to 1) to the
getkword call that follows:
96 | AutoLISP Reference
The following sequence illustrates what happens if the user enters invalid
input in response to getkword:
Command: (initget 1 "Yes No")
nil
Command: (setq x (getkword "Are you sure? (Yes or No) "))
Are you sure? (Yes or No) Maybe
Invalid option keyword.
Are you sure? (Yes or No) yes
"Yes"
The user’s response was not one of the keywords defined by the preceding
initget, so getkword issued an error message and then prompted the user
again with the string supplied in the msg argument.
SEE ALSO the initget function in this reference and“The getxxx Func-
tions” in the Visual LISP Developer’s Guide.
getorient
Pauses for user input of an angle, and returns that angle in radians
Use getangle when you need a rotation amount (a relative angle). Use
getorient to obtain an orientation (an absolute angle).
Arguments
pt A 2D base point in the current UCS.
The pt argument, if specified, is assumed to be the first of
two points, so that the user can show AutoLISP the angle
by pointing to one other point. You can supply a 3D base
getorient | 97
point, but the angle is always measured in the current
construction plane.
msg A string to be displayed to prompt the user.
Return Values
The angle specified by the user, in radians, with respect to the current con-
struction plane.
Examples
Command: (setq pt1 (getpoint "Pick point: "))
(4.55028 5.84722 0.0)
Command: (getorient pt1 "Pick point: ")
5.61582
SEE ALSO the getangle function in this reference and “The getxxx Func-
tions” in the Visual LISP Developer’s Guide.
getpoint
Pauses for user input of a point, and returns that point
Arguments
pt A 2D or 3D base point in the current UCS.
Note that getpoint will accept a single integer or real
number as the pt argument, and use the AutoCAD direct
distance entry mechanism to determine a point. This
mechanism uses the value of the LASTPOINT system
variable as the starting point, the pt input as the distance,
and the current cursor location as the direction from
LASTPO INT . The result is a point that is the specified number
of units away from LASTPOINT in the direction of the current
cursor location.
msg A string to be displayed to prompt the user.
98 | AutoLISP Reference
Return Values
A 3D point, expressed in terms of the current UCS.
Examples
(setq p (getpoint))
(setq p (getpoint "Where? "))
(setq p (getpoint '(1.5 2.0) "Second point: "))
SEE ALSO the getcorner and initget functions in this reference and “The
getxxx Functions” in the Visual LISP Developer’s Guide.
getreal
Pauses for user input of a real number, and returns that real number
(getreal [msg])
The user cannot enter another AutoLISP expression as the response to a
getreal request.
Arguments
msg A string to be displayed to prompt the user.
Return Values
The real number entered by the user.
Examples
(setq val (getreal))
(setq val (getreal "Scale factor: "))
getstring
Pauses for user input of a string, and returns that string
getreal | 99
Arguments
cr If supplied and not nil, this argument indicates that users
can include blanks in their input string (and must
terminate the string by pressing ENTER ). Otherwise, the
input string is terminated by space or ENTER .
msg A string to be displayed to prompt the user.
Return Values
The string entered by the user, or nil, if the user pressed ENTER without typ-
ing a string.
If the string is longer than 132 characters, getstring returns only the first
132 characters of the string. If the input string contains the backslash char-
acter (\), getstring converts it to two backslash characters (\\). This allows
you to use returned values containing file name paths in other functions.
Examples
Command: (setq s (getstring "What’s your first name? "))
What’s your first name? Gary
"Gary"
Command: (setq s (getstring T "What’s your full name? "))
What’s your full name? Gary Indiana Jones
"Gary Indiana Jones"
Command: (setq s (getstring T "Enter filename: "))
Enter filename: c:\my documents\vlisp\secrets
"c:\\my documents\\vlisp\\secrets"
SEE ALSO the initget function. See the getkword function for a routine
that requires the user to enter one of several known options (keywords).
getvar
Retrieves the value of an AutoCAD system variable
(getvar varname)
Arguments
varname A string or symbol that names a system variable. See the
Command Reference for a list of current AutoCAD system
variables.
Examples
Get the current value of the fillet radius:
Command: (getvar 'FILLETRAD)
0.25
graphscr
Displays the AutoCAD graphics screen
(graphscr)
This function is equivalent to the GRAPHSCR command or pressing the Flip
Screen function key. The textscr function is the complement of graphscr.
Returns
nil
grclear
Clears the current viewport (obsolete function)
(grclear)
Returns
nil
grdraw
Draws a vector between two points, in the current viewport
graphscr | 101
Arguments
from 2D or 3D points (lists of two or three reals) specifying one
endpoint of the vector in terms of the current UCS.
AutoCAD clips the vector to fit the screen.
to 2D or 3D points (lists of two or three reals) specifying the
other endpoint of the vector in terms of the current UCS.
AutoCAD clips the vector to fit the screen.
color An integer identifying the color used to draw the vector. A
–1 signifies XOR ink, which complements anything it
draws over and which erases itself when overdrawn.
highlight An integer, other than zero, indicating that the vector is
to be drawn using the default highlighting method of the
display device (usually dashed).
If highlight is omitted or is zero, grdraw uses the normal
display mode.
Return Values
nil
SEE ALSO the grvecs function for a routine that draws multiple vectors.
grread
Reads values from any of the AutoCAD input devices
Arguments
track If supplied and not nil, this argument enables the return
of coordinates from a pointing device as it is moved
allkeys An integer representing a code that tells grread what
functions to perform. The allkeys bit code values can be
added together for combined functionality. The following
values can be specified:
1 (bit 0) Return drag mode coordinates. If this bit is set
and the user moves the pointing device instead of
Return Values
The grread function returns a list whose first element is a code specifying the
type of input. The second element of the list is either an integer or a point,
depending on the type of input. The return values are listed in the following
table:
grread | 103
grread return values (continued)
This sequence captures the value of the code 12 list as streaming input from
the device.
grtext
Writes text to the status line or to screen menu areas
Arguments
box An integer specifying the location in which to write the
text.
text A string that specifies the text to be written to the screen
menu or status line location. The text argument is
truncated if it is too long to fit in the available area.
highlight An integer that selects or deselects a screen menu
location.
If called without arguments, grtext restores all text areas to their standard
values. If called with only one argument, grtext results in an error.
Return Values
The string passed in the text argument, if successful, and nil, if unsuccessful
or no arguments are supplied.
grtext | 105
platforms, the text must first be written without the highlight argument and
then must be highlighted. Highlighting of a screen menu location works
only when the cursor is not in that area.
If a box value of –2 is used, grtext writes the text into the coordinate status
line area. If coordinate tracking is turned on, values written into this field are
overwritten as soon as the pointer sends another set of coordinates. For both
–1 or –2 box values, the highlight argument is ignored.
grvecs
Draws multiple vectors on the graphics screen
Arguments
vlist A vector list is comprised of a series of optional color
integers and two point lists. See “Vector List Format” for
details on how to format vlist.
trans A transformation matrix used to change the location or
proportion of the vectors defined in your vector list. This
matrix is a list of four lists of four real numbers.
Return Values
nil
The color value applies to all succeeding vectors until vlist specifies another
color. AutoCAD colors are in the range 0–255. If the color value is greater
than 255, succeeding vectors are drawn in XOR ink, which complements any-
thing it draws over and which erases itself when overdrawn. If the color value
Examples
The following code draws five vertical lines on the graphics screen, each a
different color:
(grvecs '(1 (1 2)(1 5) Draws a red line from (1,2) to (1,5)
2 (2 2)(2 5) Draws a yellow line from (2,2) to (2,5)
3 (3 2)(3 5) Draws a green line from (3,2) to (3,5)
4 (4 2)(4 5) Draws a cyan line from (4,2) to (4,5)
5 (5 2)(5 5) Draws a blue line from (5,2) to (5,5)
) )
handent
Returns an object (entity) name based on its handle
(handent handle)
The handent function returns the entity name of both graphic and non-
graphic entities.
Arguments
handle A string identifying an entity handle.
handent | 107
Return Values
If successful, handent returns the entity name associated with handle in the
current editing session. If handent is passed an invalid handle or a handle not
used by any entity in the current drawing, it returns nil.
The handent function returns entities that have been deleted during the cur-
rent editing session. You can undelete them with the entdel function.
An entity’s name can change from one editing session to the next, but an
entity’s handle remains constant.
Examples
Command: (handent "5A2")
<Entity name: 60004722>
Used with the same drawing but in another editing session, the same call
might return a different entity name. Once obtained, you can use the entity
name to manipulate the entity with any of the entity-related functions.
help
Invokes the help facility
Arguments
helpfile A string that specifies a help file. If the helpfile argument
is an empty string ("") or is omitted, AutoCAD uses the
default AutoCAD Help file.
The file extension is not required with the helpfile
argument. If a file extension is provided, AutoCAD looks
only for that file. If no file extension is provided,
AutoCAD appends .hlp to the filename.
topic A keyword that specifies the topic initially displayed by
the help facility. If the topic argument is an empty string
(""), the help facility displays the introductory part of the
help file.
Return Values
The helpfile string, if successful, otherwise nil. If you use help without any
arguments, it returns an empty string ( "") if successful, and nil if it fails.
The only error condition that the help function returns to the application is
the existence of the file specified by helpfile. All other error conditions are
reported to the user through a dialog box.
Examples
The following code calls help to display the information on MYCOMMAND in the
help file achelp.hlp:
(help "achelp.hlp" "mycommand")
if
Conditionally evaluates expressions
Arguments
testexpr Expression to be tested.
thenexpr Expression evaluated if testexpr is not nil.
elseexpr Expression evaluated if testexpr is nil.
if | 109
Return Values
The if function returns the value of the selected expression. If elseexpr is
missing and testexpr is nil, then if returns nil.
Examples
Command: (if (= 1 3) "YES!!" "no.")
"no."
Command: (if (= 2 (+ 1 1)) "YES!!")
"YES!!"
Command: (if (= 2 (+ 3 4)) "YES!!")
nil
initdia
Forces the display of the next command's dialog box
(initdia [dialogflag])
Currently, the following commands make use of the initdia function:
ATTDEF, ATTEXT, BHATCH, BLOCK, COLOR, IMAGE, IMAGEADJUST, INSERT, LAYER,
LINETYPE, MTEXT, PLOT, RENAME, STYLE, TOOLBAR, and VIEW.
Arguments
dialogflag An integer. If this argument is not present or is present
and nonzero, the next use (and next use only) of a
command will display that command's dialog box rather
than its command line prompts.
If dialogflag is zero, any previous call to this function is
cleared, restoring the default behavior of presenting the
command line interface.
Return Values
nil
Examples
Issue the PLOT command without calling initdia first:
initget
Establishes keywords for use by the next user-input function call
Arguments
bits A bit-coded integer that allows or disallows certain types
of user input. The bits can be added together in any
combination to form a value between 0 and 255. If no bits
initget | 111
argument is supplied, zero (no conditions) is assumed.
The bit values are as follows:
1 (bit 0) Prevents the user from responding to the
request by entering only ENTER .
2 (bit 1) Prevents the user from responding to the
request by entering zero.
4 (bit 2) Prevents the user from responding to the
request by entering a negative value.
8 (bit 3) Allows the user to enter a point outside the
current drawing limits. This condition applies to the next
user-input function even if the AutoCAD system variable
LIMCHECK is currently set.
16 (bit 4) (Not currently used.)
32 (bit 5) Uses dashed lines when drawing a rubber-band
line or box. For those functions with which the user can
specify a point by selecting a location on the graphics
screen, this bit value causes the rubber-band line or box to
be dashed instead of solid. (Some display drivers use a
distinctive color instead of dashed lines.) If the system
variable POPUPS is 0, AutoCAD ignores this bit.
64 (bit 6) Prohibits input of a Z coordinate to the
getdist function; lets an application ensure that this
function returns a 2D distance.
128 (bit 7) Allows arbitrary input as if it is a keyword,
first honoring any other control bits and listed keywords.
This bit takes precedence over bit 0; if bits 7 and 0 are set
and the user presses ENTER , a null string is returned.
NOTE Future versions of AutoLISP may use additional initget control bits, so
avoid setting bits that are not listed here.
Return Values
nil
getint • • • • •
getreal • • • • •
getdist • • • • • • •
getangle • • • • •
getorient • • • • •
getpoint • • • • •
getcorner • • • • •
getkword • • •
entsel •
nentsel •
nentselp •
Keyword Specifications
The string argument is interpreted according to the following rules:
Each keyword is separated from the following keyword by one or more
spaces. For example, "Width Height Depth" defines three keywords.
Each keyword can contain only letters, numbers, and hyphens (-).
There are two methods for abbreviating keywords:
initget | 113
uppercase abbreviation can be anywhere in the keyword (for example,
"LType", "eXit", or "toP").
■ The entire keyword is specified in uppercase characters, and it is followed
immediately by a comma, which is followed by the required characters
(for example, "LTYPE,LT"). The keyword characters in this case must
include the first letter of the keyword, which means that "EXIT,X" is not
valid.
The two brief examples, "LType" and "LTYPE,LT", are equivalent: if the user
types LT (in either uppercase or lowercase letters), this is sufficient to identify
the keyword. The user can enter characters that follow the required portion
of the keyword, provided they don’t conflict with the specification. In the
example, the user could also enter LTY or LTYP, but L would not be sufficient.
If string shows the keyword entirely in uppercase or lowercase characters with
no comma followed by a required part, AutoCAD recognizes the keyword
only if the user enters all of it.
The initget function provides support for localized keywords. The following
syntax for the keyword string allows input of the localized keyword while it
returns the language independent keyword:
"local1 local2 localn _indep1 indep2 indepn"
where local1 through localn are the localized keywords, and indep1 through
indepn are the language-independent keywords.
There must always be the same number of localized keywords as language-
independent keywords, and the first language-independent keyword is
prefixed by an underscore as shown in the following example:
(initget "Abc Def _Ghi Jkl")
(getkword "\nEnter an option (Abc/Def): ")
inters
Finds the intersection of two lines
Arguments
pt1 One endpoint of the first line.
pt2 The other endpoint of the first line.
pt3 One endpoint of the second line.
pt4 The other endpoint of the second line.
onseg If specified as nil, the lines defined by the four pt
arguments are considered infinite in length. If the onseg
argument is omitted or is not nil, the intersection point
must lie on both lines or inters returns nil.
Return Values
If the onseg argument is present and is nil, inters returns the point where
the lines intersect, even if that point is off the end of one or both of the lines.
If the onseg argument is omitted or is not nil, the intersection point must lie
on both lines or inters returns nil. The inters function returns nil if the
two lines do not intersect.
Examples
(setq a '(1.0 1.0) b '(9.0 9.0))
(setq c '(4.0 1.0) d '(4.0 2.0))
Command: (inters a b c d)
nil
Command: (inters a b c d)
nil
Command: (inters a b c d nil)
(4.0 4.0)
itoa
Returns the conversion of an integer into a string
(itoa int)
Arguments
int An integer.
itoa | 115
Return Values
A string derived from int.
Examples
Command: (itoa 33)
"33"
Command: (itoa -17)
"-17"
lambda
Defines an anonymous function
Arguments
arguments Arguments passed to an expression.
expr An AutoLISP expression.
Return Values
The value of the last expr.
Examples
The following examples demonstrate the lambda function from the Visual
LISP Console window:
last
Returns the last element in a list
(last lst)
Arguments
lst A list.
Return Values
An atom or a list.
Examples
Command: (last '(a b c d e))
E
Command: (last '(a b c (d e)))
(D E)
layoutlist
Returns a list of all paper space layouts in the current drawing
(layoutlist)
Return Values
A list of strings.
last | 117
Examples
Command: (layoutlist)
("Layout1" "Layout2")
length
Returns an integer indicating the number of elements in a list
(length lst)
Arguments
lst A list.
Return Values
An integer.
Examples
Command: (length '(a b c d))
4
Command: (length '(a b (c d)))
3
Command: (length '())
0
list
Takes any number of expressions, and combines them into one list
(list [expr...])
This function is frequently used to define a 2D or 3D point variable (a list of
two or three reals).
Arguments
expr An AutoLISP expression.
Return Values
A list, unless no expressions are supplied, in which case list returns nil.
As an alternative to using the list function, you can explicitly quote a list
with the quote function if there are no variables or undefined items in the
list. The single quote character ( ' ) is defined as the quote function.
Command: '(3.9 6.7) means the same as (list 3.9 6.7)
This can be useful for creating association lists and defining points.
listp
Verifies that an item is a list
(listp item)
Arguments
item Any atom, list, or expression.
Return Values
T if item is a list, nil otherwise. Because nil is both an atom and a list, the listp
function returns T when passed nil.
Examples
Command: (listp '(a b c))
T
Command: (listp 'a)
nil
Command: (listp 4.343)
nil
Command: (listp nil)
T
Command: (listp (setq v1 '(1 2 43)))
T
listp | 119
SEE ALSO the vl-list* and vl-list-length functions.
load
Evaluates the AutoLISP expressions in a file
Arguments
filename A string that represents the file name. If the filename
argument does not specify a file extension, load adds an
extension to the name when searching for a file to load.
The function will try several extensions, if necessary, in
the following order:
■ .vlx
■ .fas
■ .lsp
Return Values
Unspecified, if successful. If load fails, it returns the value of onfailure; if
onfailure is not defined, failure results in an error message.
SEE ALSO the defun function in this reference, and “Symbol and Func-
tion Handling” in the Visual LISP Developer’s Guide.
load_dialog
Loads a DCL file
(load_dialog dclfile)
The load_dialog function searches for files according to the AutoCAD
library search path.
This function is the complement of unload_dialog. An application can load
multiple DCL files with multiple load_dialog calls.
Arguments
dclfile A string that specifies the DCL file to load. If the dclfile
argument does not specify a file extension, .dcl is
assumed.
load_dialog | 121
Return Values
A positive integer value ( dcl_id) if successful, or a negative integer if
load_dialog can’t open the file. The dcl_id is used as a handle in subsequent
new_dialog and unload_dialog calls.
log
Returns the natural log of a number as a real number
(log num)
Arguments
num A positive number.
Return Values
A real number.
Examples
Command: (log 4.5)
1.50408
Command: (log 1.22)
0.198851
logand
Returns the result of the logical bitwise AND of a list of integers
Arguments
int An integer.
Return Values
An integer (0, if no arguments are supplied).
Examples
Command: (logand 7 15 3)
3
Command: (logand 2 3 15)
2
logior
Returns the result of the logical bitwise inclusive OR of a list of integers
Arguments
int An integer.
Return Values
An integer (0, if no arguments are supplied).
Examples
Command: (logior 1 2 4)
7
Command: (logior 9 3)
11
lsh
Returns the logical bitwise shift of an integer by a specified number of bits
Arguments
int An integer.
numbits Number of bits to shift int.
If numbits is positive, int is shifted to the left; if numbits is
negative, int is shifted to the right. In either case, zero bits
are shifted in, and the bits shifted out are discarded.
If numbits is not specified, no shift occurs.
Return Values
The value of int after the bitwise shift. The returned value is positive if the
significant bit (bit number 31) contains a 0 after the shift operation, other-
wise it is negative. If no arguments are supplied, lsh returns 0.
logior | 123
The behavior is different from other languages (>> & << of C, C++, or Java)
where more than 32 left shifts (of a 32 bit integer) results 0. In right shift also
the integer appears again on every 32 shifts.
Examples
Command: (lsh 2 1)
4
Command: (lsh 2 -1)
1
Command: (lsh 40 2)
160
mapcar
Returns a list of the result of executing a function with the individual elements of a list
or lists are supplied as arguments to the function
Arguments
function A function.
list1... listn One or more lists. The number of lists must match the
number of arguments required by function.
Return Values
A list.
Examples
Command: (setq a 10 b 20 c 30)
30
Command: (mapcar '1+ (list a b c))
(11 21 31)
max
Returns the largest of the numbers given
Arguments
number A number.
Return Values
A number. If any of the arguments are real numbers, a real is returned, oth-
erwise an integer is returned. If no argument is supplied, max returns 0.
Examples
Command: (max 4.07 -144)
4.07
Command: (max -88 19 5 2)
19
Command: (max 2.1 4 8)
8.0
mem
Displays the current state of the AutoLISP memory
(mem)
The mem function displays statistics on AutoLISP memory usage. The first line
of this statistics report contains the following information:
GC calls Number of garbage collection calls since AutoLISP started.
GC run time Total time spent collecting garbage (in milliseconds).
max | 125
LISP objects are allocated in dynamic (heap) memory that is organized in seg-
ments and divided into pages. Memory is described under the heading,
"Dynamic memory segments statistics:"
PgSz Dynamic memory page size (in KB).
Used Number of pages used.
Free Number of free (empty) pages.
FMCL Largest contiguous area of free pages.
Segs Number of segments allocated.
Type Internal description of the types of objects allocated in
this segment. These include:
lisp stacks—LISP internal stacks
bytecode area—compiled code function modules
CONS memory—CONS objects
::new—untyped memory requests served using this
segment
DM Str—dynamic string bodies
DMxx memory—all other LISP nodes
bstack body—internal structure used for IO operations
The final line in the report lists the minimal segment size and the number of
allocated segments. AutoLISP keeps a list of no more than three free seg-
ments, in order to save system calls for memory requests.
All heap memory is global; that is, all AutoCAD documents share the same
heap. This could change in future releases of AutoCAD.
Note that mem does not list all memory requested from the operating system,
only those requests served by the AutoLISP Dynamic Memory (DM) sub-
system; some AutoLISP classes do not use DM for memory allocation.
Return Values
nil
member
Searches a list for an occurrence of an expression and returns the remainder of the list,
starting with the first occurrence of the expression
Arguments
expr The expression to be searched for.
lst The list in which to search for expr.
Return Values
A list, or nil, if there is no occurrence of expr in lst.
Examples
Command: (member 'c '(a b c d e))
(C D E)
Command: (member 'q '(a b c d e))
nil
menucmd
Issues menu commands, or sets and retrieves menu item status
(menucmd string)
The menucmd function can switch between subpages in an AutoCAD menu.
This function can also force the display of menus. This allows AutoLISP pro-
member | 127
grams to use image tile menus and to display other menus from which the
user can make selections. AutoLISP programs can also enable, disable, and
place marks in menu items.
Arguments
string A string that specifies a menu area and the value to assign
to that menu area. The string argument has the following
parameters.
"menu_area=value"
Return Values
nil
Examples
The following code displays the image tile menu MOREICONS.
(menucmd "I=moreicons") Loads the MOREICONS image tile menu
(menucmd "I=*") Displays the menu
The following code checks the status of the third menu item in the pull-
down menu POP11. If the menu item is currently enabled, the menucmd
function disables it.
(setq s (menucmd "P11.3=?")) Gets the status of the menu item
(if (= s "") If the status is an empty string,
(menucmd "P11.3=~") disable the menu item
)
menugroup
Verifies that a menugroup is loaded
(menugroup groupname)
Arguments
groupname A string that specifies the menugroup name.
Return Values
If groupname matches a loaded menugroup the function returns the group-
name string; otherwise, it returns nil.
min
Returns the smallest of the numbers given
Arguments
number A number.
menugroup | 129
Return Values
A number. If any number argument is a real, a real is returned, otherwise an
integer is returned. If no argument is supplied, min returns 0.
Examples
Command: (min 683 -10.0)
-10.0
Command: (min 73 2 48 5)
2
Command: (min 73.0 2 48 5)
2.0
Command: (min 2 4 6.7)
2.0
minusp
Verifies that a number is negative
(minusp num)
Arguments
num A number.
Return Values
T if number is negative, nil otherwise.
Examples
Command: (minusp -1)
T
Command: (minusp -4.293)
T
Command: (minusp 830.2)
nil
mode_tile
Sets the mode of a dialog box tile
Return Values
nil
namedobjdict
Returns the entity name of the current drawing’s named object dictionary, which is the
root of all nongraphical objects in the drawing
(namedobjdict)
Using the name returned by this function and the dictionary access func-
tions, an application can access the nongraphical objects in the drawing.
nentsel
Prompts the user to select an object (entity) by specifying a point, and provides access
to the definition data contained within a complex object
(nentsel [msg])
The nentsel function prompts the user to select an object. The current
Object Snap mode is ignored unless the user specifically requests it. To pro-
vide additional support at the Command prompt, nentsel honors keywords
defined by a previous call to initget.
Arguments
msg A string to be displayed as a prompt. If omitted, the Select
object prompt is issued.
namedobjdict | 131
Return Values
When the selected object is not complex (i.e., not a 3D polyline or block),
nentsel returns the same information as entsel. However, if the selected
object is a 3D polyline, nentsel returns a list containing the name of the sub-
entity (vertex) and the pick point. This is similar to the list returned by ent-
sel, except that the name of the selected vertex is returned instead of the
polyline header. The nentsel function always returns the starting vertex of
the selected 3D polyline segment. Picking the third segment of the polyline,
for example, returns the third vertex. The Seqend subentity is never returned
by nentsel for a 3D polyline.
NOTE nentsel is the only AutoLISP function that uses a matrix of this type; the
nentselp function returns a matrix similar to those used by other AutoLISP and
ObjectARX functions.
The fourth element is a list containing the entity name of the block that con-
tains the selected object. If the selected object is in a nested block (a block
within a block), the list additionally contains the entity names of all blocks
in which the selected object is nested, starting with the innermost block and
continuing outward until the name of the block that was inserted in the
drawing is reported.
Examples
Draw a 3Dpolyline with multiple line segments, then load and run the fol-
lowing function and select different segments of the line. Pick off of the line
and then pick the same segments again to see the subentity handle. Try it
with a lightweight polyline to see the difference.
(defun c:subent ()
(while
(setq Ent (entsel "\nPick an entity: "))
(print (strcat "Entity handle is: "
(cdr (assoc 5 (entget (car Ent))))))
)
(while
(setq Ent (nentsel "\nPick an entity or subEntity: "))
(print (strcat "Entity or subEntity handle is: "
(cdr (assoc 5 (entget (car Ent))))))
)
(prompt "\nDone.")
(princ)
)
SEE ALSO the entsel, initget,and nentselp functions in this reference and
“Entity Name Functions” in the Visual LISP Developer’s Guide.
nentselp
Provides similar functionality to that of the nentsel function without the need for user
input
Arguments
msg A string to be displayed as a prompt. If omitted, the Select
object prompt is issued.
pt A selection point. This allows object selection without
user input.
Return Values
The nentselp function returns a 4 × 4 transformation matrix, defined as fol-
lows:
nentselp | 133
M00 M 01 M02 M03
M10 M 11 M12 M13
M20 M 21 M22 M23
M30 M 31 M32 M33
The first three columns of the matrix specify scaling and rotation. The fourth
column is a translation vector.
The functions that use a matrix of this type treat a point as a column vector
of dimension 4. The point is expressed in homogeneous coordinates, where the
fourth element of the point vector is a scale factor that is normally set to 1.0.
The final row of the matrix, the vector [M30 M31 M32 M33], has the nominal
value of [0 0 0 1]; it is currently ignored by the functions that use this matrix
format. In this convention, applying a transformation to a point is a matrix
multiplication that appears as follows:
As these equations show, the scale factor and the last row of the matrix have
no effect and are ignored.
Arguments
dlgname A string that specifies the dialog box.
dcl_id The DCL file identifier obtained by load_dialog.
action A string that contains an AutoLISP expression to use as the
default action. If you don’t want to define a default
action, specify an empty string ( ""). The action argument
is required if you specify screen-pt.
The default action is evaluated when the user picks an
active tile that doesn’t have an action or callback
explicitly assigned to it by action_tile or in DCL.
screen-pt A 2D point list that specifies the X,Y location of the dialog
box on the screen. The point specifies the upper-left
corner of the dialog box. If you pass the point as'(-1 -1),
the dialog box is opened in the default position (the
center of the AutoCAD graphics screen).
Return Values
T, if successful, otherwise nil.
SEE ALSO the “Managing Dialog Boxes” chapter of the Visual LISP Devel-
oper’s Guide.
not
Verifies that an item evaluates to nil
(not item)
Typically, the null function is used for lists, and not is used for other data
types along with some types of control functions.
Arguments
item An AutoLISP expression.
new_dialog | 135
Return Values
T if item evaluates to nil, nil otherwise.
Examples
Command: (setq a 123 b "string" c nil)
nil
Command: (not a)
nil
Command: (not b)
nil
Command: (not c)
T
Command: (not '())
T
nth
Returns the nth element of a list
(nth n lst)
Arguments
n The number of the element to return from the list (zero is
the first element).
lst The list.
Return Values
The nth element of lst. If n is greater than the highest element number of lst,
nth returns nil.
Examples
Command: (nth 3 '(a b c d e))
D
Command: (nth 0 '(a b c d e))
A
Command: (nth 5 '(a b c d e))
nil
(null item)
Arguments
item An AutoLISP expression.
Return Values
T if item evaluates to nil, nil otherwise.
Examples
Command: (setq a 123 b "string" c nil)
nil
Command: (null a)
nil
Command: (null b)
nil
Command: (null c)
T
Command: (null '())
T
numberp
Verifies that an item is a real number or an integer
(numberp item)
Arguments
item An AutoLISP expression.
Return Values
T if item evaluates to a real or an integer, nil otherwise.
null | 137
Examples
Command: (setq a 123 b 'a)
A
Command: (numberp 4)
T
Command: (numberp 3.8348)
T
Command: (numberp "Howdy")
nil
Command: (numberp a)
T
Command: (numberp b)
nil
Command: (numberp (eval b))
T
open
Opens a file for access by the AutoLISP I/O functions
Arguments
filename A string that specifies the name and extension of the file
to be opened. If you do not specify the full path name of
the file, open assumes you are referring to the AutoCAD
start-up directory.
mode Indicates whether the file is open for reading, writing, or
appending. Specify a string containing one of the
following letters:
r Open for reading.
w Open for writing. If filename does not exist, a new file
is created and opened. If filename already exists, its
existing data is overwritten. Data passed to an open file is
not actually written until the file is closed with the close
function.
a Open for appending. If filename does not exist, a new
file is created and opened. If filename already exists, it is
opened and the pointer is positioned at the end of the
Return Values
If successful, open returns a file descriptor that can be used by the other I/O
functions. If mode "r" is specified and filename does not exist, open returns
nil.
NOTE On DOS systems, some programs and text editors write text files with
an end-of-file marker ( CTRL + Z , decimal ASCII code 26) at the end of the text.
When reading a text file, DOS returns an end-of-file status if a CTRL + Z marker is
encountered, even if that marker is followed by more data. If you intend to use
OPEN’s "a" mode to append data to files produced by another program, be cer-
tain the other program does not insert CTRL + Z markers at the end of its text files.
Examples
Open an existing file:
Command: (setq a
(open "c:/program files/acad2000/help/filelist.txt" "r"))
#<file "c:/program files/acad2000/help/filelist.txt">
The following examples issue open against files that do not exist:
Command: (setq f (open "c:\\my documents\\new.tst" "w"))
#<file "c:\\my documents\\new.tst">
Command: (setq f (open "nosuch.fil" "r"))
nil
Command: (setq f (open "logfile" "a"))
#<file "logfile">
or
Returns the logical OR of a list of expressions
(or [expr...])
The or function evaluates the expressions from left to right, looking for a
non-nil expression.
or | 139
Arguments
expr The expressions to be evaluated.
Return Values
T, if a non-nil expression is found, or nil, if all of the expressions are nil or
no arguments are supplied.
Note that or accepts an atom as an argument and returns T if one is supplied.
Examples
Command: (or nil 45 '())
T
Command: (or nil '())
nil
osnap
Returns a 3D point that is the result of applying an Object Snap mode to a specified point
(osnap pt mode)
Arguments
pt A point.
mode A string that consists of one or more valid Object Snap
identifiers such as mid, cen, and so on, separated by
commas.
Return Values
A point, or nil, if the pick did not return an object (for example, there is no
geometry under the pick aperture, or the geometry is not applicable to the
selected object snap mode). The point returned by osnap depends on the cur-
rent 3D view, the AutoCAD entity around pt, and the setting of the APERTURE
system variable.
Examples
Command: (setq pt1 (getpoint))
(11.8637 3.28269 0.0)
Command: (setq pt2 (osnap pt1 "_end,_int"))
(12.1424 3.42181 0.0)
Arguments
pt A 2D or 3D point.
ang An angle expressed in radians relative to the X axis, with
respect to the current construction plane. Angles increase
in the counterclockwise direction.
dist Distance from the specified pt.
Return Values
A 2D or 3D point, depending on the type of point specified by pt.
Examples
Supplying a 3D point to polar:
Command: (polar '(1 1 3.5) 0.785398 1.414214)
(2.0 2.0 3.5)
prin1
Prints an expression to the command line or writes an expression to an open file
Arguments
expr A string or AutoLISP expression. Only the specified expr is
printed; no newline or space is included.
file-desc A file descriptor for a file opened for writing.
Return Values
The value of the evaluated expr. If called with no arguments, prin1 returns a
null symbol.
polar | 141
Used as the last expression in a function, prin1 without arguments results in
a blank line printing when the function completes, allowing the function to
exit “quietly.”
Examples
Command: (setq a 123 b '(a))
(A)
Command: (prin1 'a)
AA
Control codes
Code Description
\\ \ character
\e Escape character
\n Newline character
\r Return character
\t TAB character
princ
Prints an expression to the command line, or writes an expression to an open file
Arguments
expr A string or AutoLISP expression. Only the specified expr is
printed; no newline or space is included.
file-desc A file descriptor for a file opened for writing.
Return Values
The value of the evaluated expr. If called with no arguments, princ returns a
null symbol.
print
Prints an expression to the command line, or writes an expression to an open file
Arguments
expr A string or AutoLISP expression. Only the specified expr is
printed; no newline or space is included.
princ | 143
file-desc A file descriptor for a file opened for writing.
Return Values
The value of the evaluated expr. If called with no arguments, print returns a
null symbol.
progn
Evaluates each expression sequentially and returns the value of the last expression
(progn [expr]...)
You can use progn to evaluate several expressions where only one expression
is expected.
Arguments
expr One or more AutoLISP expressions.
Return Values
The result of the last evaluated expression.
Examples
The if function normally evaluates one then expression if the test expression
evaluates to anything but nil. The following example uses progn to evaluate
two expressions following if:
(if (= a b)
(progn
(princ "\nA = B ")
(setq a (+ a 10) b (- b 10))
)
)
prompt
Displays a string on your screen’s prompt area
(prompt msg)
On dual-screen AutoCAD configurations, prompt displays msg on both
screens and is, therefore, preferable to princ.
Return Values
nil
Examples
Command: (prompt "New value: ")
New value: nil
quit
Forces the current application to quit
(quit)
If quit is called, it returns the error message quit/exit abort and returns to the
AutoCAD Command prompt.
quote
Returns an expression without evaluating it
(quote expr)
Arguments
expr An AutoLISP expression.
Return Values
The expr argument.
Examples
Command: (quote a)
A
quit | 145
Command: !'a
A
Command: (quote (a b))
(A B)
read
Returns the first list or atom obtained from a string
(read [string])
The read function parses the string representation of any LISP data and
returns the first expression in the string, converting it to a corresponding
data type.
Arguments
string A string. The string argument should not contain blanks,
except within a list or string.
Return Values
A list or atom. The read function returns its argument converted into the cor-
responding data type. If no argument is specified, read returns nil.
If the string contains multiple LISP expressions separated by LISP symbol
delimiters such as blanks, new-line, tabs, or parentheses, only the first
expression is returned.
Examples
Command: (read "hello")
HELLO
Command: (read "hello there")
HELLO
Command: (read "\"Hi Y’all\"")
"Hi Y’all"
Command: (read "(a b c)")
(A B C)
Command: (read "(a b c) (d)")
(A B C)
Command: (read "1.2300")
1.23
read-char
Returns the decimal ASCII code representing the character read from the keyboard input
buffer or from an open file
(read-char [file-desc])
Arguments
file-desc A file descriptor (obtained from open) referring to an open
file. If no file-desc is specified, read-char obtains input
from the keyboard input buffer.
Return Values
An integer representing the ASCII code for a character. The read-char func-
tion returns a single newline character (ASCII code 10) whenever it detects
an end-of-line character or character sequence.
Examples
The following example omits file-desc, so read-char looks for data in the key-
board buffer:
Command: (read-char)
The user entered ABC; read-char returned the ASCII code representing the
first character entered (A). The next three calls to read-char return the data
remaining in the keyboard input buffer. This data translates to 66 (the ASCII
code for the letter B), 67 (C), and 10 (newline), respectively:
Command: (read-char)
66
Command: (read-char)
67
Command: (read-char)
10
read-char | 147
With the keyboard input buffer now empty, read-char waits for user input
the next time it is called:
Command: (read-char)
read-line
Reads a string from the keyboard or from an open file, until an end-of-line marker is
encountered
(read-line [file-desc])
Arguments
file-desc A file descriptor (obtained from open) referring to an open
file. If no file-desc is specified, read-line obtains input
from the keyboard input buffer.
Return Values
The string read by read-line, without the end-of-line marker. If read-line
encounters the end of the file, it returns nil.
Examples
Open a file for reading:
Command: (setq f (open "c:\\my documents\\new.tst" "r"))
#<file "c:\\my documents\\new.tst">
redraw
Redraws the current viewport or a specified object (entity) in the current viewport
Arguments
ename The name of the entity name to be redrawn.
mode An integer value that controls the visibility and
highlighting of the entity. The mode can be one of the
following values:
1 Show entity
2 Hide entity (blank it out)
3 Highlight entity
4 Unhighlight entity
The use of entity highlighting (mode 3) must be balanced
with entity unhighlighting (mode 4).
If ename is the header of a complex entity (a polyline or a block reference
with attributes), redraw processes the main entity and all its subentities if the
mode argument is positive. If the mode argument is negative, redraw operates
on only the header entity.
Return Values
The redraw function always returns nil.
regapp
Registers an application name with the current AutoCAD drawing in preparation for
using extended object data
(regapp application)
Arguments
application A string naming the application. The name must be a
valid symbol table name. See the description of snvalid for
regapp | 149
the rules AutoLISP uses to determine if a symbol name is
valid.
Return Values
If an application of the same name has already been registered, this function
returns nil; otherwise it returns the name of the application.
If registered successfully, the application name is entered into the APPID
symbol table. This table maintains a list of the applications that are using
extended data in the drawing.
Examples
(regapp "ADESK_4153322344")
(regapp "DESIGNER-v2.1-124753")
NOTE It is recommended that you pick a unique application name. One way
of ensuring this is to adopt a naming scheme that uses the company or product
name and a unique number (like your telephone number or the current
date/time). The product version number can be included in the application name
or stored by the application in a separate integer or real-number field; for
example, (1040 2.1).
rem
Divides the first number by the second, and returns the remainder
Arguments
number Any number.
If you provide more than two numbers, rem divides the
result of dividing the first number by the second with the
third, and so on.
If you provide more than two numbers, rem evaluates the
arguments from left to right. For example, if you supply
three numbers, rem divides the first number by the
second, then takes the result and divides it by the third
number, returning the remainder of that operation.
Examples
Command: (rem 42 12)
6
Command: (rem 12.0 16)
12.0
Command: (rem 26 7 2)
1
repeat
Evaluates each expression a specified number of times, and returns the value of the last
expression
Arguments
int An integer. Must be a positive number.
expr One or more atoms or expressions.
Return Values
The value of the last expression or atom evaluated. If expr is not supplied,
repeat returns nil.
Examples
Command: (setq a 10 b 100)
100
Command: (repeat 4 (setq a (+ a 10)) (setq b (+ b 100)))
500
repeat | 151
reverse
Returns a copy of a list with its elements reversed
(reverse lst)
Arguments
lst A list.
Return Values
A list.
Examples
Command: (reverse '((a) b c))
(C B (A))
rtos
Converts a number into a string
Arguments
number A number.
mode An integer specifying the linear units mode. The mode
corresponds to the values allowed for the AutoCAD
system variable LUN ITS and can be one of the following
numbers:
1 Scientific
2 Decimal
3 Engineering (feet and decimal inches)
4 Architectural (feet and fractional inches)
5 Fractional
Return Values
A string. The UNITMODE system variable affects the returned string when
engineering, architectural, or fractional units are selected (mode values 3, 4,
or 5).
Examples
Set variable x:
Command: (setq x 17.5)
17.5
rtos | 153
Command: (setq fmtval (rtos x 5 2))
"17-1/2"
set
Sets the value of a quoted symbol name to an expression
Arguments
sym A symbol.
expr An AutoLISP expression.
Return Values
The value of the expression.
Examples
Each of the following commands sets symbol a to 5.0:
(set 'a 5.0)
(set (read "a") 5.0)
(setq a 5.0)
Both set and setq expect a symbol as their first argument, but set accepts
an expression that returns a symbol, whereas setq does not, as the following
shows:
Command: (set (read "a") 5.0)
5.0
Command: (setq (read "a") 5.0)
; *** ERROR: syntax error
Arguments
key A string that specifies the tile.
value A string that names the new value to assign (initially set
by the value attribute).
Return Values
The value the tile was set to.
setcfg
Writes application data to the AppData section of the acad.cfg file
Arguments
cfgname A string that specifies the section and parameter to set
with the value of cfgval. The cfgname argument must be a
string of the following form:
"AppData/application_name/section_name/.../param_name"
The string can be up to 496 characters long.
cfgval A string. The string can be up to 512 characters in length.
Larger strings are accepted by setcfg, but cannot be
returned by getcfg.
Return Values
If successful, setcfg returns cfgval. If cfgname is not valid, setcfg returns nil.
Examples
The following code sets the WallThk parameter in the AppData/ArchStuff
section to 8, and returns the string "8":
Command: (setcfg "AppData/ArchStuff/WallThk" "8")
"8"
set_tile | 155
SEE ALSO the getcfg function.
setenv
Sets a system environment variable to a specified value
Arguments
varname A string specifying the name of the environment variable
to be set. Environment variable names must be spelled
and cased exactly as they are stored in the system registry.
value A string specifying the value to set varname to.
Return Values
value
Examples
The following command sets the value of the MaxArray environment variable
to 10000:
Command: (setenv "MaxArray" "10000")
"10000"
Note that changes to settings might not take effect until the next time
AutoCAD is started.
setfunhelp
Registers a user-defined command with the Help facility so the appropriate help file and
topic are called when the user requests help on that command
Arguments
c:fname A string specifying the user-defined command (the C:XXX
function). You must include the c: prefix.
Return Values
The string passed as c:fname, if successful, otherwise, nil.
This function verifies only that the c:fname argument has the c: prefix. It
does not verify that the c:fname function exists, nor does it verify the correct-
ness of the other arguments supplied.
Examples
The following example illustrates the use of setfunhelp by defining a simple
function and issuing setfunhelp to associate the function with the circle
topic in the AutoCAD help file (acad.hlp):
(defun c:foo ()
(getstring "Press F1 for help on the foo command:")
)
(setfunhelp "c:foo" "acad.hlp" "circle")
After loading this code, issuing the foo command and then pressing F1 dis-
plays the circle topic.
This example works, but serves no real purpose. In the real world, you would
create your own help file and associate that help file and topic with your
function.
Define a function named test:
Command: (defun c:test()(getstring "\nTEST: " )(princ))
C:TEST
setfunhelp | 157
Run the test command and at the prompt, press F1; you should see the Help
Index with "line" entered as the first few letters of the word you’re looking
for.
NOTE When you use the defun function to define a C:XXX function, it removes
that function’s name from those registered by setfunhelp (if one exists). There-
fore, setfunhelp should only be called after the defun call, which defines the
user-defined command.
setq
Sets the value of a symbol or symbols to associated expressions
Arguments
sym A symbol. This argument is not evaluated.
expr An expression.
Return Values
The result of the last expr evaluated.
Examples
The following function call set variable a to 5.0:
Command: (setq a 5.0)
5.0
Whenever a is evaluated, it returns the real number 5.0.
The following command sets two variables, b and c:
Command: (setq b 123 c 4.7)
4.7
setq returns the value of the last variable set.
setvar
Sets an AutoCAD system variable to a specified value
Arguments
varname A string or symbol naming a variable.
value An atom or expression whose evaluated result is to be
assigned to varname. For system variables with integer
values, the supplied value must be between –32,768 and
+32,767.
Return Values
If successful, setvar returns value.
Examples
Set the AutoCAD fillet radius to 0.5 units:
Command: (setvar "FILLETRAD" 0.50)
0.5
setvar | 159
fers from the SETVAR command, which interprets this argument as degrees
relative to the ANGBASE setting.
NOTE The UNDO command does not undo changes made to the CVPORT sys-
tem variable by the setvar function.
You can find a list of the current AutoCAD system variables in the Command
Reference.
setview
Establishes a view for a specified viewport
Arguments
view_descriptor An entity definition list similar to that returned by
tblsearch when applied to the VIEW symbol table.
Return Values
If successful, the setview function returns the view_descriptor.
sin
Returns the sine of an angle as a real number expressed in radians
(sin ang)
Arguments
ang An angle, in radians.
Examples
Command: (sin 1.0)
0.841471
Command: (sin 0.0)
0.0
slide_image
Displays an AutoCAD slide in the currently active dialog box image tile
Arguments
x1 X-offset from the upper-left corner of the tile, in pixels.
Must be a positive value.
y1 Y-offset from the upper-left corner of the tile, in pixels.
Must be a positive value.
width Width of the image, in pixels.
height Height of the image, in pixels.
sldname Identifies the slide. This argument can be a slide file (.sld)
or a slide in a slide library file (.slb). Specify sldname the
same way you would specify it for the VSLIDE command or
for a menu file (see the “Creating Images” topic in the
Visual LISP Developer’s Guide). Use one of the following
formats for sldname:
sldname or libname(sldname)
The first (upper-left) corner of the slide —its insertion point— is located at
(x1,y1), and the second (lower-right) corner is located at the relative distance
(wid,hgt) from the first (wid and hgt must be positive values). The origin (0,0)
is the upper-left corner of the image. You obtain the coordinates of the lower-
right corner by calling the dimension functions (dimx_tile and dimy_tile).
Return Values
A string containing sldname.
slide_image | 161
Examples
(slide_image
0
0
(dimx_tile "slide_tile")
(dimy_tile "slide_tile")
"myslide"
)
(end_image)
snvalid
Checks the symbol table name for valid characters
AutoLISP does not enforce restrictions on the length of symbol table names
if EXTNAMES is 1.
Arguments
sym_name A string that specifies a symbol table name.
flag An integer that specifies whether the vertical bar character
is allowed within sym_name. The flag argument can be one
of the following:
0 Do not allow vertical bar characters anywhere in
sym_name. This is the default.
1 Allow vertical bar characters in sym_name, as long as
they are not the first or last characters in the name.
Return Values
T, if sym_name is a valid symbol table name, otherwise nil.
: colon
? question mark
* asterisk
| vertical bar
, comma
= equal sign
` backquote
Examples
The following examples assume EXTNAMES is set to 1:
Command: (snvalid "hocus-pocus")
T
Command: (snvalid "hocus pocus")
T
Command: (snvalid "hocus%pocus")
T
snvalid | 163
Command: (snvalid "hocus pocus")
nil
Command: (snvalid "hocus%pocus")
nil
The following example includes a vertical bar in the symbol table name:
Command: (snvalid "hocus|pocus")
nil
By default, the vertical bar character is considered invalid in all symbol table
names.
In the following example, the flag argument is set to 1, so snvalid considers
the vertical bar character to be valid in sym_name, as long as it is not the first
or last character in the name:
Command: (snvalid "hocus|pocus" 1)
T
sqrt
Returns the square root of a number as a real number
(sqrt num)
Arguments
num A number (integer or real).
Return Values
A real number.
Examples
Command: (sqrt 4)
2.0
Command: (sqrt 2.0)
1.41421
ssadd
Adds an object (entity) to a selection set, or creates a new selection set
Return Values
The new or modified selection set.
Examples
When adding an entity to a set, the new entity is added to the existing set,
and the set passed as ss is returned as the result. Thus, if the set is assigned to
other variables, they also reflect the addition. If the named entity is already
in the set, the ssadd operation is ignored and no error is reported.
Set e1 to the name of the first entity in drawing:
Command: (setq e1 (entnext))
<Entity name: 1d62d60>
The following command adds the e1 entity to the selection set referenced by
ss:
ssadd | 165
ssdel
Deletes an object (entity) from a selection set
Arguments
ename An entity name.
ss A selection set.
Return Values
The name of the selection set, or nil, if the specified entity is not in the set.
Note that the entity is actually deleted from the existing selection set, as
opposed to a new set being returned with the element deleted.
Examples
In the following examples, entity name e1 is a member of selection set ss,
while entity name e3 is not a member of ss:
Command: (ssdel e1 ss)
<Selection set: 2>
The function returns nil because e3 is not a member of selection set ss.
ssget
Creates a selection set from the selected object
ssget | 167
name in the selection set (each will have different
subentity information for ssnamex to report).
:S Allow single selection only.
pt1 A point relative to the selection.
pt2 A point relative to the selection.
pt-list A list of points.
filter-list An association list that specifies object properties. Objects
that match the filter-list are added to the selection set.
If you omit all arguments, ssget prompts the user with the Select objects
prompt, allowing interactive construction of a selection set.
If you supply a point but do not specify an object selection method,
AutoCAD assumes the user is selecting an object by picking a single point.
Return Values
The name of the created selection set, if successful, or nil, if no objects were
selected.
Examples
Prompt the user to select the objects to be placed in a selection set:
Command: (ssget)
<Selection set: 2>
Create a selection set of the objects crossing the box from (0,0) to (1,1):
Command: (ssget "_C" '(0 0) '(1 1))
<Selection set: b>
Create a selection set of the objects inside the window from (0,0):
Command: (ssget "_W" '(0 0) '(5 5))
<Selection set: d>
By specifying filters, you can obtain a selection set that includes all objects of
a given type, on a given layer, or of a given color. The following example
returns a selection set that consists only of blue lines that are part of the
implied selection set (those objects selected while PICKFIRST is in effect):
Command: (ssget "_I" '((0 . "LINE") (62 . 5)))
<Selection set: 4>
The following examples of ssget require that a list of points be passed to the
function. The pt_list variable cannot contain points that define zero-length
segments.
Create a selection set of all objects crossing and inside the polygon defined
by pt_list:
Command: (ssget "_CP" pt_list)
<Selection set: 13>
Create a selection set of all blue lines inside the polygon defined by pt_list:
Command: (ssget "_WP" pt_list '((0 . "LINE") (62 . 5)))
<Selection set: 8>
The selected objects are highlighted only when ssget is used with no argu-
ments. Selection sets consume AutoCAD temporary file slots, so AutoLISP is
not permitted to have more than 128 open at one time. If this limit is
reached, AutoCAD refuses to create any more selection sets and returns nil
to all ssget calls. To close an unnecessary selection set variable, set it to nil.
ssget | 169
A selection set variable can be passed to AutoCAD in response to any Select
objects prompt at which selection by Last is valid. It selects all the objects in
the selection set variable.
The current setting of Object Snap mode is ignored by ssget unless you spe-
cifically request it while you are in the function.
SEE ALSO “Selection Set Handling” and “Selection Set Filter Lists” in the
Visual LISP Developer’s Guide.
ssgetfirst
Determines which objects are selected and gripped
(ssgetfirst)
Returns a list of two selection sets similar to those passed to sssetfirst. The
first element in the list is a selection set of entities that are gripped but not
selected. The second element is a selection set of entities that are both
gripped and selected. Either (or both) elements of the list can be nil.
NOTE Only entities from the current drawing’s model space and paper space,
not nongraphical objects or entities in other block definitions, can be analyzed by
this function.
sslength
Returns an integer containing the number of objects (entities) in a selection set
(sslength ss)
Arguments
ss A selection set.
Return Values
An integer.
Use sslength to determine the number of objects in the new selection set:
Command: (sslength sset)
1
ssmemb
Tests whether an object (entity) is a member of a selection set
Arguments
ename An entity name.
ss A selection set.
Return Values
If ename is a member of ss, ssmemb returns the entity name. If ename is not a
member, ssmemb returns nil.
Examples
In the following examples, entity name e2 is a member of selection set ss,
while entity name e1 is not a member of ss:
Command: (ssmemb e2 ss)
<Entity name: 1d62d68>
Command: (ssmemb e1 ss)
nil
ssname
Returns the object (entity) name of the indexed element of a selection set
(ssname ss index)
Entity names in selection sets obtained with ssget are always names of main
entities. Subentities (attributes and polyline vertices) are not returned. (The
entnext function allows access to them.)
ssmemb | 171
Arguments
ss A selection set.
Return Values
An entity name, if successful. If index is negative or greater than the highest
numbered entity in the selection set, ssname returns nil.
Examples
Get the name of the first entity in a selection set:
Command: (setq ent1 (ssname ss 0))
<Entity name: 1d62d68>
To access entities beyond the 32767th one in a selection set, you must supply
the index argument as a real, as in the following example:
(setq entx (ssname sset 50843.0))
ssnamex
Retrieves information about how a selection set was created
(ssnamex ss [index])
Only selection sets with entities from the current drawing’s model space and
paper space— not nongraphical objects or entities in other block definitions—
can be retrieved by this function.
Arguments
ss A selection set.
The data returned by ssnamex takes the form of a list of lists that contains
information that either describes an entity and its selection method or a
polygon that was used to select one or more entities. Each sublist that
describes the selection of a particular entity comprises three parts: the selec-
tion method ID (an integer >= 0), the entity name of the selected entity, and
selection method specific data that describes how the entity was selected.
((sel_id1 ename1 (data))(sel_id2 ename2 (data)) ... )
ID Description
1 Pick
2 Window or WPolygon
3 Crossing or CPolygon
4 Fence
Each sublist that describes a polygon and is used during entity selection takes
the form of a polygon ID (an integer < 0), followed by point descriptions.
(polygon_id point_description_1 point_description_n... )
ssnamex | 173
The following table lists the valid point descriptor IDs:
ID Description
0 Infinite line
1 Ray
2 Line segment
Examples
The data associated with Pick (type 1) entity selections is a single point
description. For example, the following record is returned for the selection of
an entity picked at 1,1 in plan view of the WCS:
Command: (ssnamex ss3 0)
((1 <Entity name: 1d62da0> 0 (0 (1.0 1.0 0.0))))
The data associated with an entity selected with the Window, WPolygon,
Crossing, or CPolygon method is the integer ID of the polygon that selected
the entity. It is up to the application to associate the polygon identifiers and
make the connection between the polygon and the entities it selected. For
example, the following returns an entity selected by Crossing (note that the
polygon ID is –1):
Command: (ssnamex ss4 0)
((3 <Entity name: 1d62d60> 0 -1) (-1 (0 (-1.80879 8.85536 0.0)) (0
(13.4004 8.85536 0.0)) (0 (13.4004 1.80024 0.0)) (0 (-1.80879
1.80024 0.0))))
The data associated with Fence selections is a list of points and descriptions
for the points where the fence and entity visually intersect. For example, the
following command returns information for a nearly vertical line intersected
three times by a Z-shaped fence:
Command: (ssnamex ss5 0)
((4 <Entity name: 1d62d88> 0 (0 (5.28135 6.25219 0.0) ) (0 (5.61868
2.81961 0.0) ) (0 (5.52688 3.75381 0.0) ) ) )
You are responsible for creating a valid selection set. For example, you may
need to verify that a background paper space viewport (DXF group code 69)
is not included in the selection set. You may also need to ensure that selected
objects belong to the current layout, as in the following code:
(setq ss (ssget (list (cons 301 (getvar "ctab")))))
Arguments
gripset A selection set to be gripped. If gripset is nil and pickset is
specified, sssetfirst grips and selects pickset. If gripset is
nil and no pickset is specified, sssetfirst turns off the
grip handles and selections it previously turned on.
Return Values
The selection set or sets specified.
Examples
First, draw a square and build three selection sets. Begin by drawing side 1
and creating a selection set to include the line drawn:
Command: (entmake (list (cons 0 "line") '(10 0.0 0.0 0.0)
'(11 0.0 10.0 0.0)))
((0 . "line") (10 0.0 0.0 0.0) (11 0.0 10.0 0.0))
Command: (setq gripset (ssget "_l"))
<Selection set: a5>
sssetfirst | 175
'(11 10.0 10.0 0.0)))
((0 . "line") (10 0.0 10.0 0.0) (11 10.0 10.0 0.0))
Command: (ssadd (entlast) gripset)
<Selection set: a5>
Draw side 4 and add it to the gripset and pickset selection sets:
Command: (entmake (list (cons 0 "line") '(10 10.0 0.0 0.0)
'(11 0.0 0.0 0.0)))
((0 . "line") (10 10.0 0.0 0.0) (11 0.0 0.0 0.0))
Command: (ssadd (entlast) gripset)
<Selection set: a5>
Command: (ssadd (entlast) pickset)
<Selection set: ab>
At this point, gripset contains sides 1-4, pickset contains sides 3 and 4, and
2onlyset contains only side 2.
Turn grip handles on for all objects in the gripset selection set:
Command: (sssetfirst gripset)
(<Selection set: a5>)
Turn on grip handles for all objects in 2onlyset, and select all objects in
pickset:
startapp
Starts a Windows application
Arguments
appcmd A string that specifies the application to execute. If
appcmd does not include a full path name, startapp
searches the directories in the PATH environment variable
for the application.
Return Values
An integer greater than 0, if successful, otherwise nil.
Examples
The following code starts the Windows Notepad and opens the acad.lsp file.
startapp | 177
start_dialog
Displays a dialog box and begins accepting user input
(start_dialog)
You must first initialize the dialog box by a previous new_dialog call. The
dialog box remains active until an action expression or callback function
calls done_dialog. Usually done_dialog is associated with the tile whose key
is "accept" (typically the OK button) and the tile whose key is "cancel"
(typically the Cancel button).
Return Values
The start_dialog function returns the optional status passed to
done_dialog. The default value is 1 if the user presses OK, 0 if the user presses
Cancel , or -1 if all dialog boxes are terminated with term_dialog. If
done_dialog is passed an integer status greater than 1, start_dialog returns
this value, whose meaning is determined by the application.
start_image
Starts the creation of an image in the dialog box tile
(start_image key)
Subsequent calls to fill_image, slide_image, and vector_image affect the
created image until the application calls end_image.
Arguments
key A string that specifies the dialog box tile. The key
argument is case-sensitive.
Return Values
The key argument, if successful, nil otherwise.
Arguments
key A string that specifies the dialog box tile. The key
argument is case-sensitive.
Return Values
The name of the list that was started.
NOTE Do not use the set_tile function between start_list and end_list
function calls.
strcase
Returns a string where all alphabetic characters have been converted to uppercase or
lowercase
start_list | 179
Arguments
string A string.
Return Values
A string.
Examples
Command: (strcase "Sample")
"SAMPLE"
Command: (strcase "Sample" T)
"sample"
The strcase function will correctly handle case mapping of the currently
configured character set.
strcat
Returns a string that is the concatenation of multiple strings
Arguments
string A string.
Return Values
A string. If no arguments are supplied, strcat returns a zero-length string.
Examples
Command: (strcat "a" "bout")
"about"
Command: (strcat "a" "b" "c")
"abc"
Command: (strcat "a" "" "c")
"ac"
Command: (strcat)
""
(strlen [string]...)
Arguments
string A string.
Return Values
An integer. If multiple string arguments are provided, strlen returns the sum
of the lengths of all arguments. If you omit the arguments or enter an empty
string, strlen returns 0.
Examples
Command (strlen "abcd")
4
Command (strlen "ab")
2
Command (strlen "one" "two" "four")
10
Command (strlen)
0
Command (strlen "")
0
subst
Searches a list for an old item and returns a copy of the list with a new item substituted
in place of every occurrence of the old item
Arguments
newitem An atom or list.
lst A list.
strlen | 181
Return Values
A list, with newitem replacing all occurrences of olditem . If olditem is not
found in lst, subst returns lst unchanged.
Examples
Command: (setq sample '(a b (c d) b))
(A B (C D) B)
Command: (subst 'qq 'b sample)
(A QQ (C D) QQ)
Command: (subst 'qq 'z sample)
(A B (C D) B)
Command: (subst 'qq '(c d) sample)
(A B QQ B)
Command: (subst '(qq rr) '(c d) sample)
(A B (QQ RR) B)
Command: (subst '(qq rr) 'z sample)
(A B (C D) B)
The following sets old to (FIRST JOHN) and new to (FIRST J):
Command: (setq old (assoc 'first who) new '(first j))
(FIRST J)
Finally, replace the value of the first item in the association list:
Command: (subst new old who)
((FIRST J) (MID Q) (LAST PUBLIC))
substr
Returns a substring of a string
NOTE The first character of string is character number 1. This differs from other
functions that process elements of a list (like nth and ssname) that count the first
element as 0.
Return Values
A string.
Examples
Command: (substr "abcde" 2)
"bcde"
Command: (substr "abcde" 2 1)
"b"
Command: (substr "abcde" 3 2)
"cd"
tablet
Retrieves and sets digitizer (tablet) calibrations
Arguments
code An integer that can be one of the following:
tablet | 183
row1, row2, Three 3D points. These three arguments specify the three
row3 rows of the tablet’s transformation matrix.
Return Values
If tablet fails, it returns nil and sets the ERRNO system variable to a value
that indicates the reason for the failure (see appendix C, “AutoLISP Error
Codes” in the Visual LISP Developer’s Guide). This can happen if the digitizer
is not a tablet.
Examples
A very simple transformation that can be established with tablet is the iden-
tity transformation:
(tablet 1 '(1 0 0) '(0 1 0) '(0 0 1) '(0 0 1))
The TABMODE system variable allows AutoLISP routines to toggle the tablet
on and off.
tblnext
Finds the next item in a symbol table
Arguments
table-name A string that identifies a symbol table. Valid table-name
values are "LAYER", "LTYPE", "VIEW", "STYLE", "BLOCK",
"UCS", "APPID", "DIMSTYLE", and " VPORT". The argument is
not case sensitive.
rewind If this argument is present and is not nil, the symbol table
is rewound and the first entry in it is retrieved.
Return Values
If a symbol table entry is found, the entry is returned as a list of dotted pairs
of DXF-type codes and values. If there are no more entries in the table, nil
is returned. Deleted table entries are never returned.
Examples
Retrieve the first layer in the symbol table:
Command: (tblnext "layer" T)
((0 . "LAYER") (2 . "0") (70 . 0) (62 . 7) (6 . "CONTINUOUS"))
Entries retrieved from the block table include a –2 group with the entity
name of the first entity in the block definition (if any). For example, the fol-
lowing command obtains information about a block called BOX:
Command: (tblnext "block")
((0 . "BLOCK") (2 . "BOX") (70 . 0) (10 9.0 2.0 0.0) (-2 . <Entity
name: 1dca370>))
tblnext | 185
(0 . "BLOCK") Symbol type
(2 . "BOX") Symbol name
(70 . 0) Flags
(10 9.0 2.0 0.0) Origin X,Y,Z
(-2 . <Entity name: 1dca370>) First entity
The entity name in the –2 group is accepted by entget and entnext, but not
by other entity access functions. For example, you cannot use ssadd to put it
in a selection set. By providing the –2 group entity name to entnext, you can
scan the entities comprising a block definition; entnext returns nil after the
last entity in the block definition.
NOTE The vports function returns current VPORT table information, therefore
it may be easier to use vports as opposed to tblnext to retrieve this information.
tblobjname
Returns the entity name of a specified symbol table entry
Arguments
table-name A string that identifies the symbol table to be searched.
The argument is not case sensitive.
Return Values
The entity name of the symbol table entry, if found.
The entity name returned by tblobjname can be used in entget and entmod
operations.
Examples
The following command searches for the entity name of the block entry
"ESC-01":
Arguments
table-name A string that identifies the symbol table to be searched.
This argument is not case sensitive.
Return Values
If tblsearch finds an entry for the given symbol name, it returns that entry
in the format described for tblnext. If no entry is found, tblsearch returns
nil.
Examples
The following command searches for a text style named "standard":
Command: (tblsearch "style" "standard")
((0 . "STYLE") (2 . "STANDARD") (70 . 0) (40 . 0.0) (41 . 1.0)
(50 . 0.0) (71 . 0) (42 . 0.3) (3 . "txt") (4 . ""))
term_dialog
Terminates all current dialog boxes as if the user had canceled each of them
(term_dialog)
If an application is terminated while any DCL files are open, AutoCAD auto-
matically calls term_dialog. This function is used mainly for aborting nested
dialog boxes.
Return Values
The term_dialog function always returns nil.
tblsearch | 187
terpri
Prints a newline to the command line
(terpri)
The terpri function is not used for file I/O. To write a newline to a file, use
prin1, princ, or print.
Return Values
nil
textbox
Measures a specified text object, and returns the diagonal coordinates of a box that
encloses the text
(textbox elist)
Arguments
elist An entity definition list defining a text object, in the
format returned by entget.
Return Values
A list of two points, if successful, otherwise nil.
The points returned by textbox describe the bounding box of the text object
as if its insertion point is located at (0,0,0) and its rotation angle is 0. The first
list returned is generally the point (0.0 0.0 0.0) unless the text object is
oblique or vertical, or it contains letters with descenders (such as g and p ).
The value of the first point list specifies the offset from the text insertion
point to the lower-left corner of the smallest rectangle enclosing the text. The
second point list specifies the upper-right corner of that box. Regardless of
the orientation of the text being measured, the point list returned always
describes the bottom-left and upper-right corners of this bounding box.
textpage
Switches from the graphics screen to the text screen
(textpage)
The textpage function is equivalent to textscr.
Return Values
nil
textscr
Switches from the graphics screen to the text screen (like the AutoCAD Flip Screen func-
tion key)
(textscr)
Return Values
The textscr function always returns nil.
trace
Aids in AutoLISP debugging
(trace [function...])
The trace function sets the trace flag for the specified functions. Each time
a specified function is evaluated, a trace display appears showing the entry of
the function (indented to the level of calling depth) and prints the result of
the function.
textpage | 189
If Visual LISP is active, trace output is sent to the Visual LISP Trace window.
If Visual LISP is not active, trace output goes to the AutoCAD command win-
dow.
NOTE Once you start Visual LISP during an AutoCAD session, it remains active
until you exit AutoCAD. Therefore, all trace output prints in the Visual LISP Trace
window for the remainder of that AutoCAD session. Exiting or closing Visual LISP
while AutoCAD is running only closes the IDE windows and places Visual LISP in
a quiescent state; it does not result in a true shutdown. You must reopen Visual
LISP to view the output in the Trace window.
Arguments
function A symbol that names a function. If no argument is
supplied, trace has no effect.
Return Values
The last function name passed to trace. If no argument is supplied, trace
returns nil.
Examples
Define a function named foo and set the trace flag for the function:
Command: (foo 3)
Entering (FOO 3)
Entering (FOO 2)
Entering (FOO 1)
Entering (FOO 0)
Result: nil
Result: nil
Result: nil
Result: nil
Clear the trace flag by invoking untrace:
Arguments
pt A list of three reals that can be interpreted as either a 3D
point or a 3D displacement (vector).
0 World (WCS)
1 User (current UCS)
2 If used with code 0 or 1, this indicates the Display
Coordinate System (DCS) of the current viewport. When
used with code 3, it indicates the DCS of the current
model space viewport.
If you use an entity name for the from or to arguments, it must be passed in
the format returned by the entnext, entlast, entsel, nentsel, and ssname
functions. This format lets you translate a point to and from the Object Coor-
dinate System (OCS) of a particular object. (For some objects, the OCS is
equivalent to the WCS; for these objects, conversion between OCS and WCS
is a null operation.) A 3D extrusion vector (a list of three reals) is another
method of converting to and from an object’s OCS. However, this does not
work for those objects whose OCS is equivalent to the WCS.
Return Values
A 3D point (or displacement) in the requested to coordinate system.
trans | 191
Examples
In the following examples, the UCS is rotated 90 degrees counterclockwise
around the World Z axis:
Command: (trans '(1.0 2.0 3.0) 0 1)
(2.0 -1.0 3.0)
Command: (trans '(1.0 2.0 3.0) 1 0)
(-2.0 1.0 3.0)
The coordinate systems are discussed in greater detail in the Visual LISP Devel-
oper’s Guide, under the topic, “Coordinate System Transformations.”
For example, to draw a line from the insertion point of a piece of text (with-
out using Osnap), you convert the text object’s insertion point from the text
object’s OCS to the UCS.
(trans text-insert-point text-ename 1)
You can then pass the result to the From point prompt.
Conversely, you must convert point (or displacement) values to their desti-
nation OCS before feeding them to entmod. For example, if you want to move
a circle (without using the MOVE command) by the UCS-relative offset
(1,2,3), you need to convert the displacement from the UCS to the circle’s
OCS:
(trans '(1 2 3) 1 circle-ename)
Then you add the resulting displacement to the circle’s center point.
For example, if you have a point entered by the user and want to find out
which end of a line it looks closer to, you convert the user’s point from the
UCS to the DCS.
(trans user-point 1 2)
Then you convert each of the line’s endpoints from the OCS to the DCS.
(trans endpoint line-ename 2)
From there you can compute the distance between the user’s point and each
endpoint of the line (ignoring the Z coordinates) to determine which end
looks closer.
The trans function can also transform 2D points. It does this by setting the
Z coordinate to an appropriate value. The Z component used depends on the
from coordinate system that was specified and on whether the value is to be
converted as a point or as a displacement. If the value is to be converted as a
WCS 0.0
OCS 0.0
type
Returns the type of a specified item
(type item)
Arguments
item A symbol.
Return Values
The data type of item . Items that evaluate to nil (such as unassigned sym-
bols) return nil. The data type is returned as one of the atoms listed in the
following table:
INT Integers
type | 193
Data types returned by the type function
LIST Lists
SAFEARRAY Safearray
STR Strings
SYM Symbols
VARIANT Variant
Examples
For example, given the following assignments:
(setq a 123 r 3.45 s "Hello!" x '(a b c))
(setq f (open "name" "r"))
then
(type 'a) returns SYM
(type a) returns INT
(type f) returns FILE
(type r) returns REAL
(type s) returns STR
(type x) returns LIST
(type +) returns SUBR
(type nil) returns nil
The following code example uses the type function on the argument passed
to it:
unload_dialog
Unloads a DCL file
(unload_dialog dcl_id)
Unloads the DCL file associated with dcl_id (obtained from a previous
new_dialog call) from memory.
Arguments
dcl_id A DCL file identifier obtained from a previous
load_dialog call.
Return Values
The unload_dialog function always returns nil.
untrace
Clears the trace flag for the specified functions
(untrace [function...])
Arguments
function A symbol that names a function. If function is not
specified, untrace has no effect.
Return Values
The last function name passed to untrace. If function was not specified,
untrace returns nil.
unload_dialog | 195
Examples
The following command clears the trace flag for function foo:
Command: (untrace foo)
FOO
vector_image
Draws a vector in the currently active dialog box image
(vector_image x1 y1 x2 y2 color)
This function draws a vector in the currently active dialog box image (opened
by start_image) from the point (x1,y1) to (x2,y2). The origin (0,0) is the
upper-left corner of the image. You can obtain the coordinates of the lower-
right corner by calling the dimension functions (dimx_tile and dimy_tile).
Arguments
x1 X coordinate of the first point.
y1 Y coordinate of the first point.
x2 X coordinate of the second point.
y2 Y coordinate of the second point.
color An AutoCAD color number, or one of the logical color
numbers shown in the following table:
Examples
(setq color -2) ;; color of AutoCAD background screen
(vector_image
0
0
(dimx_tile "slide_tile")
(dimy_tile "slide_tile")
color
)
(end_image)
ver
Returns a string that contains the current AutoLISP version number
(ver)
The ver function can be used to check the compatibility of programs.
Return Values
The string returned takes the following form:
"Visual LISP version (nn)"
(de) German
(en) US/UK
(es) Spanish
(fr) French
(it) Italian
Examples
Command: (ver)
"Visual LISP 2000 (en)"
ver | 197
vl-acad-defun
Defines an AutoLISP function symbol as an external subroutine
(vl-acad-defun ’symbol)
symbol A symbol identifying a function.
If a function does not have the c: prefix, and you want to be able to invoke
this function from an external ObjectARX application, you can use vl-acad-
defun to make the function accessible.
Return Values
Unspecified.
vl-acad-undefun
Undefines an AutoLISP function symbol so it is no longer available to
ObjectARX applications
(vl-acad-undefun ’symbol)
symbol A symbol identifying a function.
Return Values
T, if successful, nil, if unsuccessful (for example, the function was not
defined in AutoLISP).
vl-arx-import
Imports ObjectARX/ADSRX functions into a separate-namespace VLX
Return Values
Unspecified.
If executed from a document VLX, this function does nothing and returns
nil, as all ADS-DEFUN function names are automatically imported to docu-
ment VLX applications.
Examples
To see how vl-arx-import works, try the following:
1 Copy the following code into the VLISP editor and save the file:
(vl-doc-export 'testarx)
(defun testarx ()
(princ "This function tests invoking an ARX app ")
(vl-arx-import 'c:cal)
(c:cal)
)
2 Use Make Application to build a VLX with this code. Select Separate-
Namespace Application Options.
3 Load geomcal.arx, if it is not already loaded.
4 Load and run the application.
In the example above, you could have replaced the vl-arx-import call with
the following:
(vl-arx-import "geomcal.arx")
vl-arx-import | 199
vl-bb-ref
Returns the value of a variable from the blackboard namespace
(vl-bb-ref ’variable)
Arguments
’variable A symbol identifying the variable to be retrieved.
Return Values
The value of the the variable named by symbol.
Examples
Set a variable in the blackboard:
Command: (vl-bb-set 'foobar "Root toot toot")
"Root toot toot"
SEE ALSO the vl-bb-set function. Also, see “Sharing Data between
Namespaces” in the Visual LISP Developer’s Guide for a description of the
blackboard namespace.
vl-bb-set
Sets a variable in the blackboard namespace
Arguments
’symbol A symbol naming the variable to be set.
Return Values
The value you assigned to symbol.
SEE ALSO the vl-bb-ref function. Also, see “Sharing Data between
Namespaces” in the Visual LISP Developer’s Guide for a description of the
blackboard namespace.
vl-catch-all-apply
Passes a list of arguments to a specified function and traps any exceptions
Arguments
’function A function. The function argument can be either a symbol
identifying a defun, or a lambda expression.
Return Values
The result of the function call, if successful. If an error occurs,
vl-catch-all-apply returns an error object.
Examples
If the function invoked by vl-catch-all-apply completes successfully, it is
the same as using apply, as the following examples show:
_$ (setq catchit (apply '/ '(50 5)))
10
_$ (setq catchit (vl-catch-all-apply '/ '(50 5)))
10
When you use apply, an exception occurs and an error message displays.
vl-catch-all-apply | 201
_$ (setq catchit (vl-catch-all-apply '/ '(50 0)))
#<%catch-all-apply-error%>
The vl-catch-all-apply function traps the error and returns an error object.
Use vl-catch-all-error-message to see the error message contained in the
error object:
_$ (vl-catch-all-error-message catchit)
"divide by zero"
vl-catch-all-error-message
Returns a string from an error object
(vl-catch-all-error-message error-obj)
Arguments
error-obj An error object returned by vl-catch-all-apply.
Return Values
A string containing an error message.
Examples
Divide by zero using vl-catch-all-apply:
_$ (setq catchit (vl-catch-all-apply '/ '(50 0)))
#<%catch-all-apply-error%>
The vl-catch-all-apply function traps the error and returns an error object.
Use vl-catch-all-error-message to see the error message contained in the
error object:
_$ (vl-catch-all-error-message catchit)
"divide by zero"
(vl-catch-all-error-p arg)
Arguments
arg Any argument.
Return Values
T, if the supplied argument is an error object returned from
vl-catch-all-apply, nil otherwise.
Examples
Divide by zero using vl-catch-all-apply:
_$ (setq catchit (vl-catch-all-apply '/ '(50 0)))
#<%catch-all-apply-error%>
_$ (vl-catch-all-error-p catchit)
T
vl-cmdf
Executes an AutoCAD command
Arguments
vl-catch-all-error-p | 203
If your command call includes a call to another function, vl-cmdf executes
the call before it executes your command, while command executes the call
after it begins executing your command.
Some AutoCAD commands may work correctly when invoked through
vl-cmdf, while failing when invoked through command. The vl-cmdf function
mainly overcomes the limitation of not being able to use getxxx functions
inside command.
Arguments
arguments AutoCAD commands and their options.
Return Values
T
Note that if you issue vl-cmdf from Visual LISP, focus does not change to the
AutoCAD window. If the command requires user input, you’ll see the return
value ( T) in the Console window, but AutoCAD will be waiting for input. You
must manually activate the AutoCAD window and respond to the prompts.
Until you do so, any subsequent commands will fail.
Examples
The differences between command and vl-cmdf are easier to see if you enter
the following calls at the AutoCAD Command prompt, rather than the VLISP
Console prompt:
Command: (command "line" (getpoint "point?") '(0 0) "")
line Specify first point: point?
Specify next point or [Undo]:
Command: nil
Using command, the LINE command executes first, then the getpoint func-
tion is called.
Command: (VL-CMDF "line" (getpoint "point?") '(0 0) "")
point?line Specify first point:
Specify next point or [Undo]:
Command: T
Using vl-cmdf, the getpoint function is called first (notice the "point?"
prompt from getpoint), then the LINE command executes.
vl-consp
Determines whether or not a list is nil
(vl-consp list-variable)
The vl-consp function determines whether a variable contains a valid list
definition.
Arguments
list-variable A list.
Return Values
T, if list-variable is a list and is not nil,otherwise nil.
Examples
_$ (vl-consp nil)
nil
_$ (vl-consp t)
nil
_$ (vl-consp (cons 0 "LINE"))
T
vl-consp | 205
vl-directory-files
Lists all files in a given directory
Arguments
directory A string naming the directory to collect files for; if nil or
absent, vl-directory-files uses the current directory.
pattern A string containing a DOS pattern for the file name; if nil
or absent, vl-directory-files assumes "*.*"
Return Values
A list of file and path names, or nil, if no files match the specified pattern.
Examples
_$ (vl-directory-files "c:/acadwin" "acad*.exe")
("ACAD.EXE" "ACADAPP.EXE" "ACADL.EXE" "ACADPS.EXE")
_$ (vl-directory-files "e:/acadwin" nil -1)
("." ".." "SUPPORT" "SAMPLE" "ADS" "FONTS" "IGESFONT" "SOURCE"
"ASE")
_$ (vl-directory-files "E:/acad13c4" nil -1)
("." ".." "WIN" "COM" "DOS")
vl-doc-export
Makes a function available to the current document
(vl-doc-export ’function)
When issued from a VLX that runs in its own namespace, vl-doc-export
exposes the specified function to any document namespace that loads the
VLX.
Arguments
’function A symbol naming the function to be exported.
Return Values
Unspecified.
Examples
The following code shows the contents of a file named kertrats.lsp. This file is
compiled into a VLX that runs in its own namespace. The VLX file is named
kertrats.vlx . The vl-doc-export call makes the kertrats function visible to
any document that loads kertrats.vlx :
(vl-doc-export 'kertrats)
(defun kertrats ()
(princ "This function goes nowhere")
)
vl-doc-import
Imports a previously exported function into a VLX namespace
Arguments
application A string naming the VLX application whose functions are
to be imported. Do not include the .vlx extension in the
name.
Return Values
Unspecified.
vl-doc-import | 207
Examples
Import function ldataget from the ldatatest application:
(vl-doc-import "ldatatest" 'ldataget)
nil
vl-doc-ref
Retrieves the value of a variable from the current document’s namespace.
(vl-doc-ref ’symbol)
Arguments
’symbol A symbol naming a variable.
Return Values
The value of the variable identified by symbol.
Examples
Command: (vl-doc-ref 'foobar)
"Rinky dinky stinky"
vl-doc-set
Sets the value of a variable in the current document’s namespace.
Arguments
’symbol A symbol naming a variable.
Examples
Command: (vl-doc-set 'foobar "Rinky dinky stinky")
"Rinky dinky stinky"
vl-every
Checks whether the predicate is true for every element combination
Arguments
predicate- The test function. This can be any function that accepts as
function many arguments as there are lists provided with vl-every,
and returns T on any user-specified condition. The
predicate-function value can take one of the following
forms:
Return Values
T, if predicate-function returns a non-nil value for every element combination,
nil otherwise.
Examples
Check whether there are any empty files in the current directory:
_$ (vl-every
'(lambda (fnm) (> (vl-file-size fnm) 0))
(vl-directory-files nil nil 1) )
T
vl-every | 209
Check whether the list of numbers in NLST is ordered by '<=:
_$ (setq nlst (list 0 2 pi pi 4))
(0 2 3.14159 3.14159 4)
_$ (vl-every '<= nlst (cdr nlst))
T
The first expression returned nil because vl-every compared the second ele-
ment in each list and they were not numerically equal. The second expres-
sion returned T because vl-every stopped comparing elements after it had
processed all the elements in the shorter list (1 2), at which point the lists
were numerically equal. If the end of a list is reached, vl-every returns a non-
nil value.
The following example demonstrates the result when vl-every evaluates one
list that contains integer elements and another list that is nil:
_$ (setq alist (list 1 2 3 4))
(1 2 3 4)
_$ (setq junk nil)
nil
$ (vl-every '= junk alist)
T
The return value is T because vl-every responds to the nil list as if it has
reached the end of the list (even though the predicate hasn't yet been applied
to any elements). And since the end of a list has been reached, vl-every
returns a non-nil value.
vl-exit-with-error
Passes control from a VLX error handler to the *error* function of the calling namespace
(vl-exit-with-error msg)
This function is used by VLX applications that run in their own namespace.
When vl-exit-with-error executes, it calls the *error* function, the stack
is unwound, and control returns to a command prompt.
Arguments
msg A string.
Examples
The following code illustrates the use of vl-exit-with-error to pass a string
to the *error* function of the calling namespace:
(defun *error* (msg)
... ; processing in VLX namespace/execution context
(vl-exit-with-error (strcat "My application bombed! " msg)))
vl-exit-with-value
Returns a value to the function that invoked the VLX from another namespace
(vl-exit-with-value value)
A VLX *error* handler can use the vl-exit-with-value function to return
a value to the program that called the VLX.
Arguments
value Any value.
Return Values
value
Examples
The following example uses vl-exit-with-value to return the integer value
3 to the function that invoked the VLX:
(defun *error* (msg)
... ; processing in VLX-T namespace/execution context
(vl-exit-with-value 3))
vl-exit-with-value | 211
vl-file-copy
Copies or appends the contents of one file to another file
Arguments
source-file A string naming the file to be copied. If you do not specify
a full path name, vl-file-copy looks in the AutoCAD
start-up directory.
Return Values
An integer, if the copy was successful, otherwise nil.
Examples
Copy autoexec.bat to newauto.bat:
_$ (vl-file-copy "c:/autoexec.bat" "c:/newauto.bat")
1417
The copy fails because newauto.bat already exists, and the append argument
was not specified.
The copy is successful because T was specified for the append argument.
vl-file-delete
Deletes a file
(vl-file-delete filename)
Arguments
filename A string containing the name of the file to be deleted. If
you do not specify a full path name, vl-file-delete
searches the AutoCAD start-up directory.
Return Values
T, if successful, nil if delete failed.
Examples
Delete newauto.bat:
_$ (vl-file-delete "newauto.bat")
nil
The delete was successful because the full path name identified an existing
file.
vl-file-directory-p
Determines if a file name refers to a directory
(vl-file-directory-p filename)
vl-file-delete | 213
Arguments
filename A string containing a file name. If you do not specify a full
path name, vl-file-directory-p searches only the
AutoCAD start-up directory.
Return Values
T, if filename is the name of a directory, nil if it is not.
Examples
_$ (vl-file-directory-p "sample")
T
_$ (vl-file-directory-p "yinyang")
nil
_$ (vl-file-directory-p "c:/program files/acad2000")
T
_$ (vl-file-directory-p
"c:/program files/acad2000/vlisp/yinyang.lsp")
nil
vl-file-rename
Renames a file
Arguments
old-filename A string containing the name of the file you want to
rename. If you do not specify a full path name,
vl-file-rename looks in the AutoCAD start-up directory.
Return Values
T, if renaming completed successfully, nil if renaming failed.
vl-file-size
Determines the size of a file, in bytes
(vl-file-size filename)
Arguments
filename A string naming the file to be sized. If you do not specify
a full path name, vl-file-size searches the AutoCAD
start-up directory for the file.
Return Values
If successful, vl-file-size returns an integer showing the size of filename.
If the file is not readable, vl-file-size returns nil. If filename is a directory
or an empty file, vl-file-size returns 0.
Examples
_$ (vl-file-size "c:/autoexec.bat")
1417
_$ (vl-file-size "c:/")
0
vl-file-systime
Returns last modification time of the specified file
(vl-file-systime filename)
Arguments
filename A string containing the name of the file to be checked.
Return Values
A list containing the modification date and time, or nil, if the file is not
found.
vl-file-size | 215
The list returned contains the following elements:
■ year
■ month
■ day-of-week
■ day-of-month
■ hours
■ minutes
■ seconds
Examples
_$ (vl-file-systime
"c:/program files/acad2000/sample/visuallisp/yinyang.lsp")
(1998 4 3 8 10 6 52 0)
The returned value shows that the file was last modified in 1998, in the 4th
month of the year (April), the 3rd day of the week (Wednesday), on the 10th
day of the month, at 6:52:0.
vl-filename-base
Returns the name of a file, after stripping out the directory path and extension
(vl-filename-base filename)
Arguments
filename A string containing a file name. The vl-filename-base
function does not check to see if the file exists.
Return Values
A string containing filename in uppercase, with any directory and extension
stripped from the name.
Examples
_$ (vl-filename-base "c:\\acadwin\\acad.exe")
"ACAD"
_$ (vl-filename-base "c:\\acadwin")
"ACADWIN"
(vl-filename-directory filename)
Arguments
filename A string containing a complete file name, including the
path. The vl-filename-directory function does not
check to see if the specified file exists. Slashes (/) and
backslashes (\) are accepted as directory delimiters.
Return Values
A string containing the directory portion of filename, in uppercase.
Examples
_$ (vl-filename-directory "c:\\acadwin\\acad.exe")
"C:\\ACADWIN"
_$ (vl-filename-directory "acad.exe")
""
vl-filename-extension
Returns the extension from a file name, after stripping out the rest of the name
(vl-filename-extension filename)
Arguments
filename A string containing a file name, including the extension.
The vl-filename-extension function does not check to
see if the specified file exists.
Return Values
A string containing the extension of filename. The returned string starts with
a period (.) and is in uppercase. If filename does not contain an extension,
vl-filename-extension returns nil.
Examples
_$ (vl-filename-extension "c:\\acadwin\\acad.exe")
".EXE"
vl-filename-directory | 217
_$ (vl-filename-extension "c:\\acadwin\\acad")
nil
vl-filename-mktemp
Calculates a unique file name to be used for a temporary file
Arguments
pattern A string containing a file name pattern; if nil or absent,
vl-filename-mktemp uses "$VL~~".
Return Values
A string containing a file name, in the following format:
directory\base<XXX><.extension>
where:
Examples
_$ (vl-filename-mktemp)
"C:\\TMP\\$VL~~004"
vl-get-resource
Returns the text stored in a .txt file packaged in a VLX
(vl-get-resource text-file)
Arguments
text-file A string naming a .txt file packaged with the VLX. Do not
include the .txt extension when specifying the file name.
Return Values
A string containing the text in text-file.
Examples
Assume the getres.vlx file contains a LISP program defining a function named
print-readme, and a text file named readme.txt. The print-readme function
is defined as follows:
(defun print-readme ()
(princ (vl-get-resource "readme"))
(princ)
)
vl-get-resource | 219
vl-list*
Constructs and returns a list
Arguments
object Any LISP object.
Return Values
The vl-list* function is similar to list, but it will place the last object in the
final cdr of the result list. If the last argument to vl-list* is an atom, the
result is a dotted list. If the last argument is a list, its elements are appended
to all previous arguments added to the constructed list. The possible return
values from vl-list* are:
Examples
_$ (vl-list* 1)
1
_$ (vl-list* 0 "text")
(0 . "TEXT")
_$ (vl-list* 1 2 3)
(1 2 . 3)
_$ (vl-list* 1 2 '(3 4))
(1 2 3 4)
vl-list->string
Combines the characters associated with a list of integers into a string
(vl-list->string char-codes-list)
Return Values
A string of characters, with each character based on one of the integers sup-
plied in char-codes-list.
Examples
_$ (vl-list->string nil)
""
_$ (vl-list->string '(49 50))
"12"
vl-list-exported-functions
Lists exported functions
(vl-list-exported-functions [appname])
Arguments
appname A string naming a loaded VLX application. Do not include
the .vlx extension.
Return Values
A list of strings naming exported functions, or nil, if there are no functions
exported from the specified VLX. If appname is omitted or is nil,
vl-list-exported-functions returns a list of all exported functions (for
example, c: functions) except those exported from VLX namespaces.
Examples
_$ (vl-list-exported-functions "whichexpns")
("WHICHNAMESPACE")
vl-list-exported-functions | 221
vl-list-length
Calculates list length of a true list
(vl-list-length list-or-cons-object)
Arguments
list-or-cons- A true or dotted list.
object
Return Values
An integer containing the list length, if the argument is a true list, or nil, if
list-or-cons-object is a dotted list.
Compatibility note: The vl-list-length function returns nil for a dotted
list, while the corresponding Common Lisp function issues an error message
if the argument is a dotted list.
Examples
_$ (vl-list-length nil)
0
_$ (vl-list-length '(1 2))
2
_$ (vl-list-length '(1 2 . 3))
nil
vl-list-loaded-vlx
Returns a list of all separate-namespace VLX files associated with the current document.
(vl-list-loaded-vlx)
Return Values
A list of symbols identifying separate-namespace VLX applications associated
with the current AutoCAD document, or nil if there are no VLX applications
associated with the current document.
Load two VLX files; both VLX applications have been compiled to run in
their own namespace:
_$ (load "c:/my documents/visual lisp/examples/foo1.vlx")
nil
_$ (load "c:/my documents/visual lisp/examples/foo2.vlx")
nil
Test for loaded VLX files associated with the current AutoCAD document:
_$ (vl-list-loaded-vlx)
(FOO1 FOO2)
vl-load-all
Loads a file into all open AutoCAD documents, and into any document subsequently
opened during the current AutoCAD session.
(vl-load-all filename)
Arguments
filename A string naming the file to be loaded. If the file is in the
AutoCAD Support File Search Path, you can omit the path
name, but you must always specify the file extension;
vl-load-all does not assume a file type.
vl-load-all | 223
Return Values
Unspecified. If filename is not found, vl-load-all issues an error message.
Examples
$ (vl-load-all "c:/my documents/visual lisp/examples/whichns.lsp")
nil
_$ (vl-load-all "yinyang.lsp")
nil
vl-load-com
Loads Visual LISP extensions to AutoLISP
(vl-load-com)
This function loads the extended AutoLISP functions provided with Visual
LISP. The Visual LISP extensions implement ActiveX and AutoCAD reactor
support through AutoLISP, and also provide ActiveX utility and data
conversion functions, dictionary handling functions, and curve
measurement functions.
Return Values
Unspecified.
SEE ALSO “Using Extended AutoLISP Functions” in the Visual LISP Devel-
oper’s Guide.
vl-load-reactors
Loads reactor support functions
(vl-load-reactors)
This function is identical to vl-load-com and is maintained for backward
compatibility.
Arguments
predicate- The test function. This can be any function that accepts a
function single argument and returns T for any user-specified
condition. The predicate-function value can take one of the
following forms:
Return Values
A list, starting with the first element that passes the test and containing all
elements following this in the original argument. If none of the elements
passes the test condition, vl-member-if returns nil.
Examples
The following command draws a line:
_$ (COMMAND "_.LINE" '(0 10) '(30 50) nil)
nil
vl-member-if | 225
vl-member-if-not
Determines if the predicate is nil for one of the list members
Arguments
predicate- The test function. This can be any function that accepts a
function single argument and returns T for any user-specified
condition. The predicate-function value can take one of the
following forms:
Return Values
A list, starting with the first element that fails the test and containing all ele-
ments following this in the original argument. If none of the elements fails
the test condition, vl-member-if-not returns nil.
Examples
_$ (vl-member-if-not 'atom '(1 "Str" (0 . "line") nil t))
((0 . "line") nil T)
vl-position
Returns the index of the specified list item
Arguments
symbol Any AutoLISP symbol.
Return Values
An integer containing the index position of symbol in list, or nil if symbol
does not exist in the list.
Note that the first list element is index 0, the second element is index 1, and
so on.
Examples
_$ (setq stuff (list "a" "b" "c" "d" "e"))
("a" "b" "c" "d" "e")
_$ (vl-position "c" stuff)
2
vl-prin1-to-string
Returns the string representation of LISP data as if it were output by the prin1 function
(vl-prin1-to-string data)
Arguments
data Any AutoLISP data.
Return Values
A string containing the printed representation of data as if displayed by
prin1.
Examples
_$ (vl-prin1-to-string "abc")
"\"abc\""
_$ (vl-prin1-to-string "c:\\acadwin")
"\"C:\\\\ACADWIN\""
_$ (vl-prin1-to-string 'my-var)
"MY-VAR"
vl-prin1-to-string | 227
vl-princ-to-string
Returns the string representation of LISP data as if it were output by the princ func tion
(vl-princ-to-string data)
Arguments
data Any AutoLISP data.
Return Values
A string containing the printed representation of data as if displayed by
princ.
Examples
_$ (vl-princ-to-string "abc")
"abc"
_$ (vl-princ-to-string "c:\\acadwin")
"C:\\ACADWIN"
_$ (vl-princ-to-string 'my-var)
"MY-VAR"
vl-propagate
Copies the value of a variable into all open document namespaces (and sets its value in
any subsequent drawings opened during the current AutoCAD session)
(vl-propagate 'symbol)
Arguments
symbol A symbol naming an AutoLISP variable.
Return Values
Unspecified.
Examples
Command: (vl-propagate 'radius)
nil
Arguments
reg-key A string specifying a Windows registry key.
If val-name is supplied and is not nil, the specified value will be purged from
the registry. If val-name is absent or nil, the function deletes the specified
key and all of its values.
Return Values
T if successful, otherwise nil.
Examples
_$ (vl-registry-write "HKEY_CURRENT_USER\\Test" "" "test data")
"test data"
_$ (vl-registry-read "HKEY_CURRENT_USER\\Test")
"test data"
_$ (vl-registry-delete "HKEY_CURRENT_USER\\Test")
T
NOTE This function cannot delete a key that has subkeys. To delete a subtree
you must use vl-registry-descendents to enumerate all subkeys and delete all
of them.
vl-registry-descendents
Returns a list of subkeys or value names for the specified registry key
vl-registry-delete | 229
Arguments
reg-key A string specifying a Windows registry key.
If val-names is supplied and is not nil, the specified value names will be listed
from the registry. If val-name is absent or nil, the function displays all sub-
keys of reg-key.
Return Values
A list of strings, if successful, otherwise nil.
Examples
$ (vl-registry-descendents "HKEY_LOCAL_MACHINE\\SOFTWARE")
("Description" "Program Groups" "ORACLE" "ODBC" "Netscape"
"Microsoft")
vl-registry-read
Returns data stored in the Windows registry for the specified key/value pair
Arguments
reg-key A string specifying a Windows registry key.
If val-name is supplied and is not nil, the specified value will be read from
the registry. If val-name is absent or nil, the function reads the specified key
and all of its values.
Return Values
A string containing registry data, if successful, otherwise nil.
Examples
_$ (vl-registry-read "HKEY_CURRENT_USER\\Test")
nil
_$ (vl-registry-write "HKEY_CURRENT_USER\\Test" "" "test data")
"test data"
vl-registry-write
Creates a key in the Windows registry
Arguments
reg-key A string specifying a Windows registry key.
If val-name is not supplied or is nil, a default value for the key is written. If
val-name is supplied and val-data is not specified, an empty string is stored.
Return Values
vl-registry-write returns val-data, if successful, nil otherwise.
Examples
_$ (vl-registry-write "HKEY_CURRENT_USER\\Test" "" "test data")
"test data"
_$ (vl-registry-read "HKEY_CURRENT_USER\\Test")
"test data"
vl-remove
Removes elements from a list
vl-registry-write | 231
Arguments
element-to- The value of the element to be removed; may be any LISP
remove data type.
Return Values
The list with all elements except those equal to element-to-remove.
Examples
_$ (vl-remove pi (list pi t 0 "abc"))
(T 0 "abc")
vl-remove-if
Returns all elements of the supplied list which fail the test function
Arguments
predicate- The test function. This can be any function that accepts a
function single argument and returns T for any user-specified
condition. The predicate-function value can take one of the
following forms:
Return Values
A list containing all elements of list for which predicate-function returns nil.
Examples
_$ (vl-remove-if 'vl-symbolp (list pi t 0 "abc"))
(3.14159 0 "abc")
Arguments
predicate- The test function. This can be any function that accepts a
function single argument and returns T for any user-specified
condition. The predicate-function value can take one of the
following forms:
Return Values
A list containing all elements of list for which predicate-function returns a non-
nil value
Examples
_$ (vl-remove-if-not 'vl-symbolp (list pi t 0 "abc"))
(T)
vl-some
Checks whether the predicate is not nil for one element combination
Arguments
predicate- The test function. This can be any function that accepts as
function many arguments as there are lists provided with vl-some,
and returns T on a user-specified condition. The predicate-
function value can take one of the following forms:
vl-remove-if-not | 233
list A list to be tested.
The vl-some function passes the first element of each supplied list as an argu-
ment to the test function, then the next element from each list, and so on.
Evaluation stops as soon as the predicate function returns a non-nil value for
an argument combination, or until all elements have been processed in one
of the lists.
Return Values
The predicate value, if predicate-function returned a value other than nil,
otherwise nil.
Examples
The following example checks whether nlst (a number list) has equal ele-
ments in sequence:
_$ (setq nlst (list 0 2 pi pi 4))
(0 2 3.14159 3.14159 4)
_$ (vl-some '= nlst (cdr nlst))
T
vl-sort
Sorts the elements in a list according to a given compare function
Arguments
list Any list.
Return Values
A list containing the elements of list in the order specified by comparison-
function. Duplicate elements may be eliminated from the list.
vl-sort-i
Sorts the elements in a list according to a given compare function, and returns the ele-
ment index numbers
Arguments
list Any list.
Return Values
A list containing the index values of the elements of list, sorted in the order
specified by comparison-function. Duplicate elements will be retained in the
result.
vl-sort-i | 235
Examples
Sort a list of characters in descending order:
_$ (vl-sort-i '("a" "d" "f" "c") '>)
(2 1 3 0)
The sorted list order is "f" "d" "c" "a"; "f" is the 3rd element (index 2) in the
original list, "d" is the 2nd element (index 1) in the list, and so on.
Note that both occurrences of 3 are accounted for in the result list.
Note that both a’s are accounted for in the result list.
vl-string->list
Converts a string into a list of character codes
(vl-string->list string)
Arguments
string A string.
Return Values
A list, each element of which is an integer representing the character code of
the corresponding character in string.
Examples
_$ (vl-string->list "")
nil
vl-string-elt
Returns the ASCII representation of the character at a specified position in a string
Arguments
string A string to be inspected.
Return Values
An integer denoting the ASCII representation of the character at the specified
position
Examples
_$ (vl-string-elt "May the Force be with you" 8)
70
vl-string-left-trim
Removes the specified characters from the beginning of a string
Arguments
character-set A string listing the characters to be removed.
Return Values
A string containing a substring of string with all leading characters in
charac ter-set removed
vl-string-elt | 237
Examples
_$ (vl-string-left-trim " \t\n" "\n\t STR ")
"STR "
_$ (vl-string-left-trim "12456789" "12463CPO is not R2D2")
"3CPO is not R2D2"
_$ (vl-string-left-trim " " " There are too many spaces here")
"There are too many spaces here"
vl-string-mismatch
Returns the length of the longest common prefix for two strings, starting at specified
positions
Arguments
str1 The first string to be matched.
Return Values
An integer.
Examples
_$ (vl-string-mismatch "VL-FUN" "VL-VAR")
3
_$ (vl-string-mismatch "vl-fun" "avl-var")
0
_$ (vl-string-mismatch "vl-fun" "avl-var" 0 1)
3
_$ (vl-string-mismatch "VL-FUN" "Vl-vAR")
1
_$ (vl-string-mismatch "VL-FUN" "Vl-vAR" 0 0 T)
3
Arguments
char-code The integer representation of the character to be searched.
Return Values
An integer representing the displacement at which char-code was found from
the beginning of the string; nil if the character was not found.
Examples
_$ (vl-string-position (ascii "z") "azbdc")
1
_$ (vl-string-position 122 "azbzc")
1
_$ (vl-string-position (ascii "x") "azbzc")
nil
The search string used in the following example contains two "z" characters.
Reading from left to right, with the first character being displacement 0,
there is one z at displacement 1 and another z at displacement 3:
_$ (vl-string-position (ascii "z") "azbzlmnqc")
1
Searching from left to right (the default), the "z" in position 1 is the first one
vl-string-position encounters. But when searching from right to left, as in
the following example, the "z" in position 3 is the first one encountered:
_$ (vl-string-position (ascii "z") "azbzlmnqc" nil t)
3
vl-string-position | 239
vl-string-right-trim
Removes the specified characters from the end of a string
Arguments
character-set A string listing the characters to be removed.
Return Values
A string containing a substring of string with all trailing characters in
charac ter-set removed.
Examples
_$ (vl-string-right-trim " \t\n" " STR \n\t ")
" STR"
_$ (vl-string-right-trim "1356789" "3CPO is not R2D267891")
"3CPO is not R2D2"
_$ (vl-string-right-trim " " "There are too many spaces here ")
"There are too many spaces here"
vl-string-search
Searches for the specified pattern in a string
Arguments
pattern A string containing the pattern to be searched for.
Return Values
An integer representing the position in the string where the specified pattern
was found, or nil if the pattern is not found; the first character of the string
is position 0.
vl-string-subst
Substitutes one string for another, within a string
Arguments
new-str The string to be substituted for pattern .
Return Values
The value of string after any substitutions have been made
Examples
Replace the string "Ben" with "Obi-wan":
_$ (vl-string-subst "Obi-wan" "Ben" "Ben Kenobi")
"Obi-wan Kenobi"
Nothing was substituted because vl-string-subst did not find a match for
"Ben"; the "ben" in the string that was searched begins with a lowercase "b".
vl-string-subst | 241
_$ (vl-string-subst "Obi-wan" "Ben" "Ben Kenobi Ben")
"Obi-wan Kenobi Ben"
Note that there are two occurrences of "Ben" in the string that was searched,
but vl-string-subst only replaces the first occurrence.
Replace "Ben" with "Obi-wan," but start the search at the fourth character in
the string:
_$ (vl-string-subst "Obi-wan" "Ben" "Ben \"Ben\" Kenobi" 3)
"Ben \"Obi-wan\" Kenobi"
There are two occurrences of "Ben" in the string that was searched, but
because vl-string-subst was instructed to begin searching at the fourth
character, it found and replaced the second occurrence, not the first.
vl-string-translate
Replaces characters in a string with a specified set of characters
Arguments
source-set A string of characters to be matched.
Return Values
The value of str after any substitutions have been made
Examples
_$ (vl-string-translate "abcABC" "123123" "A is a, B is b, C is C")
"1 is 1, 2 is 2, 3 is 3"
_$ (vl-string-translate "abc" "123" "A is a, B is b, C is C")
"A is 1, B is 2, C is C"
vl-string-trim
Removes the specified characters from the beginning and end of a string
Return Values
The value of str, after any characters have been trimmed.
Examples
_$ (vl-string-trim " \t\n" " \t\n STR \n\t ")
"STR"
_$ (vl-string-trim "this is junk" "this is junk Don't call this
junk! this is junk")
"Don't call this junk!"
_$ (vl-string-trim " " " Leave me alone ")
"Leave me alone"
vl-symbol-name
Returns a string containing the name of a symbol
(vl-symbol-name symbol)
Arguments
symbol Any LISP symbol.
Return Values
A string containing the name of the supplied symbol argument, in upper-
case.
Examples
_$ (vl-symbol-name 'S::STARTUP)
"S::STARTUP"
_$ (progn (setq sym 'my-var) (vl-symbol-name sym))
"MY-VAR"
_$ (vl-symbol-name 1)
; *** ERROR: bad argument type: symbolp 1
vl-symbol-name | 243
vl-symbol-value
Returns the current value bound to a symbol
(vl-symbol-value symbol)
This function is equivalent to the eval function, but does not call the LISP
evaluator.
Arguments
symbol Any LISP symbol.
Return Values
The value of symbol , after evaluation.
Examples
_$ (vl-symbol-value 't)
T
_$ (vl-symbol-value 'PI)
3.14159
_$ (progn (setq sym 'PAUSE) (vl-symbol-value sym))
"\\"
vl-symbolp
Identifies whether or not a specified object is a symbol
Arguments
(vl-symbolp object)
object Any LISP object.
Return Values
T if object is a symbol, otherwise nil.
Examples
_$ (vl-symbolp t)
T
_$ (vl-symbolp nil)
nil
vl-unload-vlx
Unload a VLX application that is loaded in its own namespace
(vl-unload-vlx appname)
Arguments
appname A string naming a VLX application that is loaded in its
own namespace. Do not include the .vlx extension.
The vl-unload-vlx function does not unload VLX applications that are
loaded in the current document's namespace.
Return Values
T if successful, otherwise vl-unload-vlx results in an error.
Examples
Assuming that vlxns is an application that is loaded in its own namespace,
the following command unloads vlxns:
Command: (vl-unload-vlx "vlxns")
T
The vl-unload-vlx command fails this time, because the application was not
loaded.
vl-unload-vlx | 245
vl-vbaload
Loads a Visual Basic project
Arguments
(vl-vbaload filename)
filename A string naming the Visual Basic project file to be loaded.
Return Values
Unspecified, if successful.
Examples
$ (vl-vbaload "c:/program files/acad2000/sample/vba/drawline.dvb")
"c:\\program files\\acad2000\\sample\\vba\\drawline.dvb"
vl-vbarun
Runs a Visual Basic macro
Arguments
(vl-vbarun macroname)
macroname A string naming a loaded Visual Basic macro.
Return Values
macroname
Examples
Load a VBA project file:
$ (vl-vbaload "c:/program files/acad2000/sample/vba/drawline.dvb")
"c:\\program files\\acad2000\\sample\\vba\\drawline.dvb"
(vl-vlx-loaded-p appname)
Arguments
appname A string naming a VLX application.
Return Values
T if the application is loaded, nil if it is not loaded.
Examples
Check to see if the vlxns application is loaded in its own namespace:
Command: (vl-vlx-loaded-p "vlxns")
nil
This example assumes vlxns was defined to run in its own namespace. If the
application was not defined to run in its own namespace, it would load into
the current document’s namespace and vl-vlx-loaded-p would return nil.
vlax-3D-point
Creates ActiveX-compatible(variant) 3D point structure
Arguments
list A list of 2 or 3 numbers, representing points.
vl-vlx-loaded-p | 247
x, y Numbers representing X and Y coordinates of a point.
Return Values
A variant containing a three-element array of doubles.
Examples
$ (vlax-3D-point 5 20)
#<variant 8197 ...>
_$ (vlax-3D-point '(33.6 44.0 90.0))
<variant 8197 ...>
vlax-add-cmd
Adds commands to the AutoCAD built-in command set
NOTE You cannot use vlax-add-cmd to expose functions that create reactor
objects or serve as reactor callbacks.
Return Values
The global-name argument, if successful. The function returns nil, if
acedRegCmds->addCommand(...) returns an error condition.
Examples
The hello-autocad function in the following example has no c: prefix, but
the vlax-add-cmd makes it visible as an ObjectARX-style command at the
AutoCAD Command prompt:
_$ (defun hello-autocad () (princ "hello Visual LISP"))
HELLO-AUTOCAD
_$ (vlax-add-cmd "hello-autocad" 'hello-autocad)
"hello-autocad"
vlax-add-cmd | 249
SEE ALSO the vlax-remove-cmd function.
vlax-create-object
Creates a new instance of an application object
(vlax-create-object prog-id)
Use vlax-create-object when you want a new instance of an application to
be started, and an object of the type specified by <Component> (see the argu-
ment description) to be created. To use the current instance, use
vlax-get-object. However, if an application object has registered itself as a
single-instance object, only one instance of the object is created, no matter
how many times you call vlax-create-object.
Arguments
prog-id A string containing the programmatic identifier of the
desired ActiveX object. The format of prog-id is:
<Vendor>.<Component>.<Version >
For example:
AutoCAD.Drawing.15
Return Values
The application object (VLA-object).
Examples
Create an instance of an Excel application:
_$ (vlax-create-object "Excel.Application")
#<VLA-OBJECT _Application 0017b894>
vlax-curve-getArea
Returns the area inside the curve
(vlax-curve-getArea curve-obj)
Arguments
curve-obj The VLA-object to be measured.
Examples
Assume the curve being measured is the ellipse in the following drawing:
vlax-curve-getDistAtParam
Returns the length of the curve's segment from the curve's beginning to the specified
parameter
Arguments
curve-obj The VLA-object to be measured.
Return Values
A real number that is the length up to the specified parameter, if successful,
otherwise nil.
vlax-curve-getDistAtParam | 251
Examples
Assume that splineObj points to the spline in the following drawing:
_$ (vlax-curve-getDistAtParam splineObj
( / (- endspline startspline) 2))
8.99417
The distance from the start to the middle of the curve is 8.99417.
vlax-curve-getDistAtPoint
Returns the length of the curve's segment between the curve's start point and the spec-
ified point
Return Values
A real number if successful, otherwise nil.
Examples
For the following example, assume that splineObj points to the spline
shown in the example for vlax-curve-getDistAtParam.
Set OSNAP to tangent and select the point where the line is tangent to the
curve:
_$ (setq selPt (getpoint))
(4.91438 6.04738 0.0)
Determine the distance from the start of the curve to the selected point:
_$ (vlax-curve-getDistAtPoint splineObj selpt)
5.17769
vlax-curve-getEndParam
Returns the parameter of the endpoint of the curve
(vlax-curve-getEndParam curve-obj)
Arguments
curve-obj The VLA-object to be measured.
Return Values
A real number representing an end parameter, if successful, otherwise nil.
Examples
Assuming that ellipseObj points to the ellipse shown in the example for
vlax-curve-getArea, the following function call returns the end parameter of
the curve:
_$ (vlax-curve-getendparam ellipseObj)
6.28319
vlax-curve-getEndParam | 253
SEE ALSO the vlax-curve-getStartParam function.
vlax-curve-getEndPoint
Returns the endpoint (in WCS) of the curve
(vlax-curve-getEndPoint curve-obj)
Arguments
curve-obj The VLA-object to be measured.
Return Values
A 3D point list representing an endpoint, if successful, otherwise nil.
Examples
Get the endpoint of the ellipse used to demonstrate vlax-curve-getArea:
_$ (vlax-curve-getEndPoint ellipseObj)
(2.0 2.0 0.0)
vlax-curve-getParamAtDist
Returns the parameter of a curve at the specified distance from the beginning of the
curve
Arguments
curve-obj The VLA-object to be measured.
Return Values
A real number representing a parameter, if successful, otherwise nil.
vlax-curve-getParamAtPoint
Returns the parameter of the curve at the point
Arguments
curve-obj The VLA-object to be measured.
Return Values
A real number representing a parameter, if successful, otherwise nil.
Examples
Assuming that ellipseObj points to the ellipse shown in the example for
vlax-curve-getArea, set OSNAP to tangent and select the point where the line
is tangent to the ellipse:
_$ (setq selPt (getpoint))
(7.55765 5.55066 0.0)
vlax-curve-getPointAtDist
Returns the point (in WCS) along a curve at the distance specified by the user
Arguments
curve-obj The VLA-object to be measured.
vlax-curve-getParamAtPoint | 255
dist The distance along the curve from the beginning of the
curve to the location of the specified point.
Return Values
A 3D point list representing a point on the curve, if successful, otherwise nil.
Examples
Assuming that splineObj points to the spline shown in the example for
vlax-curve-getDistAtParam, determine the point at a distance of 1.0 from the
beginning of the spline:
_$ (vlax-curve-getPointAtDist splineObj 1.0)
(2.24236 2.99005 0.0)
vlax-curve-getPointAtParam
Returns the point at the specified parameter value along a curve
Arguments
curve-obj The VLA-object to be measured.
Return Values
A 3D point list representing a point on the curve, if successful, otherwise nil.
Examples
For the following example, assume that splineObj points to the spline
shown in the example for vlax-curve-getDistAtParam.
(vlax-curve-getStartParam curve-obj)
Arguments
curve-obj The VLA-object to be measured.
Return Values
A real number representing the start parameter, if successful, otherwise nil.
Examples
Assuming that ellipseObj points to the ellipse shown in the example for
vlax-curve-getArea, determine the start parameter of the curve:
_$ (vlax-curve-getstartparam ellipseObj)
0.0
vlax-curve-getStartPoint
Returns the start point (in WCS) of the curve
(vlax-curve-getStartPoint curve-obj)
Arguments
curve-obj The VLA-object to be measured.
Return Values
A 3D point list representing the start point, if successful, otherwise nil.
Examples
Get the start point of the ellipse used to demonstrate vlax-curve-getArea:
_$ (vlax-curve-getStartPoint ellipseObj)
(2.0 2.0 0.0)
For an ellipse, the start points and endpoints are the same.
vlax-curve-getStartParam | 257
Obtain the start point of the spline used to demonstrate
vlax-curve-getDistAtParam:
_$ (vlax-curve-getStartPoint splineObj)
(1.73962 2.12561 0.0)
vlax-curve-isClosed
Determines if the specified curve is closed (that is, the start point is the same as the end-
point)
(vlax-curve-isClosed curve-obj)
Arguments
curve-obj The VLA-object to be tested.
Return Values
T if the curve is closed, otherwise nil.
Examples
Determine if the ellipse used to demonstrate vlax-curve-getArea is closed:
_$ (vlax-curve-isClosed ellipseObj)
T
vlax-curve-isPeriodic
Determines if the specified curve has an infinite range in both directions and there is a
period value dT, such that a point on the curve at (u + dT) = point on curve (u), for any
parameter u.
(vlax-curve-isPeriodic curve-obj)
Arguments
curve-obj The VLA-object to be tested.
Examples
Determine if the ellipse used to demonstrate vlax-curve-getArea is periodic:
_$ (vlax-curve-isPeriodic ellipseObj)
T
vlax-curve-isPlanar
Determines if there is a plane that contains the curve
(vlax-curve-isPlanar curve-obj)
Arguments
curve-obj The VLA-object to be tested.
Return Values
T if there is a plane that contains the curve, otherwise nil.
Examples
Determine if there is a plane containing the ellipse used to demonstrate
vlax-curve-getArea:
_$ (vlax-curve-isPlanar ellipseObj)
T
vlax-curve-isPlanar | 259
vlax-curve-getClosestPointTo
Returns the point (in WCS) on a curve that is nearest to the specified point
Arguments
curve-obj The VLA-object to be measured.
givenPnt A point (in WCS) for which to find the nearest point on
the curve.
Return Values
A 3D point list representing a point on the curve, if successful, otherwise nil.
Examples
Assume that the curve being measured is the arc in the following drawing:
Return the closest point on the arc to the coordinates 6.0, 0.5:
_$ (vlax-curve-getClosestPointTo arcObj '(6.0 0.5 0.0))
(6.0 1.5 0.0)
Return the closest point on the arc to the coordinates 6.0, 0.5, after extending
the arc:
(vlax-curve-getClosestPointToProjection curve-obj
givenPnt normal [extend])
Arguments
curve-obj The VLA-object to be measured.
givenPnt A point (in WCS) for which to find the nearest point on
the curve.
normal A normal vector (in WCS) for the plane to project onto.
extend If specified and not nil,
vlax-curve-getClosestPointToProjection extends the
curve when searching for the nearest point.
Return Values
A 3D point list representing a point on the curve, if successful, otherwise nil.
vlax-curve-getFirstDeriv
Returns the first derivative (in WCS) of a curve at the specified location
Arguments
curve-obj The VLA-object to be measured.
Return Values
A 3D vector list, if successful, otherwise nil.
vlax-curve-getClosestPointToProjection | 261
Examples
For the following example, assume that splineObj points to the spline
shown in the example of the vlax-curve-getDistAtParam function.
Determine the first derivative at the parameter midway along the curve:
_$ (vlax-curve-getFirstDeriv splineObj
( / (- endspline startspline) 2))
(0.422631 -1.0951 0.0)
vlax-curve-getSecondDeriv
Returns the second derivative (in WCS) of a curve at the specified location
Arguments
curve-obj The VLA-object to be measured.
Return Values
A 3D vector list, if successful, otherwise nil.
Examples
For the following example, assume that splineObj points to the spline
shown in the example of the vlax-curve-getDistAtParam function.
vlax-dump-object
Lists an object’s properties, and optionally, the methods that apply to the object
Arguments
obj A VLA-object.
Return Values
T, if successful. If an invalid object name is supplied, vlax-dump-object dis-
plays an error message.
Examples
_$ (setq aa (vlax-get-acad-object))
#<VLA-OBJECT IAcadApplication 00b3b91c>
_$ (vlax-dump-object aa)
; IAcadApplication: AutoCAD Application Interface
; Property values:
; ActiveDocument (RO) = #<VLA-OBJECT IAcadDocument 01b52fac>
; Application (RO) = #<VLA-OBJECT IAcadApplication 00b3b91c>
; Caption (RO) = "AutoCAD - [Drawing.dwg]"
.
.
.
T
List an object’s properties and the methods that apply to the object:
_$ (vlax-dump-object aa T)
; IAcadApplication: AutoCAD Application Interface
; Property values:
; ActiveDocument (RO) = #<VLA-OBJECT IAcadDocument 01b52fac>
; Application (RO) = #<VLA-OBJECT IAcadApplication 00b3b91c>
; Caption (RO) = "AutoCAD - [Drawing.dwg]"
.
.
.
vlax-dump-object | 263
; Methods supported:
; EndUndoMark ()
; Eval (1)
; GetInterfaceObject (1)
; ListAds ()
; ListArx ()
.
.
.
T
vlax-ename->vla-object
Transforms entity to VLA-object
(vlax-ename->vla-object entname)
Arguments
entname An entity name (ename data type).
Return Values
A VLA-object.
Examples
_$ (setq e (car (entsel)))
<Entity name: 27e0540>
_$ (vlax-ename->vla-object e)
#<VLA-OBJECT IAcadLWPolyline 03f713a0>
vlax-erased-p
Determines whether an object was erased
(vlax-erased-p obj)
Arguments
obj A VLA-object.
Return Values
T if the object was erased, otherwise nil.
Arguments
symbol A symbol to be assigned to each VLA-object in a
collection.
Return Values
The value of the last expression evaluated for the last object in the collection.
Examples
The following code issues vlax-dump-object on every drawing object in the
model space:
(vl-load-com) ; load ActiveX support
(vlax-for for-item
(vla-get-modelspace
(vla-get-activedocument (vlax-get-acad-object))
)
(vlax-dump-object for-item) ; list object properties
)
vlax-get-acad-object
Retrieves the top level AutoCAD application object for the current AutoCAD session
(vlax-get-acad-object)
Return Values
A VLA-object.
Examples
_$ (setq aa (vlax-get-acad-object))
#<VLA-OBJECT IAcadApplication 00b3b91c>
vlax-for | 265
vlax-get-object
Returns a running instance of an application object
(vlax-get-object prog-id)
Arguments
prog-id A string that identifies the desired application object. The
format of prog-id is:
appname.objecttype
where appname is the name of the application and
objecttype is the application object. The objecttype may be
followed by a version number.
Return Values
The application object, or nil, if there is no instance of the specified object
currently running.
Examples
Obtain the Application object for the Excel program:
_$ (vlax-get-object "Excel.Application")
#<VLA-OBJECT _Application 0017bb5c>
vlax-get-or-create-object
Returns a running instance of an application object, or creates a new instance, if the
application is not currently running
(vlax-get-or-create-object prog-id)
<Vendor>.<Component>.<Version >
For example:
AutoCAD.Drawing.15
Return Values
The object.
Examples
_$ (vlax-get-or-create-object "Excel.Application")
#<VLA-OBJECT _Application 0017bb5c>
vlax-get-property
Retrieves a VLA-object’s property
Arguments
object A VLA-object.
Return Values
The value of the object’s property.
Examples
Begin by retrieving a pointer to the root AutoCAD object:
_$ (setq acadObject (vlax-get-acad-object))
#<VLA-OBJECT IAcadApplication 00a4b2b4>
vlax-get-property | 267
Get the ModelSpace property of the ActiveDocument object:
_$ (setq mSpace (vlax-get-property acadDocument 'Modelspace))
#<VLA-OBJECT IAcadModelSpace 00c14b44>
vlax-import-type-library
Imports information from a type library
Arguments
filename A string naming the type library. A file can be one of the
following types:
Return Values
T, if successful.
Examples
Import a Microsoft Word ™type library, assigning the prefix "msw-" to meth-
ods and properties, and "mswc-" to constants:
$ (vlax-import-type-library
:tlb-filename "c:/program files/microsoft office/msword8.olb"
:methods-prefix "msw-"
:properties-prefix "msw-"
:constants-prefix "mswc-")
T
Remarks
Function wrappers created by vlax-import-type-library are available only
in the context of the document vlax-import-type-library was issued from.
vlax-import-type-library | 269
■ In your AutoLISP source file, code the vlax-import-type-library call
before any code that uses method or property wrappers or constants
defined in the type library.
vlax-invoke-method
Calls the specified ActiveX method
Arguments
obj A VLA-object.
Return Values
Depends on the method invoked.
Examples
The following example uses the AddCircle method to draw a circle in the cur-
rent AutoCAD drawing.
The first argument to AddCircle specifies the location of the center of the cir-
cle. The method requires the center to be specified as a variant containing a
three-element array of doubles. You can use vlax-3d-point to convert an
AutoLISP point list to the required variant data type:
_$ (setq circCenter (vlax-3d-point '(3.0 3.0 0.0)))
#<variant 8197 ...>
Arguments
dict A VLA-object, AutoCAD drawing entity object, or a string
naming a global dictionary.
Return Values
T, if successful, otherwise nil (for example, the data did not exist).
Examples
Add LISP data to a dictionary:
_$ (vlax-ldata-put "dict" "key" '(1))
(1)
vlax-ldata-get
Retrieves LISP data from a drawing dictionary or an object
vlax-ldata-delete | 271
Arguments
dict A VLA-object, AutoCAD drawing entity object, or a string
naming a global dictionary.
Note that a separate-namespace VLX can store both private and non-private
data using the same dict and key. The private data can only be accessed by
the same VLX, but any application can retrieve the non-private data.
Return Values
The value of the key item.
Examples
Enter the following commands at the Visual LISP Console window:
_$ (vlax-ldata-put "mydict" "mykey" "Mumbo Dumbo")
"Mumbo Dumbo"
_$ (vlax-ldata-get "mydict" "mykey")
"Mumbo Dumbo"
2 Enter the following code in a file and use Make Application to build a VLX
from the file. Use the Expert mode of the Make Application Wizard, and
select the Separate Namespace option in the Compile Options tab.
Refer back to the code defining ldataput: this function stores a string con-
taining "Mine! Mine!"
Notice that the data returned by ldataget is not the data stored by ldataput.
This is because ldataget does not specify the private argument in its call to
vlax-ldata-get. So the data retrieved by ldataget is the data set by issuing
vlax-ldata-put from the Visual LISP Console in step 1.
_$ (ldataget-nilt)
"Mine! Mine! "
7 From the Visual LISP Console prompt, issue the same call that ldataget-nilt
uses to retrieve private data:
_$ (vlax-ldata-get "mydict" "mykey" nil T)
"Mumbo Dumbo"
vlax-ldata-get | 273
vlax-ldata-list
Lists LISP data in a drawing dictionary
Arguments
dict A VLA-object, AutoCAD drawing entity object, or a string
naming a global dictionary.
Return Values
An associative list consisting of pairs (key . value).
Examples
Use vlax-ldata-put to store LISP data in a dictionary:
$ (vlax-ldata-put "dict" "cay" "Mumbo Jumbo ")
"Mumbo Jumbo "
$ (vlax-ldata-put "dict" "say" "Floobar ")
"Floobar "
vlax-ldata-put
Stores LISP data in a drawing dictionary or an object
Return Values
The value of data.
Examples
_$ (vlax-ldata-put "dict" "key" '(1))
(1)
$ (vlax-ldata-put "dict" "cay" "Gumbo jumbo")
"Gumbo jumbo"
vlax-ldata-test
Determines if data can be saved over a session boundary
(vlax-ldata-test data)
Arguments
data Any LISP data to be tested.
Return Values
T, if the data can be saved and restored over the session boundary, nil other-
wise.
Examples
Determine if a string can be saved as ldata over a session boundary:
_$ (vlax-ldata-test "Gumbo jumbo")
T
vlax-ldata-test | 275
Determine if a function can be saved as ldata over a session boundary:
_$ (vlax-ldata-test yinyang)
nil
vlax-make-safearray
Creates a safearray
Numbers 0
Booleans :vlax-false
Object nil
vlax-vbString (8)—String
vlax-vbObject (9)—Object
vlax-vbBoolean (11)—Boolean
vlax-vbVariant (12)—Variant
The integer shown in parentheses indicates the value to
which the constant evaluates. It is recommended that you
specify the constant in your argument, not the integer
value, in case the value changes in later releases of
AutoCAD.
Return Values
The safearray created.
Examples
Create a single-dimension safearray consisting of doubles, beginning with
index 0:
_$ (setq point (vlax-make-safearray vlax-vbDouble '(0 . 3)))
#<safearray...>
The result shows each element of the array was initialized to zero.
vlax-make-safearray | 277
Create a two-dimension array of strings, with each dimension starting at
index 1:
$ (setq matrix (vlax-make-safearray vlax-vbString '(1 . 2) '(1 . 2)
))
#<safearray...>
vlax-make-variant
Creates a variant data type
Arguments
value The value to be assigned to the variant. If omitted, the
variant is created with the vlax-vbEmpty type
(uninitialized).
vlax-vbString (8)—String
vlax-vbObject (9)—Object
vlax-vbBoolean (11)—Boolean
nil—vlax-vbEmpty
:vlax-null—vlax-vbNull
integer—vlax-vbLong
real—vlax-vbDouble
string—vlax-vbString
VLA-object—vlax-vbObject
:vlax-true, :vlax-false—vlax-vbBoolean
variant—same as the type of initial value
vlax-make-safearray—vlax-vbArray
Return Values
The variant created.
Examples
Create a variant using the defaults for vlax-make-variant:
_$ (setq varnil (vlax-make-variant))
#<variant 0 >
Repeat the previous command, but omit the type argument and see what
happens:
vlax-make-variant | 279
_$ (setq varint (vlax-make-variant 5))
#<variant 3 5>
vlax-map-collection
Applies a function to all objects in a collection
Arguments
obj A VLA-object representing a collection.
Return Values
The obj first argument.
vlax-method-applicable-p
Determines if an object supports a particular method
Arguments
obj A VLA-object.
Return Values
T, if the object supports the method, nil otherwise.
Examples
The following commands are issued against a LightweightPolyline object:
vlax-method-applicable-p | 281
_$ (vlax-method-applicable-p WhatsMyLine 'copy)
T
_$ (vlax-method-applicable-p WhatsMyLine 'AddBox)
nil
vlax-object-released-p
Determines if an object has been released
(vlax-object-released-p obj)
Arguments
obj A VLA-object.
Return Values
T, if the object is released (no AutoCAD drawing object is attached to obj),
nil, if the object has not been released.
Examples
Attach an Excel application to the current AutoCAD drawing:
_$ (vlax-release-object excelobj)
1
Issue vlax-object-released-p to verify the object was released:
_$ (vlax-object-released-p excelobj)
T
The AutoCAD registry path can be used to register an application for demand
loading.
(vlax-product-key)
Return Values
A string containing the AutoCAD registry path.
Examples
_$ (vlax-product-key)
"Software\\Autodesk\\AutoCAD\\R15.0\\ACAD-1:409"
vlax-property-available-p
Determines if an object has a specified property
Arguments
obj A VLA-object.
Return Values
T, if the object has the specified property, otherwise nil. If T is specified for
the check-modify argument, vlax-property-available-p returns nil if either
the property is not available or the property cannot be modified.
Examples
The following examples apply to a LightweightPolyline object:
_$ (vlax-property-available-p WhatsMyLine 'Color)
T
_$ (vlax-property-available-p WhatsMyLine 'center)
nil
vlax-product-key | 283
The following examples apply to a Circle object:
_$ (vlax-property-available-p myCircle 'area)
T
Note how supplying the optional third argument changes the result:
_$ (vlax-property-available-p myCircle 'area T)
nil
The function returns nil because, although the circle has an "area" property,
that property cannot be modified.
vlax-put-property
Set the property of an ActiveX object
Arguments
obj A VLA-object.
Return Values
Nil, if successful.
Examples
Color an object red:
$ (vlax-put-property vlaobj 'Color 1)
nil
(vlax-read-enabled-p obj)
Arguments
obj A VLA-object.
Return Values
T, if the object is readable, otherwise nil.
vlax-release-object
Releases a drawing object
(vlax-release-object obj)
Arguments
obj A VLA-object.
Return Values
Unspecified.
vlax-remove-cmd
Removes a single command or a command group
Removes a single command or the whole command group for the current
AutoCAD session.
(vlax-remove-cmd global-name)
Arguments
global-name Either a string naming the command, or T. If global-name
is T, the whole command group VLC-AppName (for
example, VLC-VLIDE) is deleted.
vlax-read-enabled-p | 285
Return Values
T, if successful, nil otherwise (for example, the command is not defined).
Examples
Remove a command defined with vlax-add-cmd:
_$ (vlax-remove-cmd "hello-autocad")
T
This time vlax-remove-cmd returns nil, because the specified command does
not exist anymore.
vlax-safearray-fill
Stores data in the elements of a safearray
Arguments
var A variable whose data type is a safearray.
Return Values
var
Examples
Create a single-dimension array of doubles:
_$ (setq sa (vlax-make-safearray vlax-vbdouble '(0 . 2)))
#<safearray...>
Notice that only the first element in the array has been changed; the remain-
ing elements are unaffected and retain the value you previously set them to.
If you need to change the second or third elements and leave the first ele-
ment unaffected, use vlax-put-element.
vlax-safearray-fill | 287
safearray-put-element, vlax-safearray-type, vlax-safearray->list, and vlax-
variant-value functions.
vlax-safearray-get-dim
Returns the number of dimensions in a safearray object
(vlax-safearray-get-dim var)
Arguments
var A variable whose data type is a safearray.
Return Values
An integer identifying the number of dimensions in var. An error occurs if var
is not a safearray.
Examples
Set sa-int to a single-dimension safearray with one dimension:
_$ (setq sa-int (vlax-make-safearray vlax-vbinteger '(1 . 4)))
#<safearray...>
vlax-safearray-get-element
Returns an element from an array
Arguments
var A variable whose data type is a safearray.
Examples
Create an array with two dimensions, each dimension starting at index 1:
$ (setq matrix (vlax-make-safearray vlax-vbString '(1 . 2) '(1 . 2)
))
#<safearray...>
vlax-safearray-get-l-bound
Returns the lower boundary (starting index) of a dimension of an array
Arguments
var A variable whose data type is a safearray.
Return Values
An integer representing the lower boundary (starting index) of the dimen-
sion. If var is not an array, or dim is invalid (for example, 0, or a number
greater than the number of dimensions in the array), an error results.
vlax-safearray-get-l-bound | 289
Examples
The following examples evaluate a safearray defined as follows:
(vlax-make-safearray vlax-vbString '(1 . 2) '(0 . 1) ))
Get the starting index value of the second dimension of the array:
$ (vlax-safearray-get-l-bound tmatrix 2)
0
vlax-safearray-get-u-bound
Returns the upper boundary (end index) of a dimension of an array
Arguments
var A variable whose data type is a safearray.
Return Values
An integer representing the upper boundary (end index) of the dimension. If
var is not an array, or dim is invalid (for example, 0, or a number greater than
the number of dimensions in the array), an error results.
Examples
The following examples evaluate a safearray defined as follows:
(vlax-make-safearray vlax-vbString '(1 . 2) '(0 . 1) ))
Get the end index value of the second dimension of the array:
$ (vlax-safearray-get-u-bound tmatrix 2)
1
vlax-safearray-put-element
Adds an element to an array
Arguments
var A variable whose data type is a safearray.
Return Values
The value assigned to the element.
Examples
Create a single-dimension array consisting of doubles:
_$ (setq point (vlax-make-safearray vlax-vbDouble '(0 . 2)))
#<safearray...>
vlax-safearray-put-element | 291
Create a two-dimension array consisting of strings:
$ (setq matrix (vlax-make-safearray vlax-vbString '(1 . 2) '(1 . 2)
))
#<safearray...>
Note that you can also populate arrays using the vlax-safearray-fill
function. The following function call accomplishes the same task as three
vlax-safearray-put-element calls:
vlax-safearray-type
Returns the data type of a safearray
(vlax-safearray-type var)
Arguments
var A variable containing a safearray.
Return Values
If var contains a safearray, one of the following integers is returned:
2 Integer (vlax-vbInteger)
8 String (vlax-vbString)
9 Object (vlax-vbObject)
12 Variant (vlax-vbVariant)
Examples
Create a single-dimension array of doubles and a two-dimension array of
strings:
_$ (setq point (vlax-make-safearray vlax-vbDouble '(0 . 2)))
#<safearray...>
$ (setq matrix (vlax-make-safearray vlax-vbString '(1 . 2) '(1 . 2)
))
#<safearray...>
vlax-safearray->list
Returns the elements of a safearray in list form
(vlax-safearray->list var)
Arguments
var A variable containing a safearray.
Return Values
A list.
Examples
Create a single-dimension array of doubles:
_$ (setq point (vlax-make-safearray vlax-vbDouble '(0 . 2)))
#<safearray...>
vlax-safearray->list | 293
_$ (vlax-safearray-put-element point 0 100)
100
_$ (vlax-safearray-put-element point 1 100)
100
_$ (vlax-safearray-put-element point 2 0)
0
vlax-tmatrix
Returns a suitable representation for a 4x4 transformation matrix to be used in VLA
methods
(vlax-tmatrix list)
Arguments
list A list of four lists, each containing four numbers,
representing transformation matrix elements.
Return Values
A variant of type safearray, representing the 4x4 transformation matrix.
Examples
Define a transformation matrix and assign its value to variable tmatrix:
_$ (setq tmatrix (vlax-tmatrix '((1 1 1 0) (1 2 3 0) (2 3 4 5)
(2 9 8 3))))
#<variant 8197 ...>
;; Create a line
vlax-typeinfo-available-p
Determines whether TypeLib information is present for the specified type of object
(vlax-typeinfo-available-p obj)
Arguments
obj A VLA-object.
vlax-typeinfo-available-p | 295
Return Values
T, if TypeLib information is available, otherwise nil.
vlax-variant-change-type
Returns the value of a variant after changing it from one data type to another
Arguments
var A variable whose value is a variant.
type The type of variant to return, using the value of var (the
value of var is unchanged). The type value can be
represented by one of the following constants:
vlax-vbEmpty (0)—Uninitialized
vlax-vbNull (1)—Contains no valid data
vlax-vbInteger (2)—Integer
vlax-vbLong (3)—Long integer
vlax-vbSingle (4)—Single-precision floating-point
number
vlax-vbString (8)—String
vlax-vbObject (9)—Object
vlax-vbBoolean (11)—Boolean
vlax-vbArray (8192)—Array
The integer shown in parentheses indicates the value to
which the constant evaluates. It is recommended that you
specify the constant in your argument, not the integer
value, in case the value changes in later releases of
AutoCAD.
Examples
Set a variable named varint to a variant value:
_$ (setq varint (vlax-make-variant 5))
#<variant 3 5>
Set a variable named varintstr to the value contained in varint, but convert
that value to a string:
_$ (setq varintStr (vlax-variant-change-type varint vlax-vbstring))
#<variant 8 5>
vlax-variant-type
Determines the data type of a variant
(vlax-variant-type var)
Arguments
var A variable whose value is a variant.
Return Values
If var contains a variant, one of the following integers is returned:
0 Uninitialized ( vlax-vbEmpty)
2 Integer (vlax-vbInteger)
vlax-variant-type | 297
8 String (vlax-vbString)
9 Object (vlax-vbObject)
11 Boolean (vlax-vbBoolean)
Examples
Set a variant to nil and display the variant’s data type:
_$ (setq varnil (vlax-make-variant nil))
#<variant 0 >
_$ (vlax-variant-type varnil)
0
Set a variant to an integer value and explicitly define the variant as an integer
data type:
_$ (setq varint (vlax-make-variant 5 vlax-vbInteger))
#<variant 2 5>
_$ (vlax-variant-type varint)
2
Set a variant to an integer value and display the variant’s data type:
_$ (setq varint (vlax-make-variant 5))
#<variant 3 5>
_$ (vlax-variant-type varint)
3
Create a safearray of doubles, assign the safearray to a variant, and display the
variant’s data type:
_$ (setq 4dubs (vlax-make-safearray vlax-vbDouble '(0 . 3)))
#<safearray...>
_$ (setq var4dubs (vlax-make-variant 4dubs))
#<variant 8197 ...>
_$ (vlax-variant-type var4dubs)
8197
vlax-variant-value
Returns the value of a variant
(vlax-variant-value var)
Arguments
var A variable whose value is a variant.
Return Values
The value of the variable. If the variable does not contain a variant, an error
occurs.
Examples
_$ (vlax-variant-value varstr)
"ghost"
_$ (vlax-variant-value varint)
5
_$ (vlax-variant-value notvar)
; *** ERROR: bad argument type: variantp 6.0
The last example results in an error, because notvar does not contain a vari-
ant.
vlax-variant-value | 299
vlax-vla-object->ename
Transforms a VLA-object to an AutoLISP entity
(vlax-vla-object->ename obj)
Arguments
obj A VLA-object.
Return Values
An AutoLISP entity name (ename data type).
Examples
_$ (vlax-vla-object->ename vlaobj)
<Entity name: 27e0540>
vlax-write-enabled-p
Determines if an AutoCAD drawing object can be modified
(vlax-write-enabled-p obj)
Arguments
obj A VLA-object or AutoLISP entity object (ename).
Return Values
T, if the AutoCAD drawing object can be modified, nil if the object cannot
be modified.
vlisp-compile
Compiles AutoLISP source code into a FAS file
NOTE The Visual LISP IDE must be open in order for vlisp-compile to work.
Return Values
T, if compilation is successful, nil otherwise.
Examples
Assuming that yinyang.lsp resides in a directory that is in the AutoCAD Sup-
port File Search Path, the following command compiles this program:
_$ (vlisp-compile 'st "yinyang.lsp")
T
The output file is named yinyang.fas and resides in the same directory as the
source file.
The following command com piles yinyang.lsp and names the output file
GoodKarma.fas:
(vlisp-compile 'st "yinyang.lsp" "GoodKarma.fas")
Note that the output file from the previous command resides in the
AutoCAD install directory, not the directory where yinyang.lsp resides. The
following command compiles yinyang.lsp and directs the output file to the
c:\my documents directory:
(vlisp-compile 'st "yinyang.lsp" "c:/my documents/GoodKarma")
vlisp-compile | 301
This last example identifies the full path of the file to be compiled:
(vlisp-compile ‘st "c:/program files/acad2000/Sample/yinyang.lsp")
The output file from this command is named yinyang.fas and resides in the
same directory as the input file.
SEE ALSO “Compiling a Program from a File” in the Visual LISP Developer’s
Guide.
vlr-acdb-reactor
Constructs a reactor object that notifies when an object is added to, modified in, or
erased from a drawing database
Arguments
data Any AutoLISP data to be associated with a reactor object,
or nil, if no data.
(e vent-name . callback_function)
Name Event
Name Event
vlr-add
Enables a disabled reactor object
(vlr-add obj)
Arguments
obj A VLR object representing the reactor to be enabled.
Return Values
The obj argument.
vlr-added-p
Tests to determine if a reactor object is enabled
(vlr-added-p obj)
Arguments
obj A VLR object representing the reactor to be tested.
vlr-add | 303
Return Values
T, if the specified reactor is enabled, or nil, if the reactor is disabled.
vlr-beep-reaction
Produces a beep sound
(vlr-beep-reaction [args])
Arguments
This is a predefined callback function that accepts a variable number of argu-
ments, depending on the reactor type. The function can be assigned to an
event handler for debugging.
vlr-command-reactor
Constructs an editor reactor that notifies of a command event
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data is to be associated with the
reactor.
(e vent-name . callback_function)
vlr-current-reaction-name
Returns the name (symbol) of the current event, if called from within a reactor’s callback
(vlr-current-reaction-name)
Return Values
A symbol indicating the event that triggered the reactor.
vlr-data
Returns application-specific data associated with a reactor
(vlr-data obj)
Arguments
obj A VLR object representing the reactor object from which
to extract data.
Return Values
The application-specific data obtained from the reactor object.
vlr-current-reaction-name | 305
Examples
The following example obtains a string associated with the circleReactor
VLR object:
$ (vlr-data circleReactor)
"Circle Reactor"
vlr-data-set
Overwrites application-specific data associated with a reactor
Arguments
obj A VLR object representing the reactor object whose data is
to be overwritten.
Return Values
The data argument.
Examples
Return the application-specific data value attached to a reactor:
$ (vlr-data circleReactor)
"Circle Reactor"
NOTE The vlr-data-set function should be used with care to avoid creation
of circular structures.
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
:vlr-beginDeepCloneXlation A deep clone operation has two stages. First, each object
and any owned objects are cloned. Second, any object ID
references are translated to their cloned IDs. This callback
occurs between these two stages.
vlr-deepclone-reactor | 307
DeepClone reactor callback data
:vlr-beginDeepClone 0
:vlr-abortDeepClone
:vlr-endDeepClone
vlr-docmanager-reactor
Constructs a reactor object that notifies of events relating to drawing-documents
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
vlr-docmanager-reactor | 309
DocManager reactor callback data
vlr-dwg-reactor
Constructs an editor reactor object that notifies of a drawing event (for example, open-
ing or closing a drawing file)
(e vent-name . callback_function)
Return Values
The reactor_object argument.
vlr-dwg-reactor | 311
DWG reactor callback data
:vlr-beginClose, 0
:vlr-databaseConstructed,
:vlr-databaseToBeDestroyed
vlr-dxf-reactor
Constructs an editor reactor object that notifies of an event related to reading or writing
a DXF file
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
:vlr-beginDxfIn, 0
:vlr-abortDxfIn,
:vlr-dxfInComplete,
:vlr-beginDxfOut,
:vlr-abortDxfOut,
:vlr-dxfOutComplete
vlr-editor-reactor
Constructs an editor reactor object
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
vlr-editor-reactor | 313
callbacks A list of pairs of the following form:
(e vent-name . callback_function)
Return Values
The reactor_object argument.
:vlr-lispEnded, 0
:vlr-lispCancelled,
:vlr-beginClose,
:vlr-beginDxfIn,
:vlr-abortDxfIn,
:vlr-dxfInComplete,
:vlr-beginDxfOut,
:vlr-abortDxfOut,
:vlr-dxfOutComplete,
:vlr-databaseToBeDestroyed
vlr-editor-reactor | 315
Editor reactor callback data (continued)
:vlr-beginSave 1 A string containing the default file name for save; this
may be changed by the user.
:vlr-saveComplete 1 A string identifying the actual file name used for the
save.
vlr-insert-reactor
Constructs an editor reactor object that notifies of an event related to block insertion
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
vlr-insert-reactor | 317
Insert reactor callback data
vlr-linker-reactor
Constructs a reactor object that notifies your application every time an ObjectARX appli-
cation is loaded or unloaded
Arguments
data Any AutoLISP data to be associated with the reactor
object.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
Name Event
Examples
_$ (vlr-linker-reactor nil
'((:vlr-rxAppLoaded . my-vlr-trace-reaction)))
#<VLR-Linker-Reactor>
vlr-lisp-reactor
Constructs an editor reactor object that notifies of a LISP event
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
vlr-lisp-reactor | 319
symbol representing a function to be called when the
event fires. Each callback function accepts two arguments:
Return Values
The reactor_object argument.
:vlr-lispEnded, 0
:vlr-lispCancelled
vlr-miscellaneous-reactor
Constructs an editor reactor object that does not fall under any other editor reactor
types
(e vent-name . callback_function)
Return Values
The reactor_object argument.
:vlr-pickfirstModified 0
vlr-miscellaneous-reactor | 321
vlr-mouse-reactor
Constructs an editor reactor object that notifies of a mouse event (for example, a double-
click)
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
vlr-notification
Determines whether or not a reactor will fire if its associated namespace is not active
(vlr-notification reactor)
Arguments
reactor A VLR object.
Return Values
A symbol, which can be either 'all-documents (the reactor fires whether or
not its associated document is active), or 'active-document-only (the reac-
tor fires only if its associated document is active).
vlr-object-reactor
Constructs an object reactor object
The reactor object is added to the drawing database, but does not become
persistent.
Arguments
owners An AutoLISP list of VLA-objects identifying the drawing
objects to be watched.
vlr-notification | 323
callbacks A list of pairs of the following form:
(e vent-name . callback_function)
Return Values
The reactor_object argument.
Object events
Name Event
Name Event
:vlr-unappended The object has been detached from the drawing database.
:vlr-cancelled 0
:vlr-erased,
:vlr-unerased
:vlr-goodbye
:vlr-openedForModify
:vlr-modified
:vlr-modifyUndone
:vlr-modifiedXData
:vlr-unappended
:vlr-reappended
:vlr-objectClosed
Examples
The following code attaches an object reactor to the myCircle object. It
defines the reactor to respond whenever the object is modified ( :vlr-modi-
fied) and to call the print-radius function in response to the modification
event:
(setq circleReactor (vlr-object-reactor (list myCircle)
"Circle Reactor" '((:vlr-modified . print-radius))))
vlr-object-reactor | 325
vlr-owner-add
Adds an object to the list of owners of an object reactor
Arguments
reactor A VLR object.
Return Values
The VLA-object to which the reactor has been added.
Examples
In the following example, an arc object named “archie” is added to the owner
list of reactor circleReactor:
_$ (vlr-owner-add circleReactor archie)
#<VLA-OBJECT IAcadArc 03ad0bcc>
vlr-owner-remove
Removes an object from the list of owners of an object reactor
Arguments
reactor A VLR object.
Return Values
The VLA-object from which the reactor was removed.
vlr-owners
Returns the list of owners of an object reactor
(vlr-owners reactor)
Arguments
reactor A VLR object.
Return Values
A list of objects that notify the specified reactor.
Examples
_$ (vlr-owners circleReactor)
(#<VLA-OBJECT IAcadCircle 01db98f4> #<VLA-OBJECT IAcadCircle
01db9724> #<VLA-OBJECT IAcadCircle 01db93d4> #<VLA-OBJECT
IAcadCircle 01db9084>)
vlr-pers
Makes a reactor persistent
(vlr-pers reactor)
Arguments
reactor A VLR object.
Return Values
The specified reactor object, if successful, nil otherwise.
Examples
Define a reactor:
_$ (setq circleReactor (vlr-object-reactor
vlr-owners | 327
(list myCircle) "Radius size" '((:vlr-modified . print-radius))))
#<VLR-Object-Reactor>
vlr-pers-list
Returns a list of persistent reactors in the current drawing document
(vlr-pers-list [reactor])
Arguments
reactor-type The reactor object to be listed. If reactor is not specified,
vlr-pers-list lists all persistent reactors.
Return Values
A list of reactor objects.
Examples
_$ (vlr-pers-list)
(#<VLR-Object-Reactor> #<VLR-Object-Reactor>
(#<VLR-Object-Reactor>)
vlr-pers-p
Determines whether or not a reactor is persistent
(vlr-pers-p reactor)
Arguments
reactor A VLR object.
Return Values
The specified reactor object, if it is persistent; nil, if the reactor is transient.
Examples
Make a reactor persistent:
_$ (vlr-pers circleReactor)
#<VLR-Object-Reactor>
vlr-pers-release
Makes a reactor transient
(vlr-pers-release reactor)
Arguments
reactor VLR object.
Return Values
The specified reactor object, if successful, nil otherwise.
vlr-reaction-names
Returns a list of all possible callback conditions for this reactor type
(vlr-reaction-names reactor-type)
Arguments
reactor-type One of the following symbols:
:VLR-AcDb-Reactor
:VLR-Command-Reactor
:VLR-DeepClone-Reactor
:VLR-DocManager-Reactor
:VLR-DWG-Reactor
:VLR-DXF-Reactor
:VLR-Editor-Reactor
:VLR-Insert-Reactor
vlr-pers-release | 329
:VLR-Linker-Reactor
:VLR-Lisp-Reactor
:VLR-Miscellaneous-Reactor
:VLR-Mouse-Reactor
:VLR-Object-Reactor
:VLR-SysVar-Reactor
:VLR-Toolbar-Reactor
:VLR-Undo-Reactor
:VLR-Wblock-Reactor
:VLR-Window-Reactor
:VLR-XREF-Reactor
Return Values
A list of symbols indicating the possible events for the specified reactor type.
Examples
_$ (vlr-reaction-names :VLR-Editor-Reactor)
(:vlr-unknownCommand :vlr-commandWillStart :vlr-commandEnded....
vlr-reaction-set
Adds or replaces a callback function in a reactor
Arguments
reactor A VLR object.
Return Values
Unspecified.
Examples
The following command changes the circleReactor reactor to call the
print-area function when an object is modified:
(vlr-reactions reactor)
Arguments
reactor A VLR object.
Examples
_$ (vlr-reactions circleReactor)
((:vlr-modified . PRINT-RADIUS))
vlr-reactors
Returns a list of existing reactors
(vlr-reactors [reactor-type...])
Arguments
reactor-type One or more of the following symbols:
:VLR-AcDb-Reactor
:VLR-Command-Reactor
:VLR-DeepClone-Reactor
:VLR-DocManager-Reactor
:VLR-DWG-Reactor
:VLR-DXF-Reactor
:VLR-Editor-Reactor
:VLR-Insert-Reactor
:VLR-Linker-Reactor
:VLR-Lisp-Reactor
:VLR-Miscellaneous-Reactor
:VLR-Mouse-Reactor
:VLR-Object-Reactor
:VLR-SysVar-Reactor
:VLR-Toolbar-Reactor
:VLR-Undo-Reactor
:VLR-Wblock-Reactor
:VLR-Window-Reactor
:VLR-XREF-Reactor
vlr-reactions | 331
If you specify reactor-type arguments, vlr-reactors returns lists of the reactor
types you specified. If you omit reactor-type, vlr-reactors returns all existing
reactors.
Return Values
A list of reactor lists, or nil, if there are no reactors of any specified type. Each
reactor list begins with a symbol identifying the reactor type, followed by
pointers to each reactor of that type.
Examples
List all reactors in a drawing:
_$ (vlr-reactors)
((:VLR-Object-Reactor #<VLR-Object-Reactor>) (:VLR-Editor-Reactor
#<VLR-Editor-Reactor>))
vlr-remove
Disables a reactor
(vlr-remove reactor)
Arguments
reactor A VLR object.
Return Values
The reactor argument, or nil, if unsuccessful.
vlr-remove-all
Disables all reactors of the specified type
(vlr-remove-all [reactor-type])
Arguments
reactor-type One of the following symbols:
:VLR-AcDb-Reactor
:VLR-Command-Reactor
:VLR-DeepClone-Reactor
:VLR-DocManager-Reactor
:VLR-DWG-Reactor
:VLR-DXF-Reactor
:VLR-Editor-Reactor
:VLR-Insert-Reactor
:VLR-Linker-Reactor
:VLR-Lisp-Reactor
:VLR-Miscellaneous-Reactor
:VLR-Mouse-Reactor
:VLR-Object-Reactor
:VLR-SysVar-Reactor
:VLR-Toolbar-Reactor
:VLR-Undo-Reactor
:VLR-Wblock-Reactor
:VLR-Window-Reactor
:VLR-XREF-Reactor
If no reactor-type is specified, vlr-remove-all disables all
reactors.
vlr-remove-all | 333
Return Values
A list of lists. The first element of each list identifies the type of reactor, and
the remaining elements identify the disabled reactor objects. The function
returns nil if there are no reactors active.
Examples
The following function call disables all editor reactors:
_$ (vlr-remove-all :vlr-editor-reactor)
((:VLR-Editor-Reactor #<VLR-Editor-Reactor>))
vlr-set-notification
Defines whether or not a reactor’s callback function will execute if its associated
namespace is not active
Arguments
reactor A VLR object.
Return Values
The VLR object.
Examples
Set a reactor to execute its callback function even if its associated namespace
is not active:
_$ (vlr-set-notification circleReactor 'all-documents)
#<VLR-Object-Reactor>
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
vlr-sysvar-reactor | 335
SysVar reactor callback data
vlr-toolbar-reactor
Constructs an editor reactor object that notifies of a change to the bitmaps in a toolbar
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
vlr-trace-reaction
A pre-defined callback function that prints one or more callback arguments in the Trace
window
(vlr-trace-reaction)
This function can be used as a debugging tool to verify that a reactor has
fired.
Examples
Define a command reactor and assign vlr-trace-reaction as the callback
function:
_$ (VLR-Reaction-Set (VLR-Command-Reactor) :VLR-commandWillStart
'VLR-trace-reaction)
VLR-trace-reaction
vlr-trace-reaction | 337
Respond to the command prompts, then activate the VLISP window and
open the Trace window. You should see the following in the Trace window:
; "Reaction": :VLR-commandWillStart; "argument list":
(#<VLR-COMMAND-REACTOR> ("LINE"))
The output from vlr-trace-reaction identifies the type of trigger event, the
reactor type, and the command that triggered the reactor.
vlr-type
Returns a symbol representing the reactor type
(vlr-type reactor)
Arguments
reactor A VLR object.
Return Values
A symbol identifying the reactor type. The following table lists the types that
may be returned by vlr-type:
Reactor types
:VLR-Miscellaneous-Reactor An editor reactor that does not fall under any of the
other editor reactor types.
Examples
$ (vlr-type circleReactor)
:VLR-Object-Reactor
vlr-types
Returns a list of all reactor types
(vlr-types)
Return Values
(:VLR-Linker-Reactor :VLR-Editor-Reactor :VLR-AcDb-Reactor ....)
vlr-types | 339
vlr-undo-reactor
Constructs an editor reactor object that notifies of an undo event
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
vlr-undo-reactor | 341
Undo reactor callback data (continued)
vlr-wblock-reactor
Constructs an editor reactor object that notifies of an event related to writing a block
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
vlr-wblock-reactor | 343
Wblock reactor callback data (continued)
vlr-window-reactor
Constructs an editor reactor object that notifies of an event related to moving or sizing
an AutoCAD window
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
vlr-window-reactor | 345
vlr-xref-reactor
Constructs an editor reactor object that notifies of an event related to attaching or mod-
ifying XREFs
Arguments
data Any AutoLISP data to be associated with the reactor
object, or nil, if no data.
(e vent-name . callback_function)
Return Values
The reactor_object argument.
vlr-xref-reactor | 347
XREF reactor callback data
vlr-xref-reactor | 349
XREF reactor callback data (continued)
vlr-xref-reactor | 351
XREF reactor callback data (continued)
vports
Returns a list of viewport descriptors for the current viewport configuration
(vports)
Return Values
One or more viewport descriptor lists consisting of the viewport identifica-
tion number and the coordinates of the viewport’s lower-left and upper-right
corners.
If the AutoCAD TILEMODE system variable is set to 1 (on), the returned list
describes the viewport configuration created with the AutoCAD VPORTS com-
mand. The corners of the viewports are expressed in values between 0.0 and
1.0, with (0.0, 0.0) representing the lower-left corner of the display screen’s
graphics area, and (1.0, 1.0) the upper-right corner. If TILEMODE is 0 (off), the
returned list describes the viewport objects created with the MVIEW com-
mand. The viewport object corners are expressed in paper space coordinates.
Viewport number 1 is always paper space when TILEMODE is off.
Given four equal-sized viewports located in the four corners of the screen
when TILEMODE is on, the vports function might return the following lists:
((5 (0.5 0.0) (1.0 0.5))
(2 (0.5 0.5) (1.0 1.0))
(3 (0.0 0.5) (0.5 1.0))
(4 (0.0 0.0) (0.5 0.5)) )
The current viewport’s descriptor is always first in the list. In the previous
example, viewport number 5 is the current viewport.
wcmatch
Performs a wild-card pattern match on a string
Arguments
string A string to be compared. The comparison is case-sensitive,
so upper- and lowercase characters must match.
wcmatch | 353
Return Values
If string and pattern match, wcmatch returns T, otherwise , wcmatch returns
nil.
Wild-card characters
Character Definition
Examples
The following command tests a string to see if it begins with the character N:
Command: (wcmatch "Name" "N*")
T
The following example performs three comparisons. If any of the three pat-
tern conditions is met, wcmatch returns T. In this case the tests are: does the
string contain three characters; does the string not contain an m; and does the
string begin with the letter " N." If any of the three pattern conditions is met,
wcmatch returns T:
Both the C and AutoLISP programming languages use the backslash (\) as an
escape character, so you need two backslashes (\\) to produce one backslash
in a string. To test for a backslash character anywhere in "Name", use the fol-
lowing function call:
Command: (wcmatch "Name" "*`\\*")
nil
The closing bracket character ("]") is also read literally if it is the first brack-
eted character or if it follows a leading tilde (as in "[ ]ABC]" or "[~]ABC]").
wcmatch | 355
while
Evaluates a test expression, and if it is not nil, evaluates other expressions; repeats this
process until the test expression evaluates to nil
Arguments
testexpr The expression containing the test condition.
Return Values
The most recent value of the last expr.
Examples
The following code calls user function some-func ten times, with test set to
1 through 10. It then returns 11, which is the value of the last expression
evaluated:
(setq test 1)
(while (<= test 10)
(some-func test)
(setq test (1+ test))
)
write-char
Writes one character to the screen or to an open file
Arguments
num The decimal ASCII code for the character to be written.
Return Values
The num argument.
Assuming that f is the descriptor for an open file, the following command
writes the letter C to that file:
Command: (write-char 67 f)
67
Note that write-char cannot write a NULL character (ASCII code 0) to a file.
write-line
Writes a string to the screen or to an open file
Arguments
string A string.
Return Values
The string , quoted in the normal manner. The quotes are omitted when writ-
ing to a file.
Examples
Open a new file:
Command: (setq f (open "c:\\my documents\\new.tst" "w"))
#<file "c:\\my documents\\new.tst">
The line is not physically written until you close the file:
Command: (close f)
nil
write-line | 357
xdroom
Returns the amount of extended data (xdata) space that is available for an object (entity)
(xdroom ename)
Because there is a limit (currently, 16 kilobytes) on the amount of extended
data that can be assigned to an entity definition, and because multiple appli-
cations can append extended data to the same entity, this function is pro-
vided so an application can verify there is room for the extended data that it
will append. It can be called in conjunction with xdsize, which returns the
size of an extended data list.
Arguments
ename An entity name (ename data type).
Return Values
An integer reflecting the number of bytes of available space. If unsuccessful,
xdroom returns nil.
Examples
The following example that looks up the available space for extended data of
a viewport object:
Command: (xdroom vpname)
16162
In this example, 16,162 bytes of the original 16,383 bytes of extended data
space are available, meaning that 221 bytes are used.
xdsize
Returns the size (in bytes) that a list occupies when it is linked to an object (entity) as
extended data
(xdsize lst)
Arguments
lst A valid list of extended data that contain an application
name previously registered with the use of the regapp
function. See the “Examples” section of this function for
lst examples.
Brace fields (group code 1002) must be balanced. An invalid lst generates an
error and places the appropriate error code in the ERRNO variable. If the
extended data contains an unregistered application name, you see this error
message (assuming that CMDECHO is on):
Examples
The lst can start with a –3 group code (the extended data sentinel), but it is
not required. Because extended data can contain information from multiple
applications, the list must have a set of enclosing parentheses.
(-3 ("MYAPP" (1000 . "SUITOFARMOR")
(1002 . "{")
(1040 . 0.0)
(1040 . 1.0)
(1002 . "}")
)
)
Here is the same example without the –3 group code. This list is just the cdr
of the first example, but it is important that the enclosing parentheses are
included:
( ("MYAPP" (1000 . "SUITOFARMOR")
(1002 . "{")
(1040 . 0.0)
(1040 . 1.0)
(1002 . "}")
)
)
zerop
Verifies that a number evaluates to zero
(zerop number)
Arguments
number A number.
Return Values
T if number evaluates to zero, otherwise nil.
zerop | 359
Examples
Command: (zerop 0)
T
Command: (zerop 0.0)
T
Command: (zerop 0.0001)
nil
In This Appendix
22
AutoCAD commands defined by ObjectARX or ■ Render
■ Geom3d
AutoLISP applications are called externally defined.
■ GeomCal
AutoLISP applications may need to access externally ■ AcadPS
functionality.
361
3dsin
Imports a 3D Studio (.3ds) file (Externally-defined: render ARX application)
Arguments
mode An integer that specifies whether the command is to be
used interactively (mode = 1) or noninteractively ( mode =
0).
Examples
Open the 3D Studio file globe.3ds for import and prompt the user for import
specifics:
(c:3dsin 1 "globe.3ds")
Import all of shadow.3ds with no user input, splitting objects with multiple
materials and putting all new objects on the same layer:
3dsout
Exports a 3D Studio file (Externally-defined: render ARX application)
Arguments
sset A selection set containing the AutoCAD objects to export.
3dsout | 363
0, welding is disabled; if set to a value greater than or
equal to 0, AutoCAD welds vertices closer than this value.
Examples
Export all of a drawing, creating 3D Studio objects based on drawing layer,
using a smoothing threshold of 30 degrees and a welding distance of 0.1:
(c:3dsout (ssget "X") 0 0 30 0.1 "testav.3ds")
align
Translates and rotates objects, allowing them to be aligned with other objects (Exter-
nally-defined: geom3d ARX application)
Arguments
arg1 arg2... Arguments to the AutoCAD align command. The order,
number, and type of arguments for the align function are
the same as if you were entering ALIGN at the command
line.
Return Values
T if successful, otherwise nil.
Examples
The following example specifies two pairs of source and destination points,
which perform a 2D move:
(setq ss (ssget))
(align ss s1 d1 s2 d2 "" "2d")
(c:cal expression)
Arguments
expression A quoted string. Refer to CAL in the Command Reference for
a description of allowable expressions.
Return Values
The result of the expression.
Examples
The following example uses cal in an AutoLISP expression with the trans
function:
(trans (c:cal "[1,2,3]+MID") 1 2)
fog
Adds distance from the view (Externally-defined: render ARX application)
Arguments
enabled A string that turns fog on and off without affecting other
settings. Default is ON.
near_dist A real number defining where the fog starts. Default is 0.0.
far_dist A real number defining where the fog ends. Default is 1.0.
cal | 365
background A string that applies fog to the background as well as to
the geometry. Default is OFF (do not apply fog to the
background).
With the FOG command, you can provide visual information about the
distance of objects from the view’s eye. To maximize fog, add white to an
image; to maximize depth cueing, add black.
light
Creates, modifies, and deletes lights and lighting effects (Externally-defined: render ARX
application)
Arguments
mode A string indicating the action to be performed. Allowable
mode values are:
A Set or retrieve ambient light intensity
options The options allowed depend on the mode and are listed
separately for each mode.
Arguments
intensity A real number from 0.0 to 1.0; if intensity is omitted, it
defaults to 1.0.
Examples
To set ambient light intensity to 0.6, issue the following:
Command: (c:light "A" 0.6)
1
To retrieve the current ambient light intensity, omit the intensity argu-
ment:
Command: (c:light "A")
(0.6 (1.0 1.0 1.0))
The intensity returned is 0.6, and the color is 1.0 1.0 1.0.
D—Delete Lights
Delete existing lights.
Arguments
name A string specifying the name of the light to delete.
Examples
The following function call deletes a light named "OLDLGT":
(c:light "D" "OLDLGT")
L—List Lights
List all lights in the drawing or return a definition of the specified light.
light | 367
Arguments
name A string specifying the name of the light to list. If you
omit the name argument, c:light returns a list of all the
lights defined in the drawing.
Examples
The following command lists all lights defined in the current drawing:
Command: (c:light "L")
("BUDLIGHT" "LIGHT01")
M—Modify Lights
Modifies existing lights.
Arguments
The arguments for the Modify mode are described in the following table:
light | 369
The hotspot and falloff arguments apply only to spotlights. You must pass
them as nil when you create a new distant light.
You can specify nil for any argument that does not apply to the type of light
you are modifying, or if you want the property affected by the argument to
retain its current value. You can omit any arguments located at the end of the
argument list (for example, attenuation, or attenuation and timezone, or atten-
uation, timezone, and longitude...).
Examples
The following code changes the color of the distant light named " D1" to blue:
(c:light "M" "D1" nil nil nil '(0.0 0.0 1.0))
Arguments
The arguments for the New Distant Light mode are described in the
following table:
light | 371
NP—New Point Light
Create a new point light.
Arguments
The arguments for the New Point Light mode are described in the following
table:
NEWPT1 would have the default intensity, the current attenuation setting,
the default location looking at the current view, and the default color of
white.
NOTE For point lights, the default maximum intensity depends on the current
point/spotlight attenuation setting. With no attenuation, it is 1.00; with inverse
linear attenuation, it is twice the drawing's maximum extents distance; and with
inverse square attenuation, it is the square of twice the maximum extents dis-
tance.
NS—New Spotlight
Creates a new spotlight.
Arguments
The arguments for the New Spotlight mode are described in the following
table:
light | 373
LIGHT—"NS" mode arguments (continued)
Examples
The following code creates a new spotlight named "GSPOT":
Command: (c:light "NS" "GSPOT" 43.82 '(12.0 6.0 24.0) '(78.0 78.0
24.0) nil nil 30.0 32.0)
1
GSPOT is a spotlight with an intensity of 43.82. Its color is the default (white).
The spotlight’s location is (12,6,24), and its target is (78,78,24). Its cone is 32
degrees wide, with a hotspot of 30 degrees.
NOTE For spotlights, the default maximum intensity depends on the current
point/spotlight attenuation setting. With no attenuation, it is 1.00; with inverse
linear attenuation, it is twice the drawing's maximum extents distance; and with
inverse square attenuation, it is the square of twice the maximum extents dis-
tance.
Arguments
old_name A string specifying the name of the light to rename.
Examples
Command: (c:light "R" "GSPOT" "HOTSPOT")
1
lsedit
Creates or modifies landscape objects (Externally-defined: render ARX application)
Arguments
The arguments for the LSEDIT com mand are described in the following table:
LSEDIT arguments
lsedit | 375
LSEDIT arguments (continued)
height REAL Height of the object in drawing units. If nil, the None
current value is unchanged.
position LIST The position of the base of the object. If nil, the None
(of reals) current value is unchanged.
Examples
Modify a landscape object, where <ename> is the AutoCAD name (entsel) of
the object to modify; leave alignment unchanged:
(c:lsedit <ename> 35.0 ’(10.0 23.0) nil)
lslib
Manages the landscape library (Externally-defined: render ARX application)
Arguments
mode The mode arguments can be one of the following:
Arguments
name A string naming the entry in the landscape library.
Examples
Add an entry called "Maple tree" to the current landscape library:
(c:lslib "ADD" "Maple tree" "maple.tga" "mapleo.tga" 0)
DELETE
Remove an entry from the current library.
Arguments
name A string naming the entry in the landscape library.
Examples
Remove the entry called "Maple tree" from the current landscape library:
(c:lslib "delete" "Maple tree")
MODIFY
lslib | 377
Change an entry in the current library. The texture-map, opacity-map , and
alignment arguments can be passed as nil, in which case the value is
unchanged.
Arguments
name A string naming the entry in the landscape library.
Examples
Change the "Maple tree" to be non-view-aligned with crossing faces:
(c:lslib "MODIFY" "Maple tree" nil nil 2)
OPEN
Open a new library and make it the current library.
Arguments
name A string naming the landscape library to open.
Examples
Open the TREES.LLI file and make it the current landscape library:
(c:lslib "OPEN" "TREES.LLI")
SAVE
Save the current landscape library as the named file.
Examples
Save the file as TREES.LLI:
(c:lslib "SAVE" "TREES.LLI")
LIST
Lists all the elements in the current library. This command takes no argu-
ments. The list includes landscape entries of the form ’("NAME" "TEX-MAP"
"OP-MAP" ALIGN).
(c:lslib "LIST")
Examples
The following illustrates output from the LIST option:
(("Bush #1" "8bush02l.tga" "8bush02o.tga" 0)
("Cactus" "8plnt15l.tga" "8plnt15o.tga" 0)
("Dawn Redwood" "8tree39l.tga" "8tree39o.tga" 0))
lsnew
Create landscape objects (Externally-defined: render ARX application)
Arguments
object-type A string naming the landscape library entry.
lsnew | 379
alignment An integer specifying the geometry and alignment of the
entry. Can be one of the following:
Examples
Create a new instance of "Cactus" that is 25 units tall, located at 0, 1, 3, and
has a single non-view-aligned face.
Command: (c:lsnew "Cactus" 25.0 '(0.0 1.0 3.0) 1)
1
matlib
Manages materials libraries (Externally-defined: render ARX application)
Arguments
mode A string that specifies the action that this function
performs. Can be one of the following:
mirror3d
Reflects selected objects about a user-specified plane (Externally-defined: geom3d ARX
application)
Arguments
The order, number, and type of arguments for the mirror3d function are the
same as if you were entering the MIRROR3D AutoCAD command. To signify a
user pressing ENTER without typing any values, use nil or an empty string
( "" ).
Return Values
T if successful, otherwise nil.
Examples
The following example mirrors the selected objects about the XY plane that
passes through the point 0,0,5, and then deletes the old objects:
(setq ss (ssget))
(mirror3d ss "XY" '(0 0 5) "Y")
psdrag
Controls the appearance of an imported PostScript image while it is being dragged into
position by the PSIN command (Externally-defined: acadps ARX application)
(c:psdrag mode)
mirror3d | 381
Arguments
mode An integer that should equal either 0 or 1. The current
value of PSDRAG affects interactive use of the PSIN
command. If PSDRAG is 1, PSIN generates the PostScript
image as the user drags it to scale it. If PSDRAG is 0, PSIN
generates and drags only the bounding box of the image.
Return Values
If successful, the c:psdrag function returns the old value of PSDRAG; if
c:psdrag fails, it returns nil.
Examples
The following code turns on PSDRAG by setting it to 1. The next interactive
invocation of PSIN generates the PostScript image as the user drags it during
scaling.
(c:psdrag 1)
psfill
Fills a two-dimensional polyline outline with a PostScript fill pattern (Externally-defined:
acadps ARX application)
Arguments
ent The name of the polyline.
Return Values
If successful, c:psfill returns T; if it fails, it returns nil.
PostScript fills are stored in drawing files as extended data and are identified
by the application name AUTOCAD_POSTSCRIPT_FIGURE.
psin
Imports a PostScript file (Externally-defined: acadps ARX application)
Arguments
filename A string that contains the name of the PostScript image.
You don’t have to specify the . eps file name extension.
Return Values
If successful, c:psin returns the name of the newly created object; if it fails,
it returns nil.
Examples
The following code imports a PostScript file called sample.eps, inserts it at
(24,19), and scales it with a factor of 25:
(c:psin "sample" ’(24 19) 25)
PostScript images are stored in drawing files as extended data and are identi-
fied by the application name AUTOCAD_POSTSCRIPT_FIGURE.
psin | 383
render
Creates a realistically shaded image of a 3D wireframe model using geometry, lighting,
and surface finish information (Externally-defined: render ARX application)
Arguments
filename A string naming a rendering file.
The rendering is controlled by the current settings; set these by using the
c:rpref function. For example:
NOTE When the current rendering preferences specify Query for Selection and
the PICKFIRST system variable is turned on, then if a selection set is current when
you invoke c:render, the objects in the set are rendered with no further
prompting.
RFILEOPT arguments
TGA
Specifies the Targa format.
render | 385
Arguments
Examples
(C:RFILEOPT "TGA" 640 480 1.0 "C32" 1 "COMP" "UP")
PCX
Specifies the Z-Soft Bitmap format.
Arguments
Examples
(C:RFILEOPT "PCX" 640 480 1.0 "G8")
Arguments
PS
Specifies the PostScript format.
Arguments
PS format arguments
Examples
(C:RFILEOPT "PS" 640 480 1.0 "C24" "P" "C" 640)
render | 387
TIFF
Specifies the Tagged Image File format.
Arguments
Examples
(C:RFILEOPT "TIFF" 640 480 1.0 "C24")
renderupdate
Regenerate the ent2face file on the next rendering (Externally-defined: render ARX appli-
cation)
(c:renderupdate [RU_value])
Use the renderupdate command with no arguments to regenerate the
en2face file on the next rendering.
Arguments
RU_value A string specifying one of the following:
replay
Displays a BMP, TGA, or TIFF image (Externally-defined: render ARX application)
Arguments
filename A string naming the image file.
Examples
The following call replays an image named test.tga, displaying pixels starting
from the lower left of the image (zero offset) out to 500 pixels wide and 400
pixels in heights:
(c:replay "TEST" "TGA" 0 0 500 400)
rmat
Creates, edits, attaches, and detaches rendering materials (Externally-defined: render
ARX application)
rmat | 389
Arguments
mode A string. Can be one of the following:
A Attaches material
C Copies material
D Detaches material
L Lists all materials in the drawing or returns a definition
of the specified material
M Modifies material
N Creates new material
options The options allowed depend on the mode specified.
A—Attach Material
The "A" (attach) mode lets you attach a material to selected objects or an ACI
(AutoCAD Color Index) value, depending on whether the third argument
(layer-name) is an integer or a selection set.
Arguments
The following table describes the attach arguments.
Attach arguments
Examples
Attach the material PURPLE TIGER to the ACI 1 (red):
(c:rmat "A" "PURPLE TIGER" 1)
If you omit the third argument, the "A" mode returns a list of three items:
The following example illustrates the values returned when the third argu-
ment is omitted:
Command: (c:rmat "a" "twood")
Gathering objects…1 found
Layer names ACI’s
(("first" "second")(135) <Selection set 12>))
A material index value in the range 1–255 is an ACI number; an index greater
than 255 indicates an AutoCAD Render material not assigned by ACI.
C—Copy Material
Creates a new material by copying one already present in the drawing.
Arguments
cur_name A string that specifies the name of the material to copy.
new_name A string that specifies the name for the new material.
Examples
Modify a material to change its definition:
(c:rmat "C" "RED" "RED2")
D—Detach Material
The "D" (detach) mode lets you detach a material from selected objects, an
ACI (AutoCAD Color Index) value, or layers, depending on whether the sec-
ond argument ( selection-set) is an integer, a selection set, or a string.
Arguments
The following table describes the detach arguments.
Detach arguments
rmat | 391
Detach arguments (continued)
Examples
Prompt the user to select objects, and then detach each object from its mate-
rial:
(c:rmat "D" (ssget))
L—List Material
Lists material definitions in the drawing.
Arguments
name A string that specifies the material definition to list. If the
name argument is omitted, c:rmat lists all materials in the
drawing.
Examples
List all materials in the drawing:
Command: (c:rmat "L")
("*GLOBAL*" "BLUE GLASS" "WHITE PLASTIC" "TWOOD" "BEIGE MATTE")
The first string in the list specifies the default global material, *GLOBAL*. You
can pass this string to c:rmat just as you can pass the names of library or user-
defined materials, as demonstrated in the following example:
Command: (c:rmat "L" "*GLOBAL*")
("*GLOBAL*" "STANDARD" (-1.0 -1.0 -1.0) 0.7 ("" 0.0 0 (1.0 1.0) (0.0
0.0) 0.0 0 0) (-1.0 -1.0 -1.0) 0.1 (-1.0 -1.0 -1.0) 0.2 ("" 0.0 0)
0.5 0.0 ("" 0.0 0 (1.0 1.0) (0.0 0.0) 0.0 0 0) 1.0 ("" 0.0 0 (1.0
1.0) (0.0 0.0) 0.0 0 0))
The list items in a material definition are the same as the arguments to the
Modify or New modes.
For example, the following call changes BLUE MARBLE to have a medium
blue stone (matrix) color and black veins:
(c:rmat "M" "BLUE MARBLE" "marble" ’(0.5 0.5 1.0) ’(0.0 0.0 0.0))
N—New Material
The "N" (new) mode creates a new material. The arguments to this function
depend not only on the mode, but also on the type of m aterial you’re creat-
ing. The procedural materials: marble, granite, and wood, each have a unique
set of arguments, which differs from the standard m aterial arguments.
Arguments
The following table describes the new arguments:
New arguments
In addition, the arguments for each kind of bitmap are specified in a sublist
as described under “Bitmap Arguments” on page 399.
rmat | 393
Standard
The material type string "STANDARD" indicates you’re creating a new stan-
dard material.
Arguments
The following table describes the standard arguments:
Standard arguments
Examples
The following call creates a shiny red m aterial with a pattern map:
(c:rmat "N" "RED LACQUER" "STANDARD" ; Name and type
'(1.0 0.0 0.0) (1.0) ; Color (red), weight, and texture map
'("INLAY.TGA” 0.75 0 (0.5 0.5) (0.3 0.3) 0.0 0 1)
'(1.0 0.0 0.0) 1.0 ; Ambient color and its weight (same as diffuse)
'(1.0 0.0 0.0) 1.0 ; Reflection color (white) and its weight
nil ; No reflection map
0.2 ; Roughness (low)
0.0 ; Transparency (none)
nil ; No opacity map
0.0 ; Refraction (none)
nil ; No bump map
The next call creates a material, MAPS, that uses multiple bitmaps:
(c:rmat "N" "MAPS" "STANDARD"
'(1.0 0.0 0.0) (1.0) '("weave.tga" 1.0 0)
'(1.0 0.0 0.0) 1.0
'(1.0 0.0 0.0) 1.0 '("room.tga" 0.75)
0.5
0.0
'("hole.tga")
1.0
'("ridges.tga")
The following call creates a material with no bitmaps and default values, with
reflections that are generated by ray tracing when rendered with Photo Ray-
trace or with environment map with Photo Real:
(c:rmat "N" "SHINE" "STANDARD" nil nil nil nil nil nil nil
'(nil nil 1))
Marble
The material type string "MARBLE" indicates that you are creating a new
marble material.
rmat | 395
Arguments
The following table describes the m arble arguments:
RMAT—Marble arguments
stone-color LIST RGB value specifying the main (–1.0 –1.0 –1.0)—
(of reals) matrix color of the marble white
vein-color LIST RGB value specifying the vein (–1.0 –1.0 –1.0)—
(of reals) color of the marble black
Examples
The following call creates a marble with a pink matrix and black veins:
(c:rmat "N" "PINK MARBLE" "MARBLE" '(1.0 0.34 0.79))
Arguments
The following table describes the granite arguments:
RMAT—Granite arguments
rmat | 397
RMAT—Granite arguments (continued)
Examples
Create a granite without dark gray, with more black, and with yellow instead
of light gray:
(c:rmap "N" "YELLOW GRANITE"
nil 0.5 nil 0.0 nil 0.85 '(1.0 1.0 0.0) 0.6)
Wood
The material type string "WOOD" indicates that you’re creating a new wood
material.
Arguments
The following table describes the wood arguments:
RMAT—Wood arguments
light-color LIST RGB value specifying the color of (0.6 0.4 0.3)
(of reals) the light rings
dark-color LIST RGB value specifying the color of (0.3 0.2 0.2)—black
(of reals) the dark rings
Examples
Create a wood with an irregular grain:
(c:rmat "N" "CRYPTO" "WOOD" nil nil nil nil nil nil nil nil nil 0.56)
Bitmap Arguments
The arguments to specify a bitmap are passed to a list, which you can include
as a sublist in the c:rmat call (this is the form shown at the beginning of each
of the following sections) or assign to a symbol before you call c:rmat.
Pattern/Texture
rmat | 399
Arguments
The following table describes the pattern/texture arguments:
Pattern/Texture arguments
Reflection/Environment
Arguments
The following table describes the reflection/environment arguments:
Reflection/Environment arguments
Opacity
Arguments
The following table describes the opacity arguments:
Opacity arguments
rmat | 401
Opacity arguments (continued)
Bump Map
Bump arguments
Arguments
args The order, number, and type of arguments for the
rotate3d function are the same as if you were entering
them at the command line; see ROTATE3D in the Command
Reference for more information.
To signify a null response (user pressing ENTER without
specifying any arguments), use nil or an empty string
( "" ).
Return Values
If successful, rotate3d returns T; otherwise it returns nil.
Examples
The following example rotates the selected objects 30 degrees about the axis
specified by points p1 and p2.
(setq ss (ssget))
(rotate3d ss p1 p2 30)
AutoLISP support for the rotate3d function is implemented with the use of
the SAGET library.
rpref
Sets rendering preferences (Externally-defined: render ARX application)
rotate3d | 403
Arguments
mode A string that can be one of the following:
DEST—Destination Preference
Selects which output device is used.
Arguments
option A string that specifies the rendering destination. Can be
one of the following:
Examples
The following call specifies rendering to a file:
(c:rpref "DEST" "FILE")
ICON—Icon Preference
Specifies the size of the light or material icon block in a drawing.
Examples
The following function call changes the icon scale to 50 percent:
(c:rpref "ICON" 0.5)
Arguments
option A string that specifies the rendering type. Can be one of
the following:
Examples
The following code specifies that the next rendering will be generated by the
basic AutoCAD renderer.
(c:rpref "STYPE" "ARENDER")
SELECT—Selection Preference
Specifies whether to prompt for object selection before generating a
rendering.
Arguments
option A string that specifies the prompting. Can be one of the
following:
Examples
The following call sets rendering to prompt for object selection:
rpref | 405
(c:rpref "SELECT" "ASK")
TOGGLE—Toggle Preference
Controls various rendering options.
Arguments
option A string that specifies the prompting. Can be one of the
following:
Examples
The following calls turn off Merge rendering and turn on shadows:
(c:rpref "TOGGLE" "MERGE" "OFF")
(c:rpref "TOGGLE" "SMOOTH" "ON")
saveimg
Saves a rendered image to a file in BMP, TGA, or TIFF format (Externally-defined: render
ARX application)
Examples
The following example saves a full-screen TIFF image named test.tif, without
compressing the file:
(c:saveimg "TEST" "TIF" "NONE")
scene
Creates new scenes and modifies or deletes existing scenes in paper space only (Exter-
nally-defined: render ARX application)
scene | 407
Arguments
mode A string that can be one of the following:
D—Delete Scene
Deletes an existing scene.
Arguments
name A string that specifies the name of the scene to delete.
If the deleted scene is the current scene, *NONE* becomes the current scene.
Examples
(c:scene "D" "PLANVIEW")
L—List Scene
Lists all scenes in the drawing or returns a definition of the specified scene.
Arguments
name A string that specifies the name of the scene to list. If the
name argument is omitted, c:scene returns a list of all the
scenes defined in the drawing.
Return Values
When you specify name, c:scene returns the definition of the named scene.
Examples
The following code returns a list of scene names defined in the drawing.
The empty string ("") is the default scene, *NONE*, which can’t be modified.
M—Modify Scene
Modifies an existing scene.
NOTE You must pass the lights argument as a list even when you specify only
one light.
For example, the following call modifies a scene named SCENE1 to use the
named view FRONT and all the lights in the drawing:
N—New Scene
Creates a new scene.
Arguments
name A string that specifies the name of the new scene.
scene | 409
Examples
To create a new scene named DEFAULT using the *CURRENT* view and *ALL*
lights, issue the following function call:
(c:scene "N" "DEFAULT")
To create a new scene named DULL using the *CURRENT* view and the default,
“over-the-shoulder” lighting, use the following call:
(c:scene "N" "DULL" T nil)
To create a new scene named SPECIAL using the named view MY_VIEW and
the SUN, LAMP, and SPOT lights, issue the following function call:
(c:scene "N" "SPECIAL" "MY_VIEW" '("SUN" "LAMP "SPOT"))
R—Rename Scene
Renames a scene.
Arguments
old_name A string that specifies the name of the original scene.
new_name A string that specifies the new name for the scene.
Examples
Rename a scene from "SPECIAL" to "BRIGHT":
(c:scene "R" "SPECIAL" "BRIGHT")
S—Set Scene
Sets the current scene.
Arguments
old_name A string that specifies the name of the scene to make
current.
Return Values
If you omit the name argument, c:scene returns the name of the currently
selected scene.
Examples
Obtain the name of the currently selected scene:
To make SCENE3 the current scene, issue the following function call:
(c:scene "S" "SCENE3")
setuv
Assigns material mapping coordinates to selected objects. Its function has two modes,
specified by a string argument (Externally-defined: render ARX application)
Arguments
mode Mode can be one of the following strings:
A—Assign
The "A" (assign) mode assigns mapping coordinates.
Arguments
Arguments expected by this mode depend on whether you specify projection
or solid mapping. The assign arguments for projection mapping are
described in the following table:
setuv | 411
SETUV—"A" mode arguments for projection mapping (continued)
pt1, pt2, pt3 LIST Three points that define the mapping None
geometry:
Planar—lower-left corner, lower-right corner,
upper-left corner
Cylindrical—center bottom, center top,
direction toward the seam
Spherical—center of the sphere, radius
(north), direction toward the seam
For solid mapping, the option arguments specify only the mapping points.
These implicitly define the scale in the UVW dimensions. The assign argu-
ments for solid mapping are described in the following table:
ssname PICKSET The selection set that contains the objects None
to which you want to assign mapping
coordinates
Examples
The following function call assigns cylindrical mapping coordinates to an
object the user chooses, using tiling and the default scale and offset:
(c:setuv "A" (ssget) "C" ’(5.0 5.0 5.0) ’(5.0 5.0 10.0)
’(10.0 0.0 0.0) 1)
D—Detach
The "D" (detach) mode detaches the UV mapping assigned to the objects in
the selection set. These objects will now be mapped with the default map-
ping coordinates until you assign mapping coordinates again.
Arguments
ssname The selection set that contains the objects from which you
want to detach mapping coordinates
Examples
The following call prompts the user for entities that will be detached from
their mapping coordinates:
(c:setuv "D" (ssget))
showmat
Lists the material type and attachment method for a selected object (Externally-defined:
render ARX application)
(c:showmat arg1)
This function lists the material type and attachment method based on arg1.
Arguments
arg1 Can be an entity name, an integer representing an ACI
value, or a layer name (a string).
showmat | 413
solprof
Creates profile images of three-dimensional solids (Externally-defined: solids ARX appli-
cation
Arguments
args The order, number, and type of arguments are the same as
those specified when issuing SOLPROF at the Command
prompt; see SOLPROF in the Command Reference for further
information.
stats
Displays statistics for the last rendering (Externally-defined: render ARX application)
Arguments
filename | nil A string specifying the name of the file to save the
rendering information in, or nil to tell RENDER to stop
saving statistics. If you omit the file name, c:stats
displays the Statistics dialog box.
Examples
The following command writes statistics from your last rendering to the fig-
ures.txt file:
(c:stats "figures.txt")
The following command saves the information associated with the last ren-
dering to the stats.txt file, and also saves the information associated with the
following renderings to this file:
(c:stats "stats.txt")
3D applications, 35
distance between points , 63 applications
distance, specifying, 91 AppData section, 155
Object Snap mode, 140 connecting with ActiveX, 250, 266
points , 140 forcing to quit, 145
points in user coordinate system, 141 loading ObjectARX, 35
3D points naming, 149
ActiveX compatible, 247 ObjectARX, listing, 35
angles, specifying, 141 quitting, 79
distance, specifying, 141 separate-namespace VLX, 198
3DSIN command, 362 starting Windows applications , 177
3DSOUT command, 363 unloading ObjectARX, 36
using extended data, 149
A writing data, 155
absolute values , 25 application-specific data
acad.cfg, 155 overwriting in reactor objects, 306
AppData section, 89 in reactor objects , 305
ActiveX arctangents, measured in radians , 37
creating 3D points, 247 arrays
creating transformation matrices, 294 dimension boundaries of, 290
getting object properties, 267 returning end index of, 290
adding strings, active dialog box lists, 28 arrays. See safearrays , 288
ALIGN command, 364 ARX applications. See ObjectARX , 35
allocating memory, 30, 80 ASCII character code
AND, list of integers, 122 converting first character, 36
ANGBASE system variable, 159 converting to single characters, 47
angles keyboard input buffer, 147
converting from string to radian, 31 in open files , 147
converting to strings, 32 representing characters, 237
defined by two endpoints, 31 ASESQLED command, 365
measuring cosine in radians , 52 association lists
in radians , 97 returning list entries, 37
measured in radians, 88 searching, 37
sine of, 160 atoms
user input, 88 defined, 39
anonymous functions, defining, 116 and dotted lists , 220
antilogarithms, and real numbers , 79 verifying, 39
appending lists , 34 attributes, retrieving DCL values, 87
application objects AutoCAD commands, built-in command set,
creating new instance of, 250 248
returning running instance of, 266 AutoCAD documents, function availability, 206
application-handling functions, ObjectARX AutoCAD graphics screen, 101
417
AutoCAD status line,writing text to, 105 closing dialog boxes , 65
AutoLISP closing files , 48
accessing files with, 138 collections
evaluating expressions, 78 applying functions , 280
memory status , 125 evaluating, 265
version number, 197 colors
AutoLISP data, displaying as output from prin1, displaying colors , 26
227 selection dialog box , 26
AutoLISP data, displaying as output from princ, command events, and editor reactors, 304
228 command line
automatic loading of AutoLISP files , 42 printing expressions , 141, 143
automatic loading of ObjectARX files , 41 printing newlines , 188
command reactor events, (table), 305
B commands
backslash (\), control codes (table), 142 3DSIN, 362
base points, specifying distance, 91 3DSOUT, 363
beep sounds , 304 adding to AutoCAD, 248
bits, specifying to shift integers, 123 ALIGN, 364
blackboard namespace ASESQLED, 365
returning variable value from , 200 English name in AutoCAD, 89
setting variables, 200 executing in AutoCAD, 203
block references LIGHT, 366
attributes, selecting, 132 localized name in AutoCAD, 89
definition data , 132 LSEDIT, 375
selecting, 132 for menus, 127
with attributes, changing, 75 MIRROR3D, 381
with attributes, updating screen image, 75 PSDRAG, 381
blocks PSFILL, 382
inserting in editor reactors, 316 PSIN, 383
nested, 132 removing, 285
writing to , 342 RENDER, 384
Boolean, bitwise functions, 42 RENDERUPDATE, 388
boundaries, in safearrays , 289 REPLAY, 388
building applications RPREF, 403
making application modules SAVEIMG, 406
include text files, 219 SCENE, 407
built-in functions, 54 SETUV, 411
bytes, for file size, 215 SHOWMAT, 413
SOLPROF, 414
C common denominators, finding greatest, 86
comparison function
calibrations, digitizer coordinates, 183 in lists , 234, 235
callback functions complex objects, accessing definition data, 131
and inactive namespaces , 334 concatenating
printing arguments in Trace window, 337 expressions into lists, 118
replacing, 330 lists , 34
case conversions multiple strings , 180
lowercase, 179 conditionally evaluating expressions, 109
uppercase, 179 converting angles to radians, 31
character codes converting ename to VLA-object, 264
ASCII, 36 converting expressions, first in list, 146
ASCII representation, 237 converting integers
converting from strings, 236 ASCII to single character, 47
list, 220 to strings , 115
searching for ASCII, 239 converting numbers, real to smaller, 83
characters, quantity in strings , 181 converting strings
closing applications, forced quit, 79 integers, 39
418 | Index
real numbers , 38 adding, 135
converting values, units of measurement, 52 adding strings to active list, 28
converting VLA-object to ename, 300 attributes with DCL values, 87
coordinate systems closing, 65
transforming, 132 color selection, 26
translating points , 191 creating images , 178
coordinates, in text boxes, 188 displaying, 135
corners, user input for rectangles , 90 displaying error messages , 29
cosine, of angles, 52 ending active lists , 66
creating drawing objects (entities), 69 ending creation of images, 65
curves forcing display of, 110
closed, defined, 258 opening, 178
contained in planes, 259 pop-up lists , 179
creating inside area, 250 processing lists, 179
defining parameters , 251 remaining active, 178
finding nearest point, 260 slides, displaying, 161
first derivative, 261 specifying tiles , 27
infinite ranges, 258 terminating, 65
parameter of endpoints, 253 terminating current, 187
parameters at specified distance, 254 tile mode, setting, 130
parameters in World Coordinate System , tile values, setting, 155
255 unloading DCL files , 195
periodic, 258 warning message, 29
projecting onto planes, 261 dictionaries
second derivative, 262 accessing objects (entities), 131
segment length to parameter, 251 adding nongraphical objects , 57
segment length to selected point, 252 erasing LISP data , 271
specifying parameter value, 256 finding next item, 58
specifying point distance, 255 listing LISP data, 274
start parameter, 257 named objects , 131
WCS endpoints, 254 removing entries, 60
World Coordinate System start point, 257 renaming entries, 61
retrieving LISP data, 271
D searching items , 61
data types (list), 193 storing LISP data, 274
database reactors, creating, 302 DIESEL menu expressions, 129
DCL files digitizers, setting calibrations , 183
loading, 121 dimensions of arrays, determining, 290
unloading, 195 dimensions of safearrays, determining, 289
debugging dimensions, in safearrays, 288
trace function, 189 directories
untrace function, 195 file names, determining, 213
decrementing numbers, 25 listing all files, 206
deep cloning, reactor notification, 307 paths without file name and extension, 217
DeepClone reactor events, (table), 307 using path names , 213
deepclone reactors, creating, 307 distance, specifying points, 91
defining functions , 53 division, determining remainders , 150
as lists, 54 DocManager reactor events, (table), 309
definition data, of complex objects, 131 document reactors, creating, 308
definitions, retrieving data for objects (entities), dotted lists
67 and atoms , 220
defun-q, displaying defined function, 55 constructing, 51
deleting entities, 66 drawings
deleting files , 213 last nondeleted object (entity), 68
deleting objects , 66 paper space layouts, 117
delimiters, in multiple expressions, 146 DWG reactor events, (table), 311
dialog boxes dwg reactors, creating, 310
Index | 419
DXF reactor events, (table), 313 restoring deleted entities, 66
DXF reactors, creating, 312 retrieving definition data, 67
dynamic memory, defined, 125 retrieving LISP data, 271
returning next drawing entity, 73
E searching in symbol tables , 186
editor reactor events, (table), 314 selecting, 73, 131
editor reactors selecting for set, 175
attaching Xrefs, 346 specifying properties, 283
changes to system variables, 335 storing LISP data, 274
constructing, 313 top level in Auto CAD, 265
creating, 320 transforming to VLA-object, 264
inserting blocks, 316 transforming VLA-object to, 300
modifying AutoCAD windows , 344 TypeLib information, 295
modifying Xrefs, 346 undeleting, 66
notifying changes in toolbar bitmaps, 336 updating on screen, 74
notifying of command events, 304 environment variables
undo events, 340 defined, 92
writing to blocks, 342 returning value of, 92
elements spelling requirements, 156
last in list, 117 values, setting, 156
nth element of lists, 136 equality
quantity in lists, 118 between expressions , 21, 75, 76
removing from lists , 231 error messages
reversing in lists , 152 displaying in dialog boxes, 29
supplying as arguments for lists, 124 for quitting applications, 145
end-of-line markers, open files, 148 user-defined, 78
endpoints error trapping, 201
equal to start point in curves, 258 error-handling, user-defined function, 78
parameters in curves, 253 errors
endpoints, angle returned from, 31 intercepting, 201
entities VLX applications , 210
adding to selection sets, 164 evaluating expressions
assigning handles , 70 conditionally (if...), 109
complex, 131 no evaluation, 145
converting to VLA-object, 264 repetition specified, 151
converting VLA-object to, 300 repetitively, 356
creating in drawings , 69 sequentially, 144
creating new, 70 using EVAL function, 78
creating new instance, 266 evaluating lists, primary condition, 50
creating selection sets , 166 events, current within reactor’s callback, 305
deleting, 66 executing commands, in AutoCAD, 49
deleting from selection sets, 166 exponents, specifying power, 81
determining if readable, 285 expressions
erasing, 264 concatenating, 118
extended data, 149 determining whether equal, 76
gripping, 175 determining whether identical, 75
handles , 107 evaluating repetitively, 356
identifying symbols , 244 evaluating with if, 109
in selection sets, 171 last evaluated, 144
last nondeleted, 68 printing to command line, 141 , 143
linking as extended data, 358 re-evaluation, specified, 151
modifying definition data, 71 writing to files, 141, 143
naming, 70 extended data
nested, 75 functions , 358
nongraphical, accessing, 131 naming applications , 149
number in selection set, 170 external subroutines, symbols , 198
releasing in drawings, 285
420 | Index
F G
FAS files, compiling source code, 300 garbage collection, 86
files graphics
acad.cfg, 89, 155 screen displayed in AutoCAD, 101
appending between files , 212 vectors in dialog box images, 196
closing, 48 graphics screen
copying between files , 212 switching to text screen, 189
deleting, 213 vectors, drawing, 106
end-of-line marker, 148
file names, user input, 92 H
listing in directories, 206 handles
loading, 120 creating new objects (entities), 70
loading DCL, 121 naming objects (entities), 107
loading in AutoCAD, 223 height of tiles, retrieving in dialog box units, 63
naming temporary files, 218 help
naming with extension only, 217 invoking, 27 , 108
naming without directory or extension, 216 topic requests , 156
opening, 138 user-defined command, 156
renaming, 214 help facility. See help
searching library paths, 82
size in bytes , 215 I
time of last modification, 215
images
writing characters, 356
creating in dialog boxes, 178
writing expressions, 141, 143
displaying slides , 161
writing strings, 357
ending creation in dialog boxes , 65
filled rectangles, drawing in dialog box , 81
updating of screen, 74
find. See search
vectors in dialog boxes , 196
Flip Screen function key, 189
importing data, from type libraries , 268
floating point values, converting angles from
importing functions
strings to , 31
ADS-DEFUN, 198
floating point, converting to real values, 64
from ObjectARX, 198
forcing an application to quit, 145
incrementing numbers , 25
forcing display of dialog boxes , 110
index of list element, determining, 226
freeing memory, 86
infinite ranges, in curves , 258
function calls, keywords, 111
input devices, reading from AutoCAD, 102
functions
input,restricting users, 111
anonymous, defining, 116
insert reactor events, (table), 317
applying to objects , 280
integers
AutoLISP I/O, 138
converting from real numbers, 83
availability in AutoCAD documents, 206
converting from strings, 39
Boolean, bitwise, 42
converting to strings, 115, 152
built-in, 54
largest in list, 125
defining, 53
limits for user input, 95
defining as lists, 54
list using bitwise AND, 122
displaying list structures , 55
list using bitwise OR, 123
error-handling, 78
lists combining characters, 220
executing, 34
quantity of string characters , 181
exported by VLX, 221
range of values, 95
extended data-handling, 358
shifting by specifying bits, 123
importing applications, 198
smallest in list, 129
importing into VLX namespace, 207
verifying, 137
invoking VLX, 211
intercepting errors, 201
loading Visual LISP extensions to AutoLISP,
intersections, for lines , 114
224
setting symbols defined in lists , 56
K
keywords
Index | 421
functions for, 111 for ObjectARX commands , 41
methods for abbreviating, 113 recursion, 120
user input, 96 loading menugroups, 129
loading Visual Basic projects, 246
L logical bitwise AND, 122
library paths, searching for files, 82 logical bitwise OR, 123
LIGHT command, 366 logical OR of expression, 139
lines, angle of in radians, 31 logs, natural logs of numbers , 122
lines, determining intersections , 114 lowercase characters, converting, 179
linker reactor events, (table), 319 LSEDIT command, 375
linker reactors, creating, 318
LISP reactor events, (table), 320 M
LISP reactors, creating, 319 macros, running Visual Basic, 246
lists mathematical functions
adding first element, 51 addition, 19
appending to, 34 AND, 30
comparison function, 234, 235 bitwise NOT, 24
concatenating, 34, 118 division, 20, 150
constructing, 34 , 220 equality checking, 21 , 75, 76
constructing dotted lists, 51 exponentiation, 81
deleting beginning and end characters , 242 greater than, 23
deleting end characters, 240 less than or equal to , 23
deleting leading characters, 237 multiplication , 20
determining index of item, 226 not equal to , 21
element index values, 235 subtraction, 19
eliminating duplicate elements, 234, 235 MCS. See Model Coordinate System
evaluating primary conditions , 50 measurements, converting values , 52
first element, excluding, 46 memory
first element, obtaining, 46 allocating, 80
first expression, converting, 146 dynamic, defined, 125
item position in, 226 freeing unused, 86
last element, 117 setting segment size, 30
length, determining, 222 status in AutoLISP, 125
linking objects as extended data , 358 menu commands, displaying menus, 127
nth element, 136 menugroups, loading, 129
passing to functions, 34 menus
quantity of elements, 118 DIESEL expressions, 129
quantity of supplied arguments, 124 item status, 127
remainder, obtaining, 127 methods
removing elements, 231 calling ActiveX, 270
replacing old items, 181 converting transformation matrix for, 294
reversing elements , 152 objects supported by, 281
searching for remainder, 127 MIRROR3D command, 381
second element, obtaining Y coordinate, 45 miscellaneous reactor events, (table), 321
substituting new items, 181 Model Coordinate System (MCS), 132
testing elements, 232, 233 Model to World Transformation Matrix, 132
testing elements in, 209, 225, 226 modifying strings, active dialog box lists, 28
third element, obtaining Z coordinate, 45 mouse reactor events, (table), 322
using OR, 139 mouse reactors, creating, 322
valid list definitions, 205 multiple vectors, on graphics screen, 106
verifying, 119
loading. See also unloading N
loading extended Visual LISP functions , 224 names
loading files objects , 68, 73
in Auto CAD, 223 of entities in selections sets, 171
DCL files , 121 namespace
for AutoLISP commands, 42
422 | Index
importing functions , 207 creating selection sets , 166
setting variable values, 208 deleting, 66
variable values, 208 deleting from selection sets, 166
variables in open documents, 228 determining if readable, 285
naming erasing, 264
commands in AutoCAD, 89 extended data, 149
with file dialog box in AutoCAD, 92 extended object data, functions, 358
temporary files , 218 gripping, 175
valid characters for symbols, 162 handles , 107
naming objects (entities), 70 identifying symbols , 244
returning drawing objects, 73 last nondeleted, 68
negative numbers, verifying, 130 linking as extended data, 358
nested entities, 75 methods applicable to,listing, 263
newlines, printing to command line, 188 methods supported by, 281
nil modifying definition data, 71
checking variable for, 135, 137 modifying in AutoCAD drawings, 300
testing list elements for, 226 naming, 68, 70 , 73
testing lists in functions for, 233 nested, 75
non-graphical objects, adding to dictionaries , 57 nongraphical, accessing, 131
numbers number in selection set, 170
absolute values , 25 properties of, 267
checking equality of, 21 properties of,listing, 263
common denominators, 86 releasing, 282
converting to real numbers, 84 releasing in drawings, 285
decrementing, 25 restoring deleted objects, 66
evaluating to zero, 359 retrieving definition data, 67
incrementing, 25 retrieving LISP data, 271
negative, verifying, 130 returning next drawing object, 73
searching symbol tables for, 186
O selecting, 73, 131
Object Coordinate System (OCS), 191 selecting for set, 175
object events, (table), 324 setting properties in ActiveX, 284
object reactors specifying properties, 283
adding to list of owners, 326 storing LISP data, 274
creating, 323 top level in AutoCAD, 265
owners of, 327 transforming ename to VLA-object, 264
removing from list of owners , 326 transforming VLA-object to ename, 300
Object Snap mode, 74 transforming VLA-object to entity name,
specifying points , 140 300
ObjectARX TypeLib information, 295
current applications list, 35 undeleting, 66
listing loaded applications , 35 updating on screen, 74
loading application, 35 updating screen image, 75
loading associated files, 41 opening files , 138
reactor notification and, 318 output. See writing
undefining symbols, 198
unloading application, 36 P
objects paper space, current layouts , 117
adding to selection sets, 164 patterns
assigning handles , 70 matching with wild cards , 353
changing in drawing database, 302 replacing in strings, 241
complex, 131 searching in strings, 240
converting ename to VLA-object, 264 periodic curves, 258
converting VLA-object to ename, 300 persistent reactors, declaring, 327
creating in drawings , 69 planes
creating new, 70 containing curves , 259
creating new instance, 266 nearest point on projected curve, 261
Index | 423
points notifying of LISP events , 319
3D, 140 notifying of mouse events, 322
specifying, 98 object reactors,constructing, 323
transforming coordinate systems , 132 overwriting application-specific data, 306
translating between coordinate systems, replacing callback functions, 330
191 testing if enabled, 303
Y coordinate, 45 reactors, callback conditions, 329
Z coordinate, 45 reactors, determining type of, 338
polylines reading, AutoCAD input devices , 102
definition data , 132 real numbers
selecting, 132 converting from floating point, 64
updating screen image, 75 converting from numbers, 84
pop-up lists, processing in dialog boxes, 179 converting from strings, 38
properties converting to smaller integers, 83
setting in ActiveX, 284 converting to strings, 152
specifying in objects (entities), 283 largest in list, 125
PSDRAG command, 381 and natural logs, 122
PSFILL command, 382 smallest in list, 129
PSIN command, 383 specifying, 99
square roots, 164
Q verifying, 137
quit/exit abort error message, AutoLISP, 79 real values, converting angles from radians to , 31
quitting applications, forcing, 145 rectangles
corners, user input, 90
R filled, 81
in dialog box image tiles, 81
radians recursion, in loading files , 120
of angles , 88 REGEN command, 75
arctangents measured in, 37 registry keys, creating in Windows , 231
converting to strings, 32 registry path, in AutoCAD, 283
reactor events, (table), 302 remainders, in division , 150
reactor objects. See reactors , 302 renaming
reactor type, determining, 338 dictionary entries , 61
reactor types, listing, 339 files , 214
reactors RENDER command, 384
application-specific data, 305 RENDERUPDATE command, 388
constructing, 302 REPLAY command, 388
data associated with, 305 RPREF command, 403
determining if enabled, 303
determining if persistent, 328
disabling, 332 S
disabling specified type, 333 safearrays
enabling, 303 adding elements, 291
executing callback functions, 334 creating, 276
for drawing document events, 308 data types, 292
for notifying of ObjectARX applications , dimension boundaries of, 288, 289, 290
318 displaying as lists, 293
inactive namespace and, 323 lower boundaries, 289
list of existing, 331 number of dimensions , 288
list of pairs , 331 returning start index of, 289
list of persistent reactors , 328 specifying indexes of elements, 288
making persistent, 327 storing data in elements , 286
making transient, 329 upper boundaries, 290
miscellaneous editor types, 320 SAVEIMG command, 406
notifying of deep cloning, 307 saving data, in session boundaries , 275
notifying of drawing events, 310 SCENE command, 407
notifying of events in DXF files, 312 screen images, updating, 74
screen menus, entering text in, 105
424 | Index
screens specifying, 99
displaying messages, 144 substituting characters, 242
dual-screen display, 144 substrings , 182
Flip Screen function key, 189 subkeys, in Windows registry, 229
graphics for AutoCAD, 101 subroutines, external, 198
switching graphics screen to text screen, substrings. See strings
189 symbol tables
updating object image, 75 finding next item, 184
writing characters, 356 searching for object (entity) names, 186
writing strings, 357 searching for symbol names, 187
SCRIPT command, 50 symbols
searching files, end-of-line markers, 148 current bound values, 244
searching lists defining current atoms list, 40
association lists , 37 determining if nil, 135, 137
for old items, 181 external subroutines , 198
for remainder, 127 indentifying for objects (entities), 244
segments invalid characters (table), 163
setting size of, 30 naming in uppercase, 243
selecting objects, 73, 131 naming with valid characters, 162
selection sets searching for names in symbol tables , 187
adding new objects (entities), 164 setting as functions , 56
analyzing creation of, 172 setting values , 154, 158
creating, 164 undefining for ObjectARX, 198
deleting objects (entities), 166 value bound to , 44
members, determining, 171 system variables
number of objects (entities) in, 170 in AutoCAD
object selection methods (list), 166 environment variable names, 92
point descriptor IDs (table), 174 values, setting, 159
returning entity names , 171 See also environment variables
selection method IDs (table), 173
separate-namespace VLX, determining if T
loaded, 247 temporary files, naming, 218
session boundaries, saving data, 275 terminating dialog boxes , 65, 187
setting symbols to values, 158 test function for lists, 232 , 233
setting system variables, 159 text
setting variables to values, 158 in screen menus, 105
SETUV command, 411 on Autocad status line, 105
SHOWMAT command, 413 text boxes, diagonal coordinates, 188
sine of angle, 160 text objects, measuring, 188
SKETCH command, 50 text screens, switching from graphics screen, 189
slides, displaying in dialog boxes , 161 tiles
SNAPANG system variable, 159 creating images in dialog boxes , 178
SOLPROF command, 414 managing data in dialog boxes, 48
sorting mode for dialog boxes, 130
alphabetizing strings , 27 retrieving heights, 63
lists, 235 retrieving widths , 62
source code, compiling into FAS files, 300 selecting in dialog boxes, 27
square roots, as real numbers , 164 setting value in dialog boxes , 155
status line,writing text to, 105 trace flag, clearing, 195
status of menu items, 127 trace function, debugging, 189
strings Trace window, callback arguments, 337
alphabetizing list of, 27 transformation matrix
concatenating multiple strings , 180 vectors, 106
longest common prefix, 238 VLA methods, 294
replacing patterns , 241 truncating numbers, 83
searching for ASCII code, 239 .txt files, in VLX, 219
searching for patterns , 240 type function, data types (list), 193
Index | 425
type libraries, importing data from, 268 creating, 69
TypeLib information, 295 viewports
clearing current, 101
U current configurations , 352
UCS. See user coordinate system drawing vectors , 106
undeleting objects, 66 list of descriptors , 352
unloading redrawing current viewport, 148
DCL files , 195 redrawing objects (entities), 148
VLX applications , 245 specifying views , 160
See also loading vectors, drawing, 101
untrace function, debugging, 195 Visual Basic
uppercase characters, converting, 179 loading projects with AutoLISP, 246
user coordinate system, 3D points , 141 running macros with AutoLISP, 246
user input Visual LISP, loading AutoLISP entensions, 224
angles, 97 VLA-objects, getting properties, 267
help file commands , 156 VLX
integers, 95 exporting functions , 221
keyboard input buffer, 147 invoking from another namespace, 211
keywords , 96 VLX applications
keywords for function calls , 111 and current document, 222
opening dialog boxes , 178 determining if loaded, 247
points , 98 error handlers , 210
real numbers , 99 unloading, 245
restricting type of, 111 VLX, with .txt resource files, 219
selecting objects without user input, 133
selecting tiles , 27 W
strings , 99 warning message, in dialog boxes , 29
terminating dialog boxes, 187 WCS. See World Coordinate System
width of tiles, retrieving in dialog box units, 62
V wild cards, pattern match, 353
values, bound to symbols, 44 Windows applications, starting, 177
variables Windows registry
in blackboard namespace, 200 creating keys, 231
copying values, 228 deleting keys, 229
determining if numeric, 137 stored data for keys, 230
setting values , 158 subkeys , 229
setting values in namespace, 208 Windows, starting applications, 177
valid list definitions, 205 World Coordinate System
values from namespace, 208 endpoints in curves , 254
variants start point in curves, 257
changing data types, 296 writing
creating, 278 characters , 356
determining data type, 297 expressions to files, 141, 143
determining values , 299 strings , 357
vectors
in dialog box images, 196 Y
drawing in viewports, 101 Y coordinate, obtaining, 45
drawing on graphics screen, 106
verifying lists , 119 Z
version, of current AutoLISP, 197 Z coordinate, obtaining, 45
VIEWPORT entity type zero, testing number for, 359
changing, 72
426 | Index