414
February 24, 1999 ®

AutoLisp Reference

  • Upload
    liu-tun

  • View
    637

  • Download
    25

Embed Size (px)

DESCRIPTION

AutoLisp 参考手册

Citation preview

Page 1: AutoLisp Reference

February 24, 1999

®

Page 2: AutoLisp Reference

���� © 1999 Autodesk, Inc.������

AUTODESK, INC. ���� ��������������������� !"#�$%&'�()�*+�,�&�����-

��./0(1�23��456�*789:8;<�=<�>? AUTODESK, INC. @�A��B�-CDEF�GHIJK AUTODESK, INC. LM#$�A�B�NO P�QR����STU%-

Autodesk, Inc., ��VW�XYZ[���-���$\]���^�Z[_` a�bcZ[de�fg-

Autodesk hi

Pjk�l Autodesk, Inc. mno( p��qor�sthiu3D Plan83D Props83D Studio83D Studio MAX83D Studio VIZ8

3DSurfer8ADE8ADI8Advanced Modeling Extension8AEC Authorityvwix8AEC-X8AME8Animator Pro8Animator Studio8

ATC8AUGI8AutoCAD8AutoCAD Data Extension8AutoCAD Development System8AutoCAD LT8AutoCAD Map8Autodesk8

Autodeskvwix8Autodesk Animator8Autodesk MapGuide8Autodesk University8Autodesk View8Autodesk WalkThrough8Autodesk

World8AutoLISP8AutoShade8AutoSketch8AutoSolid8AutoSurf8AutoVision8Biped8bringing information down to earth8CAD

Overlay8Character Studio8Design Companion8Drafix8Education by Design8Generic8Generic 3D Drafting8Generic CADD8Generic

Software8Geodyssey8Heidi8HOOPS8Hyperwire8Inside Track8Kinetix8MaterialSpec8Mechanical Desktop8Multimedia Explorer8

NAAUG8Office Series8Opus8PeopleTracker8Physique8Planix8Rastation8Softdesk8Softdeskvwix8Solution 30008Tech

Talk8Texture Universe8The AEC Authority8The Auto Architect8TinkerTech8WHIP!8WHIP!vwix8Woodbourne8WorkCenter

( World-Creating Toolkit-

Pjk�l Autodesk, Inc. mno( p��qor�hiu3D on the PC8ACAD8ActiveShapes8Actrix8Advanced User Interface8

AEC Office8AME Link8Animation Partner8Animation Player8Animation Pro Player8A Studio in Every Computer8ATLAST8Auto-

Architect8AutoCAD Architectural Desktop8AutoCAD Architectural Desktop Learning Assistance8AutoCAD Learning Assistance8

AutoCAD LT Learning Assistance8AutoCAD Simulator8AutoCAD SQL Extension8AutoCAD SQL Interface8AutoCDM8Autodesk

Animator Clips8Autodesk Animator Theatre8Autodesk Device Interface8Autodesk PhotoEDIT8Autodesk Software Developer’s Kit8

Autodesk View DwgX8AutoEDM8AutoFlix8AutoLathe8AutoSnap8Built with ObjectARXvwix8ClearScale8Concept Studio8

Content Explorer8cornerStone Toolkit8Dancing Babyvyzx8Design Your World8Design Your Worldvwix DXF8DWG Linking8

DWG Unplugged8DXF8Exegis8FLI8FLIC8GDX Driver8Generic 3D8Home Series8Kinetixvwix8MAX DWG8ObjectARX8

ObjectDBX8Ooga-Chaka8Photo Landscape8Photoscape8Plugs and Sockets8PolarSnap8Powered with Autodesk Technology8Powered

with Autodesk Technologyvwix8ProConnect8Pro Landscape8QuickCAD8RadioRay8SchoolBox8SketchTools8Suddenly Everything

Clicks8Supportdesk8The Dancing Baby8Transforms Ideas Into Reality8Visual LISP ( VOLO!-

{|}Z[hi

Microsoft8Visual Basic ( Windows ~�Microsoft Corporation �sthi� ActiveX8Windows NT8Windows 95 ( Windows 98

~�Microsoft Corporation �hi-Delphi ~ Borland International �hi-���qhi��8Z[���hi@�����

��-

GOVERNMENT USE

Use, duplication, or disclosure by the U. S. Government is subject to restrictions as set forth in FAR 12.212 (Commercial ComputerSoftware-Restricted Rights) and DFAR 267.7202 (Rights in Technical Data and Computer Software), as applicable.

Page 3: AutoLisp Reference

�� | iii

�� ��

AutoLISP �� . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

+ .................................................................................17– .................................................................................17* .................................................................................18/ ..................................................................................18= .................................................................................19/= ................................................................................19< .................................................................................20<=................................................................................21> .................................................................................21>= ...............................................................................22~ .................................................................................221+ ................................................................................231– ................................................................................23abs ...............................................................................23acad_colordlg..............................................................24acad_helpdlg ...............................................................24acad_strlsort ................................................................25action_tile....................................................................25add_list........................................................................26alert .............................................................................27alloc.............................................................................28and...............................................................................28angle............................................................................29angtof ..........................................................................29angtos ..........................................................................30

Page 4: AutoLisp Reference

iv | ��

append.........................................................................32apply............................................................................32arx ...............................................................................33arxload ........................................................................33arxunload ....................................................................34ascii .............................................................................34assoc............................................................................35atan..............................................................................35atof ..............................................................................36atoi ..............................................................................37atom ............................................................................37atoms-family ...............................................................38autoarxload..................................................................39autoload.......................................................................40Boole ...........................................................................40boundp ........................................................................42caddr............................................................................43cadr..............................................................................43car................................................................................44cdr ...............................................................................44chr ...............................................................................45client_data_tile............................................................46close ............................................................................46command.....................................................................47cond.............................................................................48cons .............................................................................49cos ...............................................................................50cvunit ..........................................................................50defun ...........................................................................51defun-q ........................................................................52defun-q-list-ref ............................................................53defun-q-list-set ............................................................54dictadd ........................................................................55dictnext .......................................................................56dictremove .................................................................58dictrename ..................................................................58dictsearch ...................................................................59

Page 5: AutoLisp Reference

�� | v

dimx_tile .....................................................................60dimy_tile .....................................................................61distance .......................................................................61distof ...........................................................................62done_dialog.................................................................63end_image...................................................................63end_list........................................................................64entdel...........................................................................64entget...........................................................................65entlast ..........................................................................66entmake.......................................................................67entmakex ....................................................................68entmod ........................................................................68entnext.........................................................................71entsel ...........................................................................71entupd..........................................................................72eq.................................................................................73equal............................................................................74*error*.........................................................................76eval..............................................................................76exit ..............................................................................77exp...............................................................................77expand.........................................................................78expt..............................................................................79fill_image ....................................................................79findfile.........................................................................80fix ................................................................................81float .............................................................................82foreach ........................................................................82function .......................................................................83gc.................................................................................84gcd...............................................................................84get_attr ........................................................................85get_tile ........................................................................85getangle .......................................................................85getcfg ..........................................................................86getcname ....................................................................87

Page 6: AutoLisp Reference

vi | ��

getcorner .....................................................................88getdist..........................................................................88getenv..........................................................................89getfiled ........................................................................90getint ...........................................................................92getkword .....................................................................93getorient ......................................................................94getpoint .......................................................................95getreal..........................................................................96getstring ......................................................................97getvar ..........................................................................98graphscr.......................................................................98grclear .........................................................................98grdraw .........................................................................99grread ..........................................................................99grtext .........................................................................102grvecs ........................................................................103handent......................................................................105help ...........................................................................105if ................................................................................107initdia ........................................................................107initget ........................................................................108inters..........................................................................111itoa ............................................................................113lambda.......................................................................113last .............................................................................114layoutlist....................................................................114length ........................................................................115list..............................................................................115listp............................................................................116load............................................................................117load_dialog................................................................118log .............................................................................119logand........................................................................119logior .........................................................................120lsh..............................................................................120mapcar.......................................................................121

Page 7: AutoLisp Reference

�� | vii

max............................................................................122mem ..........................................................................122member .....................................................................124menucmd...................................................................124menugroup ................................................................126min ............................................................................126minusp.......................................................................127mode_tile ..................................................................127namedobjdict.............................................................128nentsel .......................................................................128nentselp .....................................................................130new_dialog................................................................132not .............................................................................132nth .............................................................................133null ............................................................................134numberp ....................................................................134open...........................................................................135or ...............................................................................136osnap .........................................................................137polar ..........................................................................138prin1 ..........................................................................138princ ..........................................................................140print ...........................................................................140progn .........................................................................141prompt .......................................................................141quit ............................................................................142quote..........................................................................142read............................................................................143read-char ...................................................................144read-line ....................................................................145redraw .......................................................................145regapp........................................................................146rem ............................................................................147repeat.........................................................................148reverse .......................................................................149rtos ............................................................................149set ..............................................................................151

Page 8: AutoLisp Reference

viii | ��

set_tile .......................................................................152setcfg .........................................................................152setenv ........................................................................153setfunhelp..................................................................153setq ............................................................................155setvar .........................................................................156setview .....................................................................157sin..............................................................................157slide_image ...............................................................158snvalid .......................................................................159sqrt ............................................................................161ssadd..........................................................................161ssdel ..........................................................................163ssget ..........................................................................163ssgetfirst ...................................................................167sslength .....................................................................167ssmemb .....................................................................168ssname.......................................................................168ssnamex ....................................................................169sssetfirst ...................................................................172startapp......................................................................174start_dialog................................................................175start_image................................................................175start_list.....................................................................176strcase........................................................................176strcat..........................................................................177strlen..........................................................................178subst ..........................................................................178substr .........................................................................179tablet..........................................................................180tblnext .......................................................................181tblobjname ................................................................183tblsearch ....................................................................184term_dialog ...............................................................184terpri..........................................................................185textbox ......................................................................185textpage.....................................................................186

Page 9: AutoLisp Reference

�� | ix

textscr........................................................................186trace...........................................................................186trans...........................................................................188type............................................................................190unload_dialog............................................................192untrace.......................................................................192vector_image.............................................................193ver .............................................................................194vl-acad-defun ............................................................195vl-acad-undefun ........................................................195vl-arx-import .............................................................195vl-bb-ref ....................................................................197vl-bb-set ....................................................................197vl-catch-all-apply ......................................................198vl-catch-all-error-message ........................................199vl-catch-all-error-p....................................................200vl-cmdf......................................................................200vl-consp.....................................................................202vl-directory-files .......................................................203vl-doc-export.............................................................203vl-doc-import ............................................................204vl-doc-ref ..................................................................205vl-doc-set ..................................................................205vl-every ....................................................................206vl-exit-with-error ......................................................207vl-exit-with-value......................................................208vl-file-copy ...............................................................209vl-file-delete..............................................................210vl-file-directory-p......................................................210vl-file-rename ...........................................................211vl-file-size .................................................................212vl-file-systime ...........................................................212vl-filename-base .......................................................213vl-filename-directory ...............................................214vl-filename-extension ...............................................214vl-filename-mktemp..................................................215vl-get-resource ..........................................................216

Page 10: AutoLisp Reference

x | ��

vl-list* .......................................................................217vl-list->string ...........................................................217vl-list-exported-functions..........................................218vl-list-length..............................................................219vl-list-loaded-vlx.......................................................219vl-load-all..................................................................220vl-load-com...............................................................221vl-load-reactors .........................................................221vl-member-if .............................................................222vl-member-if-not.......................................................223vl-position .................................................................223vl-prin1-to-string ......................................................224vl-princ-to-string ......................................................225vl-propagate ..............................................................225vl-registry-delete .......................................................226vl-registry-descendents .............................................226vl-registry-read..........................................................227vl-registry-write ........................................................228vl-remove .................................................................228vl-remove-if .............................................................229vl-remove-if-not........................................................230vl-some .....................................................................230vl-sort ........................................................................231vl-sort-i......................................................................232vl-string->list ...........................................................233vl-string-elt................................................................234vl-string-left-trim ......................................................234vl-string-mismatch ....................................................235vl-string-position.......................................................236vl-string-right-trim ....................................................237vl-string-search .........................................................237vl-string-subst ...........................................................238vl-string-translate ......................................................239vl-string-trim.............................................................239vl-symbol-name .......................................................240vl-symbol-value .......................................................241vl-symbolp ................................................................241

Page 11: AutoLisp Reference

�� | xi

vl-unload-vlx.............................................................242vl-vbaload .................................................................243vl-vbarun...................................................................243vl-vlx-loaded-p..........................................................244vlax-3D-point............................................................244vlax-add-cmd ............................................................245vlax-create-object......................................................247vlax-curve-getArea ...................................................247vlax-curve-getDistAtParam ......................................248vlax-curve-getDistAtPoint ........................................249vlax-curve-getEndParam ..........................................250vlax-curve-getEndPoint ............................................251vlax-curve-getParamAtDist ......................................251vlax-curve-getParamAtPoint ....................................252vlax-curve-getPointAtDist ........................................252vlax-curve-getPointAtParam ....................................253vlax-curve-getStartParam .........................................254vlax-curve-getStartPoint ...........................................254vlax-curve-isClosed ..................................................255vlax-curve-isPeriodic ...............................................255vlax-curve-isPlanar ...................................................256vlax-curve-getClosestPointTo ..................................257vlax-curve-getClosestPointToProjection ..................258vlax-curve-getFirstDeriv...........................................258vlax-curve-getSecondDeriv ......................................259vlax-dump-object ......................................................260vlax-ename->vla-object ...........................................261vlax-erased-p.............................................................261vlax-for......................................................................262vlax-get-acad-object..................................................262vlax-get-object ..........................................................263vlax-get-or-create-object...........................................263vlax-get-property ......................................................264vlax-import-type-library ...........................................265vlax-invoke-method ..................................................267vlax-ldata-delete........................................................268vlax-ldata-get ............................................................268

Page 12: AutoLisp Reference

xii | ��

vlax-ldata-list ............................................................271vlax-ldata-put ............................................................271vlax-ldata-test............................................................272vlax-make-safearray..................................................273vlax-make-variant .....................................................275vlax-map-collection ..................................................277vlax-method-applicable-p .........................................278vlax-object-released-p...............................................279vlax-product-key.......................................................280vlax-property-available-p..........................................280vlax-put-property ......................................................281vlax-read-enabled-p ..................................................282vlax-release-object ....................................................282vlax-remove-cmd .....................................................282vlax-safearray-fill......................................................283vlax-safearray-get-dim..............................................285vlax-safearray-get-element .......................................285vlax-safearray-get-l-bound........................................286vlax-safearray-get-u-bound.......................................287vlax-safearray-put-element .......................................288vlax-safearray-type ...................................................289vlax-safearray->list ...................................................290vlax-tmatrix...............................................................291vlax-typeinfo-available-p..........................................292vlax-variant-change-type ..........................................293vlax-variant-type.......................................................294vlax-variant-value .....................................................296vlax-vla-object->ename ............................................297vlax-write-enabled-p .................................................297vlisp-compile ............................................................297vlr-acdb-reactor.........................................................299vlr-add ......................................................................300vlr-added-p................................................................300vlr-beep-reaction.......................................................301vlr-command-reactor ...............................................301vlr-current-reaction-name .........................................302vlr-data ......................................................................302

Page 13: AutoLisp Reference

�� | xiii

vlr-data-set ................................................................303vlr-deepclone-reactor ...............................................304vlr-docmanager-reactor ............................................305vlr-dwg-reactor ........................................................307vlr-dxf-reactor ..........................................................309vlr-editor-reactor ......................................................310vlr-insert-reactor ......................................................313vlr-linker-reactor .......................................................315vlr-lisp-reactor .........................................................316vlr-miscellaneous-reactor .........................................317vlr-mouse-reactor .....................................................319vlr-notification .........................................................320vlr-object-reactor .....................................................320vlr-owner-add............................................................323vlr-owner-remove ....................................................323vlr-owners .................................................................324vlr-pers .....................................................................324vlr-pers-list ...............................................................325vlr-pers-p ..................................................................325vlr-pers-release .........................................................326vlr-reaction-names ...................................................326vlr-reaction-set .........................................................327vlr-reactions .............................................................328vlr-reactors ................................................................328vlr-remove ................................................................329vlr-remove-all ..........................................................330vlr-set-notification ...................................................331vlr-sysvar-reactor .....................................................332vlr-toolbar-reactor ....................................................333vlr-trace-reaction.......................................................334vlr-type .....................................................................335vlr-types ...................................................................336vlr-undo-reactor .......................................................337vlr-wblock-reactor ...................................................339vlr-window-reactor ..................................................341vlr-xref-reactor .........................................................343vports ........................................................................349

Page 14: AutoLisp Reference

xiv | ��

wcmatch ....................................................................350while..........................................................................353write-char ..................................................................353write-line ...................................................................354xdroom ......................................................................355xdsize ........................................................................355zerop..........................................................................356

�� A ����� . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

3dsin..........................................................................3603dsout........................................................................361align ..........................................................................362cal..............................................................................362fog .............................................................................363light ...........................................................................363lsedit..........................................................................372lslib............................................................................373lsnew .........................................................................377matlib ........................................................................377mirror3d ....................................................................378psdrag........................................................................379psfill ..........................................................................379psin............................................................................380render .......................................................................381renderupdate..............................................................386replay .......................................................................386rmat ...........................................................................387rotate3d .....................................................................402rpref ..........................................................................403saveimg .....................................................................406scene .........................................................................407setuv ..........................................................................410showmat ...................................................................412solprof .......................................................................413stats ..........................................................................413

Page 15: AutoLisp Reference

������

15

AutoLISP ��

���� ��� AutoCAD ������� AutoLISP

���

�������� ���!"#$%&�'()*+�

�,-.� �/012�

+�34�5#65789:;<=>�?@�A���

��BCD<!"EFGH2IJ#K9LM�N�OP

"QGRS�

� ��!"�T

� '()*+��,-.� �

��/012

Page 16: AutoLisp Reference

16 | AutoLISP ��

�������� �������

��� ���� number ������������������� !"������#$%&'()��*����+ ,'-���%��./)

01��� ,'-���%

23 ����4567�8�9 Visual LISP �������:AutoLISP ��;/<%

(foo string [number ...])

��=

>/��

�?��@AB$

CB$

DB$

���EF��

GHI$ (...) �J

Page 17: AutoLisp Reference

+ | 17

+

(+ [number number] ...)

��

number ����

���

���� ����������������� number ����������� 0 �� �� ��! number��"�����#�� 0�

$%

(+ 1 2) �� 3 (+ 1 2 3 4.5) �� 10.5(+ 1 2 3 4.0) �� 10.0

(– [number number] ...)

��

number ����

���

&�'� ������� number ��()*��#�����+,���&-,.��/01������2�������� number �������� 0 &-��2� �� -number��"�����#�� 0�

3�4������

3&45,���&-67���8��2�

Page 18: AutoLisp Reference

18 | AutoLISP ��

��

(- 50 40) �� 10(- 50 40.0) �� 10.0(- 50 40.0 2.5) �� 7.5(- 8) �� -8

*

(* [number number] ...)

��

number ����

��� ������������������ number ��������1 ����� ! number��"�����# 0�

��

(* 2 3) �� 6 (* 2 3.0) �� 6.0 (* 2 3 4.0) �� 24.0 (* 3 -4.5) �� -13.5(* 3) �� 3

/

(/ [number number] ...)

��

number ����

$��������� number ��%&'������(���)*+$��$,(-��./0�����1�/02.�3�������� number �������$, 1 ���� ! number��"�����# 0�

4�5�����1

4$56(���$,78���193

Page 19: AutoLisp Reference

= | 19

��

(/ 100 2) �� 50 (/ 100 2.0) �� 50.0 (/ 100 20.0 2) �� 2.5 (/ 100 20 2) �� 2 (/ 4) �� 4

=

(= numstr [numstr] ...)

��

numstr �������

� �

����������� T���� nil�������������� T�

��

(= 4 4.0) �� T (= 20 388) �� nil(= 2.4 2.4 2.4) �� T (= 499 499 500) �� nil (= "me" "me") �� T (= "me" "you") �� nil

��� eq equal ���

/=

(/= numstr [numstr] ...)

��

numstr �������

!�"#$%��&���

!'�"#$%��&��'��

Page 20: AutoLisp Reference

20 | AutoLISP ��

���

����� ��������� T����� nil�����������

���� T�

������/= �� !"# LISP $%&�'(�)�"*+� �,-./0�12�����3&��45�� T�6- AutoLISP 0�,���� ��������/= ��7�� T�89:;<=�

>=

(/= 10 20) �� T (/= "you" "you") �� nil(/= 5.43 5.44) �� T(/= 10 20 10 20 20) �� nil(/= 10 20 10 20) �� T

-?@A�<=0BC./0������D�EFGHI&�� ��J

K /= ��L��M�N T�

<

(< numstr [numstr] ...)

��

numstr ��OPQRSO�

���

��T����3UGHVW������ T����� nil�����������< ���� T�

>=

(< 10 20) �� T (< "b" "c") �� T (< 357 33.2) �� nil (< 2 3 88) �� T (< 2 3 4 4) �� nil

XUGY��T����3UGHVW������ T����� nil

Page 21: AutoLisp Reference

<= | 21

<=

(<= numstr [numstr] ...)

��

numstr ��������

��

� ������������������� T���� nil� ���

�����<= ��� T

!

(<= 10 20) �� T (<= "b" "b") �� T (<= 357 33.2) �� nil (<= 2 9 9) �� T (<= 2 9 4 5) �� nil

>

(> numstr [numstr] ...)

��

numstr ��������

��

� ������"��������� T���� nil� ������

��> ��� T

!

(> 120 17) �� T (> "c" "b") �� T (> 3.5 1792) �� nil (> 77 4 2) �� T (> 77 4 4) �� nil

#�����$� ������������������� T���� nil

#"�$� ������"��������� T���� nil

Page 22: AutoLisp Reference

22 | AutoLISP ��

>=

(>= numstr [numstr] ...)

��

numstr �������

���

��������������������� T����� nil ����

�����>= ��� T

!"

(>= 120 17) �� T (>= "c" "c") �� T (>= 3.5 1792) �� nil (>= 77 4 4) �� T (>= 77 4 9) �� nil

~

(~ int)

��

int #��

���

���$%&'( 1 �)*+

!"

(~ 3) �� -4 (~ 100) �� -101 (~ -4) �� 3

'�����+ ��������������������� T����� nil

'$%&+�����$%&'( 1 �)*+

Page 23: AutoLisp Reference

1+ | 23

1+

(1+ number)

��

number �����

��

1 �����

(1+ 5) �� 6 (1+ -17.5) �� -16.5

1–

(1– number)

��

number �����

��

� 1 �����

(1- 5) �� 4 (1- -17.5) �� -18.5

abs

(abs number)

�� 1���� 1

�� 1����� 1

�������

Page 24: AutoLisp Reference

24 | AutoLISP ��

��

number �����

���� �

��

(abs 100) �� 100 (abs -100) �� 100 (abs -99.25) �� 99.25

acad_colordlg

(acad_colordlg colornum [flag])

��

colornum �������� 0–256 ��� 0 � 256������ !" #$�%&�!"'(�

flag )*+�� flag ,- nil�.�/012�/032456&

7 flag ��89�,-: nil �;*<�/012�/03245�

colornum - 0 ='> BYBLOCK�- 256 ='> BYLAYER�

�?@+A�!"'(�)B�?�CD #$;� nil�

��

EF'(GH�?+AIJ!"�)BK+;� L"-%&!"M

(acad_colordlg 3)

acad_helpdlg

(acad_helpdlg helpfile topic)

NHOP� AutoCAD !"+A #$

<QRSTU�VWX�

Page 25: AutoLisp Reference

acad_strlsort | 25

���������� help �� ����������������� AutoCAD ���

�� !"����#$%&��� help ���

acad_strlsort

(acad _strlsort list)

��

list '()�*+,-

./0

()1�23*+,-�45 list ���6789-:;<=>?�@ABC()� acad_strlsort ��./ nil�

DE

FG�HI6JKLM7N�NO�PQ*+,-R*ST)BC()U

VWU (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")

VWU (acad_strlsort mos)("Apr" "Aug" "Dec" "Feb" "Jan" "Jul" "Jun" "Mar" "May" "Nov" "Oct" "Sep")

action_tile

(action_tile key action-expression)

action_tile ��X��YZI��[\]�^_YZ�^_YZ� new_dialog ��X�:�`a� action bcdeX��fgbc�hiFj��YZ-klmnopqr $value st`a�uv0dwx� value bcj�opqr $key st`a�!y*�opqr $data st`a�z�{t�|d}4~'fD��|�m

n�� client_data_tile ��j�opqr $reason st`a�/����45�`a���R��\��mnopqr $x � $y st`a������

n ASCIIH*ST)[*+,-BC()

��6[\]`aX�67YZ-kl�t�e[\]K�Kf7`a�����C�YZ-

kl

Page 26: AutoLisp Reference

26 | AutoLISP ��

��

key �������� ������ key �������������

action-expression

��!��"#�$%��&'(���

)* + action_tile ,�-./01 AutoLISP Command ,�

23%

T

45

67 edit1 �89:;<�=>1?@A:;<"BCDE action_tile ,�01-��&'(FG$%H

(action_tile "edit1" "(setq ns $value)")

I�J Visual LISP ������-KLM%N DCL ��O

add_list

(add_list string)

+P1 add_list ,�QR�STU01 start_list ,�VWXYZ[\]&< ^_ start_list ,�-�� operation ��.`��� string abcd>R]&<-e

fg]&<>Rh

��

string ���i

23%

67jk=23bcd]&-���lm=23 nil

+>RnoCp<]&<-qb89���erst-89���

Page 27: AutoLisp Reference

alert | 27

��

������ DCL �� ���� longlist�������������

����� !�"#� llist �$%&'�����������(

(setq llist ’("first line" "second line" "third line"))(start_list "longlist")(mapcar ’add_list llist) (end_list)

)*'�+,������'�-./01234� "2nd line"(

(start_list "longlist" 1 0)(add_list "2nd line")(end_list)

567 start_list 8 end_list 9:(

alert

(alert string)

6:

string ;<=>?��012(

@AB

nil

��

����=>?��;<�CDEF

(alert "That function is not available.")

GH= string 6:�IJ4/1KL=��>?��;<M/01F

(alert "That function\nis not available.")

NO >?��PQ;<DE/:LRS/TUVWXPIJYZ[�

\8]^(

;<��>?����;<�C�_�>?DE

Page 28: AutoLisp Reference

28 | AutoLISP ��

alloc

(alloc n-alloc)

��

n-alloc �������� ���������������

��usubr���� Cons ������

��

!" n-alloc �#$�

%&

_$ (alloc 100)1000

'�( expand )��

and

(and [expr ...])

��

expr *+�,-�

��

./*012�,-�3 4/5 nil�6)�789:1;�3 <�� nil�=

>�� T�./?@��AB and�C�� T�

%&

DEF (setq a 103 b nil c "string")"string"

DEF (and 1.4 a c)T

DEF (and 1.4 a b c)nil

#$GHI!J expand )�KB

���,-�LMN (AND) OP4/

Page 29: AutoLisp Reference

angle | 29

angle

(angle pt1 pt2)

��

pt1 ���

pt2 ���

���

�� �����

������������� X ������ ����� !"��#$%&'(��)*+,-./0������1�2"�./34 X �����

56

789 (angle ’(1.0 1.0) ’(1.0 4.0))1.5708789 (angle ’(5.0 1.33) ’(2.4 1.33))3.14159

:�; Visual LISP ������<�=��>?@�

angtof

(angtof string [units])

��

string unit ��%&�ABCD���EFG�string HIJKLM angtof N�OP%&� unit ��QRSTUV�WXEF

G��� string �AB�YZ4 angtos N���[$�AB\]�^ZJ AutoCAD _`�abcd���AB�

units ef%&��EFGAB �����g���h�i4 AutoCAD �jklm AUNITS �_`h�ni�#$opg

�� ���q�rst34�� UCS u X �rs�v�

+wx���EFG>?�y�z{��|}B���

Page 30: AutoLisp Reference

30 | AutoLISP ��

�������� AUNITS �� �units �������� �

0 ������

1 � /� /�

2 ���

3 ��

4 !"#

$%

�&��'()�*�$%+,-�./�� �01$% nil�

angtof 2 angtos ��3+456����&� angtos ��78+,9:;<���=>�� angtof �?@�angtof ��ABC$%+,DE �FGHI�J�K unit ��LMN��

OP

QR� (angtof "45.0000")0.785398

QR� (angtof "45.0000" 3)1.0177

S�T angtos ���

angtos

(angtos angle [unit [precision]])

��

angle U���"#VWX�-�

�+,U���"#X� YZ(9:;

Page 31: AutoLisp Reference

angtos | 31

unit ���������� �� unit��������

� AUNITS ����units ���������

0 !"#$�

1 � /% /&

2 '%�

3 (�

4 )*��

precision �+��,-.�/0�1����� �2��

�������� AUPREC ����

angtos �34� mode5 precision 6 AutoCAD ����� UNITMODE 789:

;<�� DIMZIN �=>��� angle ?@ABCDEF,-

angtos �GHI� angle ��JKLMNOP��?@Q��RSTA 0 U 2π (�QV�W�

��XY)*�� unit ��� 4$����� UNITMODE Z[\�,-�]�BCD�� UNITMODE � 0�]�BCD^Z_`ab c� "N 45d E"$def��� UNITMODE � 1�]�BCD^ghZ_`ab c� "N45dE"$

,-�

���i�Aj�K�,-klBCD�mn,- nil

oc

pq� (angtos 0.785398 0 4)"45.0000"

pq� (angtos -0.785398 0 4)"315.0000"

pq� (angtos -0.785398 4)"S 45d E"

<r �� angtos �stuvr��� w ANGBASE hex���$�y�z{�y2|}6~����� ANGBASE ��

��� angtof ��Visual LISP ������ ^��BCD?@�

Page 32: AutoLisp Reference

32 | AutoLISP ��

append

(append [list ...])

��

list ��

���

���� ������������������� nil�

��

��� (append ’(a b) ’(c d))(A B C D)

��� (append ’((a)(b)) ’((c)(d)))((A) (B) (C) (D))

apply

(apply ’function list)

��

’function ���� !�" defun # lambda �$%�&'�

list �������()���*+��, nil�

���

��-.�/��

��

��� (apply ’+ ’(1 2 3))6

��� (apply ’strcat ’("a" "b" "c"))"abc"

01234�����4�

0���5678���

Page 33: AutoLisp Reference

arx | 33

arx

(arx)

���

ObjectARX ������� ���������

��

��� (arx)("acadapp.arx" "acmted.arx" "oleaprot.arx")

��� arxload � arxunload ���

arxload

(arxload application [onfailure])

��

application � !"!#$%&'(�)�*+,-� �%./�+

012� ��%34 .arx�

5678 ObjectARX +,-� %9����:;<� => AutoCAD ?@� AB����

onfailure CDEFGH,-%IJ�

���

KLMNO��������KL�MN�P78Q onfailure �������<

��%��RO��S�%TUVW�

KLXYCDZ[\]CD% ObjectARX �����arxload ^_`ZaTUVW�>b� arxload CDZ[����cd�+0e� arx ��fg\CD% ARX �����

��hd\CD% ObjectARX �����

CD ObjectARX ����

Page 34: AutoLisp Reference

34 | AutoLISP ��

��

�� AutoCAD ���� � geomcal.arx�

��� (arxload "c:/program files/ACAD2000/geomcal.arx")"c:/program files/acad2000/geomcal.arx"

��� arxunload ���

arxunload

(arxunload application [onfailure])

��

application ����������� !"#� arxload �����$%

& �'�()�$*+, �'-� .arx ./0�

onfailure 1�2345%&�678�

9:;

<=>?@9:A�BC'�<=D>?EFGHI onfailure ��E��9:J

���;EK@9:LA�MNOP�

�QRDS1�TU� ObjectARX A�BC�VW+XY�EObjectARX A�BCZTU��

��� arxload ���

ascii

(ascii string)

��

string ���[�

1� ObjectARX A�BC

\���-�]^_��`a>b ASCII c.9:

Page 35: AutoLisp Reference

assoc | 35

���

���

��

� (ascii "A")65

� (ascii "a")97

� (ascii "BIG")66

assoc

(assoc element alist)

��

element ���� ����

alist ���� ���

���

���������� ��� !���"���� nil�

��

� (setq al ’((name box) (width 3) (size 4.7263) (depth 5)))((NAME BOX) (WIDTH 3) (SIZE 4.7263) (DEPTH 5))

� (assoc ’size al)(SIZE 4.7263)

� (assoc ’weight al)nil

atan

(atan num1 [num2])

# �����$%��!�������& ���

��$%��'()�*+,-./01

Page 36: AutoLisp Reference

36 | AutoLISP ��

��

num1 ����

num2 ����

���

�� ���� num1������� num1 ������������� � ����� num1 � num2������ num1/num2 �����������

�� num2 � 0� ������!"� 1.570796 ��#+90 �! -90 �$�%�"&'( num1 ��"� �����)��*+, −π/2 - +π/2 #��$�

./

012 (atan 1)0.785398

012 (atan 1.0)0.785398

012 (atan 0.5)0.463648

012 (atan 1.0)0.785398

012 (atan -1.0)-0.785398

012 (atan 2.0 3.0)0.588003

012 (atan 2.0 -3.0)2.55359

012 (atan 1.0 0.0)1.5708

atof

(atof string)

��

string 345�6��789�

���

6��

:��7894;<6�

Page 37: AutoLisp Reference

atoi | 37

��

��� (atof "97.1")97.1��� (atof "3")3.0��� (atof "3.9")3.9

atoi

(atoi string)

��

string ���� ����

���

���

��

��� (atoi "97")97

��� (atoi "3")3

��� (atoi "3.9")3

��� itoa ���

atom

(atom item)

��

item �� AutoLISP ��

���� LISP � atom !"# $%&�'()*+,-./0 12345+6��

789���:��

;<89�=>=!"

Page 38: AutoLisp Reference

38 | AutoLISP ��

���

�� item ��� nil �� T�����������������

��

��� (setq a ’(x y z))(X Y Z)

��� (setq b ’a)A

��� (atom ’a)T

��� (atom a)nil

��� (atom ’b)T

��� (atom b)T

��� (atom ’(a b c))nil

atoms-family

(atoms-family format [symlist])

format �� 0 ! 1 �" #$%&' atoms-family ( ��)*+�,-�

0 .�/-��)*+

1 .0)1�/-��)*+

symlist $%&'$2345�)*+�0)1�

���

)*���&'6 symlistatoms-family ��78'9�&')*:;<=>'9�)*�� nil�

��?78@'9�)*AB�CD

Page 39: AutoLisp Reference

autoarxload | 39

��

��� (atoms-family 0)(BNS_PRE_SEL FITSTR2LEN C:AI_SPHERE ALERT DEFUN C:BEXTEND REM_GROUP B_RESTORE_SYSVARS BNS_CMD_EXIT LISPED FNSPLITL...

����� CAR�CDR � XYZ ����������������� �

��� (atoms-family 1 ’("CAR" "CDR" "XYZ"))("CAR" "CDR" nil)

!"� #�����$� XYZ %&���'

autoarxload

(autoarxload filename cmdlist)

()*+,- cmdlist ./��#0*"��123�4567 filename ./8�

# ObjectARX 9:;<=>?,-��'

@A�*"%&(8�BCD��#��E filename FGH3AutoCAD �(IJK��LMN*"OPQR�ST:U'

./

filename 8�(��VN�IJ cmdlist ./D��#0"��LW6

7# .arx BC#���'@AXYZ[\3AutoCAD �(]^BC_`Z[DabKBC'

cmdlist ����'

� c

nil

��

�����d C:APP1�C:APP2 � C:APP3 e/�67 bonusapp.arx BC�

(autoarxload "BONUSAPP" ’("APP1" "APP2" "APP3"))

f��g45670FG ObjectARX 9:;<#��\

Page 40: AutoLisp Reference

40 | AutoLISP ��

autoload

(autoload filename cmdlist)

������ cmdlist ��� ������������ filename ��

� AutoLISP ������ ����!

filename ����"#$%& cmdlist �'�� ���()�

�� .lsp *+�,-.!/012345�AutoCAD ��67*+8934':;<*+!

cmdlist ,-.=!

>?@

nil

/0���AB��*+'����C filename DEF�AutoCAD ��%&<��(G#��HIJKLMN�O!

PQ

������"#$%& APP1RAPP2 S APP3 ��(�T���� AutoLISP ���� bounsapp.lspU

(autoload "BONUSAPP" ’("APP1" "APP2" "APP3"))

Boole

(Boole operator int1 [int2 ...])

operator 0 V 15 �W�X�Y= 16 Z[\�]^_`ab!

c�[���� DE AutoLISP �������5

�d��e��fghijkb

Page 41: AutoLisp Reference

Boole | 41

int1, int2... ���

��� Boole ������ ����������

����� ���������� !"#$%&'()*+�,-

� int1 �.�#/ � int2 �01#234�56� !7�8�9�:;�

��<#�=> 0 ? 1�@ABC� !7@�9D01�EF#�GHIJ�

��21EF#�� !�K�L��#M 1NOL��#M 0�operator ��8PA QRCSTUV:; AND$/(W OR$?(W XOR$X?(� NOT$Y(�

Z[

���

UV� !

Int1 Int2 EF#

0 0 8

0 1 4

1 0 2

1 1 1

Boole ���#

:;\ :; ��#M 1 �]^

1 AND _`ab#cM 1

6 XOR _`ab#de�`M 1

7 OR e�`?_`ab#M 1

8 NOR _`ab#cM 0$1f�g(

Page 42: AutoLisp Reference

42 | AutoLISP ��

��

����� 12 � 5 ��� (AND) ���

��� (Boole 1 12 5)4

����� 6 � 5 ���� (XOR) ���

��� (Boole 6 6 5)3

����� operator ��� !"#$%& ��'(��)�*+*, operator - 4+./0#1 int2 23 1+4 int1 5623 0 7+�8,293 1+:;�

��� (Boole 4 3 14)12

boundp

(boundp sym)

��

sym <=)

>?�

*,�� sym @ABC3D nil �+EF�>? T)*,"#BC sym �GABC

3 nil+HF�>? nil)*, sym -IJKLM <=+NOPQRG+ST�B

3 nil)

��

��� (setq a 2 b nil)nil

��� (boundp ’a)T

��� (boundp ’b)nil

U��� atoms-family F� VLIJ<= -WX1+YGZOPQRE<=)

[�\ atoms-family F�)

]^<=-WABC3_J�

Page 43: AutoLisp Reference

caddr | 43

caddr

(caddr list)

� AutoLISP ��caddr ������� ��� Z ���� ��������� �����

��

list ��

!"

list ��� ����#$�%&'����() �* ! nil�

+,

-./ (setq pt3 ’(5.25 1.0 3.0))(5.25 1.0 3.0)

-./ (caddr pt3)3.0

-./ (caddr ’(5.25 1.0))nil

0�1 Visual LISP ��������2��3�

cadr

(cadr list)

� AutoLISP ��cadr �������4�' ��� Y ����5�' ���������4�����

��

list ��

!"

list ���4����#$�%&'��678���* ! nil�

!��� ���

!���4���

Page 44: AutoLisp Reference

44 | AutoLISP ��

��

��� (setq pt2 ’(5.25 1.0))(5.25 1.0)

��� (cadr pt2)1.0

��� (cadr ’(4.0))nil

��� (cadr ’(5.25 1.0 3.0))1.0

�� Visual LISP �������� ���

car

(car list)

��

list ��

���

list ��������������� nil�

��

��� (car ’(a b c))A

��� (car ’((a b) c))(A B)

��� (car ’())nil

�� Visual LISP �������� ���

cdr

(cdr list)

���������

��� !�������

Page 45: AutoLisp Reference

chr | 45

��

list ��

���

list ��� �������������������� !�"#�$%&'��� nil�

�� ( list ��)*+�,&cdr ��*+��-� �&./)0��12��3�

4�

567 (cdr ’(a b c))(B C)

567 (cdr ’((a b) c))(C)

567 (cdr ’())nil

567 (cdr ’(a . b))B

567 (cdr ’(1 . "Text"))"Text"

��� Visual LISP ������8��*���

chr

(chr integer)

��

list 9�:�

���

;< ASCII =$ integer �>?�>?@�"#9��/A 1-255 BCD&���E#/FGH�

4�

567 (chr 65)"A"

IJ�>? ASCII =�9�KLM;<NO�P�>?�>?@

Page 46: AutoLisp Reference

46 | AutoLISP ��

��� (chr 66)"B"

��� (chr 97)"a"

client_data_tile

(client_data_tile key clientdata)

��

key ���� ��������������

clientdata �� key ����� ����!�"#$%&'(�)*+, $data -./���

0&1

nil

close

(close file-desc)

��

file-desc 2 open (�345678�59:��

0&1

;< file-desc ��=>�close (�0& nil?@A�0&BCDEFG�

� close (�HI5J�K59:�LM=N-�O�PQR=>�2SHI

5TU�VWXP345��� LM=YZ[�\5�

]^

_`ab)785 somefile.tx �c�Lde1fg-. ct�

dh���� iBCjklmHn

HIBCP34�5

Page 47: AutoLisp Reference

command | 47

(setq fil "SOMEFILE.TXT")(setq x (open fil "r") ct 0)(while (read-line x) (setq ct (1+ ct)))(close x)

command

(command [arguments] ...)

��

arguments AutoCAD ��������

command ����������������������������� !���"#�$��� ("") %&'(') ENTER '�*+��,- command ./0') ESC '�12�3456� AutoCAD ���

command �78"9��:;<= AutoCAD �>?@%�A����B�@C��DE��F�G9��HI��B�@CJK�F�L9��HI�

�B�@CLK��MNO��@%P AutoCAD QRST��D�

�UV���WX& Visual LISP YZ- command ��[\]*^_`a AutoCAD Y�WX���b-cd)�e��O[\fghYiajklX (nil)�� AutoCAD 7mnd)���opqr AutoCAD ]>?@%�O12s�t�uvwx��y^z{�

jk|

nil

2}

P}~7�� pt1 E pt2 �T��� (1,1) E� (1,5)��w,- command ��� LINE ��]71G9��|<= AutoCAD�

��� (setq pt1 ’(1 1) pt2 ’(1 5))(1 5)

��"� AutoCAD ��

Page 48: AutoLisp Reference

48 | AutoLISP ��

��� (command "line" pt1 pt2 "")����������� nil

� �����

AutoCAD � SKETCH ��������������� !"# AutoLISP � command $�%&'()*��+,-#$�%&' SCRIPT ���./0123#4 AutoLISP 56�78+

9:�,-# acad.lsp ; MNL <=%&' command $��>?"# defun @AB%C'+D&' S::STARTUP $��E#FGHIJKLMNOP�QRSK���+

TUQRVNW�*TX� AutoCAD ��Y, BREAK � TRIM ��Z�[\]^*' entsel $�_`�@a�bcdefLgW�*TXhVN��(ij�kl[�m Visual LISP ������%�nop�qr AutoCAD ��s+

,-tuvw CMDECHO Y[xy setvar � getvar $�z�Z{|g 0�xy command $�OP���o!}#��P%~�+

��m ���%� vl-cmdf $�� Visual LISP ������%�n��]cs+

cond

(cond [(test result ...) ...])

cond $����[\gH����@+.��6T�*@���������%�����!1 nil g�+4$���T4�8����@AB��+

���

{OP��-��@AB%78*@AB��+,-l@%?�*@AB

Y� result !z#Z�>�� test ��+,-������cond �� nil+

��=�����-$�

Page 49: AutoLisp Reference

cons | 49

��

������� cond ��� �����

(cond ((minusp a) (- a)) (t a))

������� –10������� 10�

cond �� � case !"�����#$%&���� T �'(#)*+,- test ./0�1���2#)34��5��� s 567�8�9:;�<=>�?�@AB?<=>��� s 8 Y C y �DE 1��� s 8 N C n �DE 0�F�DE nil�

(cond ((= s "Y") 1) ((= s "y") 1) ((= s "N") 0) ((= s "n") 0) (t nil))

cons

(cons new-first-element list-or-atom)

G

new-first-element

HIJK.LM�NO�?NO���PQC.�

list-or-atom .CPQ�

DE�

DE�R list-or-atom �S!"TU��� list-or-atom �.�� cons DE.�V@ new-first-element �DE.5�W#X��� list-or-atom �PQ�� cons DEYZ new-first-element [ list-or-atom �\��

��

]^� (cons ’a ’(b c d))(A B C D)

]^� (cons ’(a) ’(b c d))((A) B C D)

_.�`aIJ#)NO�Cbc#)\�

Page 50: AutoLisp Reference

50 | AutoLISP ��

��� (cons ’a 2)(A . 2)

��� Visual LISP ��������� ��

cos

(cos ang)

��

ang ���������

���

ang ��������

��

��� (cos 0.0)1.0

��� (cos pi)-1.0

cvunit

(cvunit value from-unit to-unit)

��

value � !��"#��$%"&%#��

from-unit value '()*+,�

to-unit value -�)*+,�

from-unit . to-unit /01 acad.unt 23�45+,67�

���������

89:;<+,=>?@ !

Page 51: AutoLisp Reference

defun | 51

���

����������� �������� ���� acad.unt ������������ �!�"#$���� nil�

%!

&'( (cvunit 1 "minute" "second")60.0

&'( (cvunit 1 "gallon" "furlong")nil

&'( (cvunit 1.0 "inch" "cm")2.54

&'( (cvunit 1.0 "acre" "sq yard")4840.0

&'( (cvunit ’(1.0 2.5) "ft" "in")(12.0 30.0)

&'( (cvunit ’(1 2 3) "ft" "in")(12.0 24.0 36.0)

)* ��+,-% ./��01��2,3��4� 1.05�67�89:4�;<� =>?!@ABCDEFG�HI.JKLMNO PQRS

T��UQF@9MN�� ��+VW�0�XYZ�

[\] Visual LISP ������� ^����_�

defun

(defun sym ([arguments] [/ variables...]) expr...)

\4

sym :4`�

arguments :4a+ b/\4`�

/ variables :4cd 0��e�fghZ`�

fghZ`ij kl#m0�fg`ino,Wpkl

#q�0�\4����� r�noUstuvwx0

�yz {|�

ST:4

Page 52: AutoLisp Reference

52 | AutoLISP ��

expr ����������� AutoLISP ���

������������������� !"#$%&'(��

��)*+,-����� !�AutoLISP %&./012 !�34567 !�

89:

;"<= ��:�

>?@ A�BCD�����EF sym :�GHIJKL�*M�NOC

D�����PQ%&��RSCD��TU*M��V �W%& atoms-family ���

HX

(defun myfunc (x y) ...) ���������(defun myfunc (/ a b) ...) ���������(defun myfunc (x / temp) ...) ���� ���(defun myfunc () ...) ��������

W�Y Visual LISP ������Z[��T��\] �̂

defun-q

(defun-q sym ([arguments] [/ variables...]) expr...)

defun-q ��_``1abcdef AutoLISP ghi�j3kD�Al&E67&m��n�op*MF qr����st%& defun-q�Gu%&v�bcdwxy AutoLISP efZ defun z2v�/O�

��

sym &a{ �����

arguments ��Zn�|��� �

B��*MF

Page 53: AutoLisp Reference

defun-q-list-ref | 53

/ variables ����������� ��

�� ���������������������

�������� !"#�$%���&'()*+,�

�-.�/0�

expr 12��3412�56�7 AutoLISP 89:�

!;<=>5?����@A�B#�����'(��-CA�

!DEFGH����@A���AutoLISP �����IJ����KLMNO����

PQR

��ST�89:�R�

UV

_$ (defun-q my-startup (x) (print (list x)))MY-STARTUP

_$ (my-startup 5)(5) (5)

�� defun-q-list-ref WX my-startup �8YZ[

_$ (defun-q-list-ref ’my-startup)((X) (PRINT (LIST X)))

\�] defun-q-list-ref � defun-q-list-set ���

defun-q-list-ref

(defun-q-list-ref ’function )

��

function �^_����@A�

PQR

���8E`a:� !��bcE`d8�BPQ nil�

UV

�� defun-q E`��[

PQ� defun-q E`����8YZ

Page 54: AutoLisp Reference

54 | AutoLISP ��

_$ (defun-q my-startup (x) (print (list x)))MY-STARTUP

�� defun-q-list-ref �� my-startup ����

_$ (defun-q-list-ref ’my-startup)((X) (PRINT (LIST X)))

�� defun-q � defun-q-list-set ���

defun-q-list-set

(defun-q-list-set ’sym list)

��

sym ��������

list ��������������

!"

#$%� sym�

&'

_$ (defun-q-list-set ’foo ’((x) x))FOO_$ (foo 3)3

()�&'*+,-�� defun-q-list-set ./0��12340�567 8 Visual LISP 9:;<=�� defun-q $%/0���

_$ (defun-q s::startup (x) (print x))S::STARTUP$ (defun-q my-startup (x) (print (list x)))MY-STARTUP

>?�� defun-q-list-set @AB12340���

_$ (defun-q-list-set ’s::startup (append (defun-q-list-ref ’s::startup) (cdr (defun-q-list-ref ’my-startup))))S::STARTUP

@��CD3EF�$%���

Page 55: AutoLisp Reference

dictadd | 55

���������� ����� 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)

��� defun-q � defun-q-list-ref ���

dictadd

(dictadd ename symbol newobj)

��

ename !"#$�%&'(�

symbol !")%&*�#$�+,-�symbol ./012'(�3456%&*78�+,%9:�

newobj !")%&*�;<=#$�

2>?@�AB!")%&*�#$C./�12��DEF%&!"F#$

G�HIJ KL�BMN���4O�+,-P!"O2F#$�QRSF'

(9:� dictnext ��TUV�

WXY

!")%&*�#$�<Z'�

D[\%&]!";<=#$

Page 56: AutoLisp Reference

56 | AutoLISP ��

��

�������� �������������

����������

��� (setq dictionary (list ’(0 . "DICTIONARY") ’(100 . "AcDbDictionary")))((0 . "DICTIONARY") (100 . "AcDbDictionary"))

! entmakex "#�����

��� (setq xname (entmakex dictionary))<$%�� 1d98950>

�&������������

��� (setq newdict (dictadd (namedobjdict) "MY_WAY_COOL_DICTIONARY" xname))<$%�� 1d98950>

� Xrecord ��

��� (setq datalist (append (list ’(0 . "XRECORD") ’(100 . "AcDbXrecord")) ’((1 . "This is my data") (10 1. 2. 3.) (70 . 33))))((0 . "XRECORD") (100 . "AcDbXrecord") (1 . "This is my data") (10 1.0 2.0 3.0) (70 . 33))

'( Xrecord ��

��� (setq xname (entmakex datalist))<$%�� 1d98958>

� Xrecord �������

��� (dictadd newdict "DATA_RECORD_1" xname)<$%�� 1d98958>

)�* dictnext+dictremove+dictrename+dictsearch , namedobjdict "#�

dictnext

(dictnext ename [rewind])

�#

ename ���-�

./��0��12��

Page 57: AutoLisp Reference

dictnext | 57

rewind �������� nil�� �����������

��������

���

!� ��"�������#$%&� �'(��� nil���) DXF *+,-.��/0�12������#34�� ���

dictsearch �� !���56���

78 namedobjdict 9:;<=� >?@A�

BC �DE6F���� �GH�I�JK�L dictnext MNOP�� @QRSTU6� �VWXY�Z[\���]^_��`abcd�

ef

ghi dictadd efjklm� .��nolmp�� Xrecord 0qr

str (setq xname (entmakex datalist))<>?@r 1b62d60>

�I� Xrecord 0qu� ���v�wxyz%� r

str (dictadd newdict "DATA_RECORD_2" xname)<>?@r 1b62d60>

��� �"����>?@r

str (cdr (car (dictnext newdict)))<>?@r 1bac958>

dictnext ��yz%� ����>?�@A�

��� �"����>?@r

str (cdr (car (dictnext newdict)))<>?@r 1bac960>

dictnext ��yz%� ��v�>?�@A�

��� �"����>?@r

str (cdr (car (dictnext newdict)))nil

� �{|}~���j) dictnext �� nil�

Page 58: AutoLisp Reference

58 | AutoLISP ��

�������� ����������

��� (cdr (car (dictnext newdict T)))<���� 1bac958>

�� T ����� rewind ������ dictnext ���� ����!

"�# dictadd$dictremove$dictrename$dictsearch % namedobjdict &�!

dictremove

(dictremove ename symbol)

'()*+�,�� -./�� 01�2,�34 -.!�2,�34

-.567 entdel &�!89:�;<�=>?@A%BCDE!FGHIJK�LMNO�34%��PQRS��HDTKFGUV7 dictremove &�W,�� -./��X�YZ,�34 -.���!

��

ename [\]�����^!

symbol N, ename -.���!

9BCDE_[�34 �BC`7X�dictremove &�0K�2,BCDE�� -.!

���

a-������!bc ename defghij symbol�dictremove &��� nil!

D=

+k�D=-.U dictadd D= lm����

��� (dictremove (namedobjdict) "my_way_cool_dictionary")<���� 1d98950>

"�# dictadd$dictnext$dictrename$dictsearch % namedobjdict &�!

dictrename

(dictrename ename oldsym newsym)

,���� -.��

n������

Page 59: AutoLisp Reference

dictsearch | 59

��

ename ��������

oldsym � �������

newsym � ������

���

���������� newsym ���� oldname ��� !"�#ename $%& newname $%�&�� '("� newname�dictrename )�*�� nil�

+,

-.�+,�� dictadd +, /0���1

�21 (dictrename (namedobjdict) "my_way_cool_dictionary" "An even cooler dictionary")"An even cooler dictionary"

3�4 dictadd#dictnext#dictremove#dictsearch 5 namedobjdict )��

dictsearch

(dictsearch ename symbol [setnext])

��

ename �67�����

symbol �89�:;�� �67�� �

��� 67<=>

Page 60: AutoLisp Reference

60 | AutoLISP ��

setnext ������ nil�� dictnext ���������� dictnext ������ dictsearch ���� ����� �

��!

��"#��$%&� � ��'()*+� ��� nil

+,

�-�+,./�0�� dictsearch 12� dictadd +,345�678

9:8 (setq newdictlist (dictsearch (namedobjdict) "my_way_cool_dictionary"))((-1 . <;<=8 1d98950>) (0 . "DICTIONARY") (5 . "52") (102 . "{ACAD_REACTORS") (330 . <;<=8 1d98860>) (102 . "}") (330 . <;<=8 1d98860>) (100 . "AcDbDictionary") (280 . 0) (281 . 1) (3 . "DATA_RECORD_1") (350 . <;<=8 1d98958>))

>�? dictadd@dictnext@dictremove A namedobjdict ��

dimx_tile

(dimx_tile key)

��

key BCD$%EFG�HI�JK= key ��LMNOP

��!

HIQR

���ST!U$%HIVWX�YN! Z[HI�ST!U\ 0 ]^�_�V�`a X UbQR�����ST!cdN[ X-1 dimx_tile A dimy_tile ���ef vector_image@fill_image A slide_image ��gh��iE$%HINO�jkST

+,

(setq tile_width (dimx_tile "my_tile"))

��HI�QR

Page 61: AutoLisp Reference

dimy_tile | 61

dimy_tile

(dimy_tile key)

��

key �������� ������key ��������

���

����

��������� � !"�#���$% ������& 0 '()*�� +�,- Y �.���/0�������12�% Y-1�dimx_tile 3 dimy_tile 0�456 vector_image7fill_image 3 slide_image 0�89:;�<=>?@A0�BC D��� ����EF���

GH

(setq tile_height (dimy_tile "my_tile"))

distance

(distance pt1 pt2)

��

pt1 IJKLJMN�

pt1 IJKLJMN�

���

OP��

QRBC���ST4UKVUIJM�distance 0�2WX BC�YZLJM� Z ���[��\@AM]^_`abcdefg h�Mij�IJOP�

�� ����

��VUMij�OP

Page 62: AutoLisp Reference

62 | AutoLISP ��

��

��� (distance ’(1.0 2.5 3.0) ’(7.7 2.5 3.0))6.7

��� (distance ’(1.0 2.0 0.5) ’(3.0 4.0 0.5))2.82843

�� Visual LISP �������� �������

distof

(distof string [mode])

distof ��� rtos ������������� rtos ����� !"��#$ distof%distof &���'() %*+,-./0 mode ��� 123�

��

string 456�789�:��&;<= mode >0�?@A distof BCDEFGHIJ�KLMNO rtos ����789P(12�QR%SMN� AutoCAD TU�VWXYZR�

mode 789[�ZR�?@%K� \O AutoCAD �]^_`

LUNITS �TUa 1�\%ba �cd[e�

1 fg

2 h�

3 ij.kl�h�km3

4 no.kl�I�km3

5 I�

��

��p!qr%s����%ts�� nil�

uv distof ���wRxy 3 �wRxy 4 2z�{�|%�� mode " 3 .ij3} 4 .no3?@%~� string "��ZR+�%s distof ���BC��� �

��'de�.��3��78956q�'��

Page 63: AutoLisp Reference

done_dialog | 63

done_dialog

(done_dialog [status])

��

status ��� start_dialog ������� start_dialog ����� OK ��� 1����� Cancel ��� 0����� 1 � status ��������� !"#� $%&

'(�)*+,-.�/��#/ done_dialog �0�1 action_tile�

���

234+�54+6789:;�59:;�<=>? (X,Y)

@ AB

CDEFGHEIacceptJ.IcancelJ�KL�MN6IO&JPI�QJKL�

RSTUV�/��� 5�/��'(W-/ done_dialog ���� $XYZ789:;CD[E\]KLRSW-�/��@ T?^�78KL�

AutoCAD X_)`abcde�EIacceptJKLRS�W-�/��'(X status %E 1�.�� !"&��fg���� �start_dialog ��h��ij� 0�� 0 klm $�QT59:;

end_image

(end_image)

5��6 start_image ���no��

#p9:;

qrstuv�9:;wxyz�{*

Page 64: AutoLisp Reference

64 | AutoLISP ��

���

nil

��� start_image �

end_list

(end_list)

��� start_image � ���

���

nil

��� add_list � start_list �

entdel

(entdel ename)

��� ename ��� ����������� ������!"#$%&����'(� �entdel �)*+���,-���./��#$012�(� ��34567���8 entdel �9:;� ��<=�>:;� ?��<=

ename @� A*+ �� BC

���

��B

DEFG

entdel �HIJKL��MN�OP� QRSITUVWX Y��Z(� :;[\]E command �^_ ATTEDIT A PEDIT `abcde��

fg<��hi <jklm no

� <=p��qA*+r�� <=

Page 65: AutoLisp Reference

entget | 65

���������� ���� entmake ����������������������

!

"#$�%���&'()*+�,-. e1/

01/ (setq e1 (entnext))<�&/ 2c90520>

��&2 e1 �/

01/ (entdel e1)<�&/ 2c90520>

34&2 e1 �/

01/ (entdel e1) <�&/ 2c90520>

entget

(entget ename [applist])

5�

ename �67�&'�ename ��2$89$��

applist :;<�&=>�

?@A

BCD ename EF���GHI>�JKLM�N$EFO9$EF�P

Q+�D�R5� applist�entget ��ST?@UJV<�&WHXY�G�ZHI>�[�\]^+�D�� AutoCAD DXF _`��ab��Gcdef�

g:h AutoLISP i� DXF _`U DXF jk�_`lm�K�HN AutoLISP DXF _`nopq�g5r DXF Reference�

!

st$�uvwxEFy�z{| (1,2) }| (6,5) ~���� !�`�� entlast ����uv��EF�&�()Z&'��, entget/

"�EF������G

Page 66: AutoLisp Reference

66 | AutoLISP ��

��� (entget (entlast))((-1 . <���� 1bbd1d0>) (0 . "LINE") (330 . <���� 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))

� entdel�entlast�entmod�entmake�entnext � entupd ��Visual LISP ������������� ���

entlast

(entlast)

entlast ��������� command �������� �������! �"#���$%&'()*+,-./$%&'0�1234�

567

89�:�;<=>���[email protected] nil�

BC

DEF e1 GHI������JK%L����:�

��� (setq e1 (entlast))<���� 2c90538>

;<M�NOP'JKQLRST��UV��WX��Y.Z�[\ �]^ entlast�

(defun lastent (/ a b) (if (setq a (entlast)) ���� �� (while (setq b (entnext a)) ���������� (setq a b) ������� ) ) a ���� ��) ����

� entdel�entget�entmod�entnext � entsel ��

56���JKQLRST�V89U��Y�:

Page 67: AutoLisp Reference

entmake | 67

entmake

(entmake [elist])

entmake ������������

��

elist ������������ entget ����������� elist ����� !"���#$�%�� &'()*+,-.��������/��01�� nil 234!"/�� &'()*56�����7&�89�entmake :;<(=

��>?7& CIRCLE LINE9��@ elist ���A��B�C-DCED &'@CED�FGC-D��@��H

IJKLMN�entmake ��!"O��P1Q)��H &' elist ��B� *��RS�/RST1UQ)

��=

&'VW�X entmake ���������� &' entmake YZ!"���X�� nil

[��\V]7� endblk :; entmake9��[H�^_@`a������ bc��[�defg�h�i Visual LISP ������B�j!"kl��m

no

Np�qr!"-.st�u (color 62)�uvw (4,4)�xyw 1 56��8z{?6D|U()*�}~���w<(=

��� (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 :;��

_�:; entmake !"����

��������� 66 �r������� ��{� 66 �rU�����w 1 ������������/�r�<(=w 0 ����{��]���@����

 ; entmake ��P�¡¢����r 27[H$£9@56� &'I�������B()*[H�AutoCAD ¤!"-.O[¥¦X§;¨©�[H!"¡¢

I��B!"-.O��

Page 68: AutoLisp Reference

68 | AutoLISP ��

��� entdel�entget � entmod ��Visual LISP �������� ���

������������������������� ���!"�� entmake �#$����%&�������%&�����

entmakex

(entmakex [elist])

entmakex ��'()*��+,����

��

elist ��)*��-��./0 entget ��123-�./45elist ��6789�����:;6<��=>?@ABCDE67�)*���F��GH23 nil IJK��F��=>?@A'L�)*��M=�NO�entmakex #$P?Q

23Q

=>RS�T entmakex 23)*�����-=> entmakex UV�����T23 nil

WX

$ (entmakex ’((0 . "CIRCLE") (62 . 1) (10 4.0 3.0 0.0) (40 . 1.0)))<��YZ 1d45558>

[\] ^_1_`�ab���cdef .dwg + .dxf gh�ij�#$ entmakex klm1_`X=�'(#$ dictadd lmnopq_Fab

��� entmake ��

entmod

(entmod elist)

entmod ��rst elist � -1 uv)���Y���w��AutoLISP rs��w���xyzV{�|$ entget ��}~���)*�����)*���-�

��DEsab+������DE�����YM�cv)1_`O�I23s���Y�

��abM��O�)*��

Page 69: AutoLisp Reference

entmod | 69

��� entmod �������� ��entmod ������� ���������� ����

��

elist � entget ����� !"#��

�$%&'�()*� �+,-./0�entmod ����123��456789()���:;<��$'�3��

�+,-=>?@0�-ABC�D()��entmod ��EFG6H�IJ�567893��

��*

-A9K�L entmod �� elist�-A entmod MN��OP ��L���� nil�

QR

STUVWX ��YZ����� ��

5[\ en1 �*]^_ ���`a ��bcd

UVd (setq en1 (entnext))< �bd 2c90520>

5 � en1 � ��efg[\ ed �d

Page 70: AutoLisp Reference

70 | AutoLISP ��

��� (setq ed (entget en1))((-1 . <���� 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))

ed ��� ��� 0 ���� 1�

��� (setq ed (subst (cons 8 "1") (assoc 8 ed) ed ))((-1 . <���� 2c90520>) (0 . "CIRCLE") (5 . "4C") (100 . "AcDbEntity") (67 . 0) (8 . "1") (100 . "AcDbCircle") (10 3.45373 6.21635 0.0) (40 . 2.94827) (210 0.0 0.0 1.0))

���� en1 ������

��� (entmod ed)((-1 . <���� 2c90520>) (0 . "CIRCLE") (5 . "4C") (100 . "AcDbEntity") (67 . 0) (8 . "1") (100 . "AcDbCircle") (10 3.45373 6.21635 0.0) (40 . 2.94827) (210 0.0 0.0 1.0))

entmod �����

�� entmod �������������

� !�"�#���$%&'()*+�,-./012!34� entdel ��5671894� command : entmake ��;<=��)

� entmod �� !��>?@1* SEQEND ��� -2 ����1*+A��./���1BCDEFG)

� !�� entmod ����HI��)

JK���LMJNO�� 0 : 1PHIQR6ST)*+� entmod ����UV,W���1X��BYZ��XV���[\)

]� entmod ����^_��`1a3bc:defgh�i?)*+jklm�fgh�� nX^_�]�fgh1J!BopqrstP40 & 41 T)

uvw JK� entmod ����V,W���1x./0J!Byz{�|}�V1~� AutoCAD DE��)

��N entdel�entget�entmake & entnext ��)Visual LISP �������

������&�������&�����)

Page 71: AutoLisp Reference

entnext | 71

entnext

(entnext [ename])

��

ename ������

��

�������� entnext ���������������� ��������� ename ��!���������� ename ��"�#����� �����������$%#�������� nil entnext ��&'(��)���*'(��+��

,-

(setq e1 (entnext)) ; �� e1 ���������(setq e2 (entnext e1)) ; �� e2 � e1 ���

./

ssget ��012�345�678)����789:;<=>?@A'(BC�� entnext ��DEFG���+��HIJFG���KLMNOP+���"�'(QRSTU���,RS+��OP+���"�V'(�(#

WXYZ��)��[�� entnext ��\]YZ SEQEND ���!��� -2 ^�_78`��)���

a�b entdelcentgetcentmake d entnext ��

entsel

(entsel [msg])

��

msg �efg�h�ijk��lm!���nfgopq

r34sQt

���1��#��sQu��v�

fg�hBCwx��AH34y�sQu��v

Page 72: AutoLisp Reference

72 | AutoLISP ��

���

����� ���������� ���� ����������

���� �!"�#�$% UCS �&'(

entsel )*����� +��,����-�.���������/01"�23(�� 4��56�789:;��<�=>4$%?@AB(

CB

DE� AutoCAD FGHIJ entsel )*�K�LMN�����O

FGO line P O 1,1 D� O 6,6 D� O ENTER FGO (setq e (entsel "Q������O")) Q������O 3,3(<� �O 60000014> (3.0 3.0 0.0))

R�S,TU������+VWX������Y�ZWX[\��� (

B], AutoCAD � Object Snap ^N BREAK_TRIM 4 EXTEND FG`�aC(entsel Kb AutoLISP cde^fgahTU(.ij�� �Lkl��m���(no,)*UpqrI�st initget )*uvw$% Osnap x3(entsel )*yz.%Eij{� initget )*x3�7|0(

Q�} entget_entmake 4 entnext )*�

entupd

(entupd ename)

�*

ename WX~��� ���(

~���#� '����&

Page 73: AutoLisp Reference

eq | 73

���

����� (ename)�� ������ nil

��

�������������������� !"#�$%&'�() *+

,-.�/0!"#1

(setq e1 (entnext)) ; � e1 �������(setq e2 (entnext e1)) ; � e2 ���� ��(setq ed (entget e2)) ; � ed ������(setq ed (subst ’(10 1.0 2.0) (assoc 10 ed) ; � ed ������ ed ; ��� (1,2) ) ) (entmod ed) ; ��������(entupd e1) ; ������� e1

��!"#23

�45 entmod +,6� 789:�;<!"#��83=>��?@ABCD��EF��entupd GH *?@AB��+,I�!"#83*!"#83�J�FK���LMNH�O *P5QGHentupd R5S32T�=>�!"#�JU��O *P5QGHQGH.VW@AB�Q��7XY

Z�[��<

\] �^_`��73a���<8XY_`���345 entupd GH���b�� cCc.VWdefghiW.VWjk�lmP5 REGEN no

pNq entgetrentmod 2 entnext GH

eq

(eq expr1 expr2)

eq GHe�st; expr1 2 expr2 �uvwMx�^y7��5 setq GHvw<

e�z�st;�u{�|x�}~��

Page 74: AutoLisp Reference

74 | AutoLISP ��

��

expr1 �������

expr2 expr1 �������

���

�������� T����� nil�

��

����� !

(setq f1 ’(a b c)) (setq f2 ’(a b c)) (setq f3 f2)

�� f1 " f3!

# ! (eq f1 f3)nil

$% f1 " f3 &'����()�*�+,�-. eq �� nil�

�� f3 " f2!

# ! (eq f3 f2)T

$% f3 " f2 �*�+,�-. eq �� T�

/�0 = " equal 1��

equal

(equal expr1 expr2 [fuzz])

��

expr1 �������

expr2 expr1 �������

fuzz 2���3 expr1 " expr2 45�6789:;�:;<=>?@A�B'C%DE�F�

G��H,2�IJK2�LM���NOA�PQRSF�H,����

T�)��UVWX�Y�Z[\]^[;_�\.�� fuzz ��.`aK�UVWX)�bcd�:;�

e�H,���R��F

Page 75: AutoLisp Reference

equal | 75

���

������� ����������� T,���� nil�

��

�������

(setq f1 ’(a b c)) (setq f2 ’(a b c)) (setq f3 f2)(setq a 1.123456) (setq b 1.123457)

� f1 � f3 !�

"�� (equal f1 f3)T

� f3 � f2 !�

"�� (equal f3 f2)T

� a � b !�

"�� (equal a b)nil

a # b $%&'()�* .000001�

� a � b !+,- fuzz .�/* .000001�

"�� (equal a b 0.000001)T

0� a # b $%&'()�����( fuzz �+12 equal 3*��$%���

! eq # equal 4�

eq 4�3*��(���567+equal 4���83*9:���

equal 3*��(��67+eq ��83*9:���; equal 3*��(��� eq <��3*9:���

=.> = # eq 4��

Page 76: AutoLisp Reference

76 | AutoLISP ��

*error*

(*error* string)

�� *error* �� nil�� AutoLISP �� ���������������� AutoCAD ���� !"��#$%&'(��)*

+, *error* -)./�0�)1+ command -)2� (command)3*45./67

89� command -)�� AutoCAD :;*

<=>

?@+ vl-exit-with-value A�B-)C<=>*

5D

�E-)FGH AutoLISP ��IJ��KLMN�OPQ��RST��#$R

(defun *error* (msg) (princ "��R") (princ msg) (princ))

U�V vl-exit-with-errorWvl-exit-with-valueWvl-catch-all-applyWvl-catch-all-error-message T vl-catch-all-error-p -)*

eval

(eval expr)

�)

expr XYZ[\]*

<=>

^[\]_>`abc�*

.�+,����IJ-)

<= AutoLISP [\]_>c�

Page 77: AutoLisp Reference

exit | 77

��

�������

� � (setq a 123)123� � (setq b ’a)A

�������

� � (eval 4.0)4.0

� � (eval (abs -10))10

� � (eval a)123

� � (eval b)123

exit

(exit)

���� exit �������� !" quit/exit abort�#��$ AutoCAD %� &'(

)*+ quit ��(

exp

(exp num)

*�

num ,�(

���

,� (num) %-./��(

012345�6789

��:� e (2.718282...) %;<=>?-./��@

Page 78: AutoLisp Reference

78 | AutoLISP ��

��

��� (exp 1.0)2.71828

��� (exp 2.2)9.02501

��� (exp -0.4)0.67032

expand

(expand n-expand)

��

n-expand ��� �������������������

� n-alloc ����� n-alloc ������ n-alloc �� usubr� n-alloc �� �� n-alloc * n-expand cons !"

#$ n-alloc %&'()*�

+,-

�./� n-alloc �����(��0�

��

1(�)*23% 100�

_$ (alloc 100)1000

%45��(�����

_$ (expand 2)82

#�6789 AutoLISP :;<=>? 200 5����@���@usubrs A �BC 8200 5�� cons DE����

F�G alloc H��

% AutoLISP ����IJ

Page 79: AutoLisp Reference

expt | 79

expt

(expt number power)

��

number �����

power number ����

�� ��������������������

��

��� (expt 2 4)16

��� (expt 3.0 2.0)9.0

fill_image

(fill_image x1 y1 width height color)

(x1,y1) ���� !"#$%�&'()&*�+,�- !"#�$.�&'/0&*12$%�&�3456 (width,height) 7��89 (0,0) :;<=>?�()&�@ABC dimx_tile D dimy_tile E�FGHI/0&����

fill_image E�JKL start_image D end_image �E�BCMNBC�

��

x1 "#()&� X ���JK�O��

y1 "#()&� Y ���JK�O��

width "# !PQ34R x1 �ST'A=U�V+*�

AW����X��YZ[���

L\]^_�4`a<=>?bc%� !"#

Page 80: AutoLisp Reference

80 | AutoLISP ��

height ������� y1 � ����������

color AutoCAD ��������� !��"#$%&

'(#

�������)"�

*+

(setq color -2) ;; AutoCAD ,-./���(fill_image 0 0 (dimx_tile "slide_tile") (dimy_tile "slide_tile") color)(end_image)

findfile

(findfile filename)

findfile 0"123�4567� filename �89:;<=>�?@A filename �BCD>EFG /HIJKLfindfile 0"A AutoCAD �MHINOP23�?@D>QEFG /HIJKLfindfile RAD>�HI�23�

�"

filename 123�45�HI�:S�

��TUVW�XY:S

���� ADI Z[X \]

–2 BGLCOLOR AutoCAD ̂ �./�_J��

–15 DBGLCOLOR _J`a,-�

–16 DFGLCOLOR _J`a�4b��J-�

–18 LINELCOLOR _J`ac���

A AutoCAD Mde�23D>45�HI

Page 81: AutoLisp Reference

fix | 81

���

��������� ��������������� nil

findfile ������ open ����

!

��"#��$ /acad2000 %&'��� abc.lsp��()��*��+,���-

./- (findfile "abc.lsp")"C:\\Program Files\\ACAD2000\\abc.lsp"

��"#012345�1 /acad2000/drawings ��(�%6789 ACAD :;$ /acad2000/support�<� xyz.txt =>1? /acad2000/support ��(��()���+,���-

./- (findfile "xyz.txt")"C:\\Program Files\\ACAD2000\\support\\xyz.txt"

��1@AB��'C>1� nosuch�� findfile �� nil-

./- (findfile "nosuch")nil

fix

(fix number)

fix ��DEF�G�HI�J number K�HI��

L�

number F�

���

number K�HI

�� number M?NM�OK��G?NG�OK�P1 32 QRSTIUV +2,147,483,647 W -2,147,483,648X�fix ��YZG�HI[\�F�P]^ AutoLISP W AutoCAD _`K�ab:cd1 16 Q�efgX

YZF�G�HI�JhijkK�[��lK�

Page 82: AutoLisp Reference

82 | AutoLISP ��

��

��� (fix 3)3

��� (fix 3.7)3

float

(float number)

��

number ���

��

number �������

��

��� (float 3)3.0

��� (float 3.75)3.75

foreach

(foreach name list [expr...])

foreach ������������ !"#$%&'�()����*+,��-./01��*+�

��

name �� !�2$%345/0�&'�

list 67,�� !89���

expr 7) list � !,���*+�

������:;�� �

����<=9>./0&'�?@AB�*+,�

Page 83: AutoLisp Reference

function | 83

���

����� expr �� ����� expr�foreach �� nil

��

����������

��� (foreach n ’(a b c) (print n))ABC C

foreach ��������� ������ C !��"#$��%$&�'(�

(print a) (print b) (print c)

) foreach *��������+,��

function

(function symbol | lambda-expr)

function -." quote -.'(�)/012 Visual LISP 34506.789:-.;< defun �=-.�>?@ABCDEF

G function H<IJ34 lambda �+,KLM Visual LISP IDE N�0OPQRST

6.

symbol �U-.VW

lambda-expr �#X,�+,�

(LAMBDA arguments {S-expression}* )

���

�+,Y���

12 Visual LISP 34506.Z89[-.@ABCDEF

Page 84: AutoLisp Reference

84 | AutoLISP ��

��

����Visual LISP �� �������� lambda ����

(mapcar ’(lambda (x) (* x x)) ’(1 2 3))

������ function ����� ! lambda ���"#��$�%�

(mapcar (function (lambda (x) (* x x))) ’(1 2 3))

gc

(gc)

gcd

(gcd int1 int2)

��

int1 &' 0 �(�$

int2 &' 0 �(�$

)*+

(�, int1 - int2 ./�0&12�$

��

34� (gcd 81 57)3

34� (gcd 12 20)4

56789��:;<�=>��?@

)*AB(��0&12�

Page 85: AutoLisp Reference

get_attr | 85

get_attr

(get_attr key attribute)

��

key �������� �������

attribute �������� DCL ������

��

�� �!"# DCL $�%������&'( �

get_tile

(get_tile key)

��

key �������� �������

��

�� �� �

getangle

(getangle [pt] [msg])

)*+,-����./��

)*+,-����01234

56789:;<=>?�@A7B?CD���>?

Page 86: AutoLisp Reference

86 | AutoLISP ��

��

pt �� UCS �����

���� pt ��������������� AutoLISP ������� ��!"#��$����%&'(�

�)*+,-./��

msg 01����!123�

456

�������78�9�

getangle :��;<=>?@%A8�>?7BCDE% ANGBASE FG9H�����I�J��KLMN����O45����8�P1�'QRS��)

*+,7��TUV��� UCS � XY +,9�@%��

WX

Y,�WXZ[\] ^_�`a����b� getanglec

dec (setq ang (getangle)) dec (setq ang (getangle ’(1.0 3.5))) dec (setq ang (getangle "Which way? ")) dec (setq ang (getangle ’(1.0 3.5) "Which way? "))

_�\]

����fg����� AutoCAD �����hijkP1��������lm����hijk�n'�opq�rsthi�$u:�v'�8�wh

i45��6��� ��fg(xyz{-��I��������AutoCAD |}���~�����T�����L������J����

������� getangle :�45���MN���'��������� getangle :����'��CDE% ANGDIR H ANGBASE ���FGJ���m��������������� ANGBASE ���FGwA8���;<=>?�@%���� ANGDIR �FG�

��`n����� AutoLISP P�k��� getangle :�� ¡�

 �¢ getorient :��\]�I£�¤¥�

getcfg

(getcfg cfgname)

| acad.cfg ¦§� AppData ¨�©ª����

Page 87: AutoLisp Reference

getcname | 87

��

cfgname �������� ����������� 496 �����

cfgname �������� ����!

"AppData/application_name/section_name/.../param_name"

"#�

$%&'�(��) cfgname *+, getcfg "# nil�

-.

/0 AppData/ArchStuff 1��� WallThk �2 8�,��345678�!

34! (getcfg "AppData/ArchStuff/WallThk")"8"

9�: setcfg ;��

getcname

(getcname cname)

��

cname <=>34?@A�BC�DE34?�F������ 64 ����

"#�

�) cname ��GHI�BC�JKLM2�<=>34?�getcname ;�"#A�BC�DE34?��) cname ��GI�BC�JKLM2�DE34?�getcname ;�"#<=>34?��) cname �*+34?�,;�"# nil�

-.

N AutoCAD OEP1�Q2R!

67 AutoCAD 34�<=>?@DE?

Page 88: AutoLisp Reference

88 | AutoLISP ��

(getcname "ETIRER") �� "_STRETCH" (getcname "_STRETCH") �� "ETIRER"

getcorner

(getcorner pt [msg])

getcorner ������� UCS � �������������������� �!"#$���%&'(��)*+ msg ��,��-�./0���12+

��34567�� AutoLISP �89:;< getcorner �=>+

��

pt ������+

msg �?-�����12+

@AB

C getpoint ��DE�F��@A��� UCS ����+GH��-I��,JK��F��LMNO Z � �PQ�� R�S Z � +

TU

VWX (getcorner ’(7.64935 6.02964 0.0))(17.2066 1.47628 0.0)

VWX (getcorner ’(7.64935 6.02964 0.0) "YZ[� ")YZ[� (15.9584 2.40119 0.0)

getdist

(getdist [pt] [msg])

\]^_��56)*`a�[���

\]^_��56bc

Page 89: AutoLisp Reference

getenv | 89

���������� ���������������������

���� ����!"#� AutoCAD �$%��&'()*+�,� ����-.$%��&'()�/0�12314567&'89*+��

getdist :,;0�<,=)>?@��A�

getdist :,B�#�C$%DEFG'HI+#JKLM��NO��P���A�

��Q/!"R# AutoLISP *S)�TU getdist �VW�

X,

pt �YZ[Y���\$% UCS ]������^_��� pt��`�+��!"����

msg �a�+���Ebc���d �eX,�� AutoCAD QI+�+fg�

>?A

<,���h���0[Y��ij>?Ak[Y���.l���m initget :,�Gn'oHk 64�ijpqr�s getdist :,tu[Y�� Z vG�l>?�Y���

wx

(setq dist (getdist)) (setq dist (getdist ’(1.0 3.5))) (setq dist (getdist "How far ")) (setq dist (getdist ’(1.0 3.5) "How far? "))

getenv

(getenv variable-name)

X,

variable-name Ebc� �yz{�|}~���|}��������

��*]�����#�5�����9�

�Ebc�)>? ����|}�A

Page 90: AutoLisp Reference

90 | AutoLISP ��

���

����� ��������������� getenv ���� nil�

��

� ���� ACAD � ! /acad/support"#$%! NOSUCH ���&'

()' (getenv "ACAD")"/acad/support"

()' (getenv "NOSUCH") nil

� *+�� MaxArray ! 10000'

()' (getenv "MaxArray")"10000"

,�- setenv ���

getfiled

(getfiled title default ext flags)

getfiled ��./012345678� 9:;<=>%� ?�$@AB%C��DEFGHI�JKLMNOP6�ABQRS$ABT� UAB

%�

��

title ���� 234�VW�

default XYD�Z[AB%\F!]��� ("")�

ext Z[�AB=>%��� ext !]��� ("")&Z[�! * ;^$AB9:?�

�����678 dwg AB9:& getfiled ���2346./_I`a4�

flags b�;cdef?gh234�i!�X0j kl1m

BFGno1d�p�0qrs01 0 N 15 tu�Vv�;7w 0 N 15?� getfiled FxyzC flags ��'

1 ;d 0? {/|}UAB�%~���|}AB%�!���01����AB,�X k�d��!�����

DV�� AutoCAD AB234{/DE|}01AB%����AB%

Page 91: AutoLisp Reference

getfiled | 91

���������� �������������

���������� �� !"#

��$%&'()��*+& �,������AutoCAD ���-.��/��*+0123456'78#

4 9( 2: ;<��=>��?@��4ABC���?@�#

���$%'(�D getfiled �EF ext GHIJK�?@��L���MN?@�OPQR���ST'?@�#

8 9( 3: ��$%&'()( 0 MN$%�getfiled UH��VWXYZ[WX����#���VWXYZ�\

]&'���^�_`YZ�a)bcd���9e���

f �YZ�g\]&h�����^i��_`YZ�

a:#

��j$%'(� getfiled cdklmn�[���o�#

��p����qr]N���Ls�t����uv�

�94twHmV:�ix'$%'(#

16 9( 4: ��$%'(�4 default GHyYZaz{|}�D'GHb~���YZ�#getfiled ���K���������L��������I��YZ�)������

�I���=�[�#

32 9( 5: ��$%'(��$%&( 09,JK&������:�D����p��]N��O�����-.!

"#�����]�������,��h����)��

E�������#

64 9( 6: ������JK& URL�g�� ¡��#

1289( 7: �;< URL#

cd¢

�����Ik£��JK�����D getfiled cdJK����¤{¥#¦D'UHcd nil#

§¨

�¨I©� getfiled ����Select a Lisp File����ª

(getfiled "Select a Lisp File" "c:/program files/acad2000/support/" "lsp" 8)

AutoCAD �������ª

Page 92: AutoLisp Reference

92 | AutoLISP ��

getint

(getint [msg])

�� getint ������� � -32,768 � +32,767�����������getint ������ !��"�#$%&��'(���)*��+, AutoLISP -./012 getint ���34�

��

msg �56����789���:;<���=)��6��

��

>?

��@A��������B�����CDEF ENTER G�=>? nil�

HIJ%&����+,��K>?<��

L title ��MN

L default ���OPQRSMN

L ext ��MN

L default ���TUQRSMN�

�� default VW@ATU�=<X��YZ[

\�

Page 93: AutoLisp Reference

getkword | 93

��

��� (setq num (getint))1515

��� (setq num (getint "������"))������2525

��� (setq num (getint))15.0 �����1515

��� ����� initget ���� Visual LISP ���������getxxx ����

getkword

(getkword [msg])

��� getkword ��� !"#�� initget ��$%&'�()*��+,-�� AutoLISP ./0123 getkword ��4�

��

msg �567�+�*89�:;<=>��?@ getkword ,A7BC67DE�

FG�

*89?.7H�+��IJK�()*�:;�+��LMNOPQR ENTER )S?TU�+V&W� initget ��$%TX()*?@���FG nil�

:;�+��YZ'()*?getkword [A7\]DE?^67�+_`�

ab�cd�+��()*^FG>()*

Page 94: AutoLisp Reference

94 | AutoLISP ��

��

����� initget �� ������Yes���No����������� getkword !"#$�% bits &' 1��(��� getkword )

*+) (initget 1 "Yes No")nil

*+) (setq x (getkword ",-./�012 (Yes or No) ")),-./�012 (Yes or No) yes"Yes"

345 getkword �67���8�#$9:�;)

*+) (initget 1 "Yes No")nil

*+) (setq x (getkword ",-./�012 (Yes or No) ")),-./�012 (Yes or No) Maybe9:�<= ��>,-./�012 (Yes or No) yes"Yes"

�8�?@� initget AB� ���CD�EF getkword GHIJKL�(�M msg �NA�OPQRS�8>

6�T U��V� initget FW Visual LISP ������V��getxxx �>

getorient

(getorient [pt] [msg])

getorient FXYZ[\]^_�8NA�`aE,A�bcdefg[\�hi[�jYklakmn�op�qg>�8#$�qgrFst� ANGDIR � ANGBASE &n'uv�>(w�xyzqg{|#$�}~�]^;r�}�efg�hi[�MXYZ[\����w�����^ ANGDIR � ANGBASE �&n>���34�� UNITS *+���&n���^ ANGBASE � ANGDIR�

<��x����eguv[\�qg�^[\�5�� getorient ���V��(�������>

s�.x���^��}qg�Y@�� getangle �w�.x�NA[\��}qg�Y;@�� getorient >

�8� #$x� AutoLISP �¡¢Q?@ getorient �67>

£¤F¥¦�8#$qg��§¨zqg

Page 95: AutoLisp Reference

getpoint | 95

��

pt �� UCS �����

� �� pt ������������������������ AutoLISP ��!"�#$%&'(��)*+!",-.��/012345�

msg �6&7���89:�

;<=

>?";<@A��/012�!"�

BC

DEF (setq pt1 (getpoint "GHF"))(4.55028 5.84722 0.0) DEF (getorient pt1 "GHF")5.61582

I�J K�L�� getangle M�%N Visual LISP ��������Ogetxxx M�P�

getpoint

(getpoint [pt] [msg])

��Q$%RSGH����T$%RSUV%��WXYZ[7�\]�

���� &'^ pt ���_` AutoCAD abcd��e8f]Xgh�ijkl�cM��;<=-�� UCS ����(��

mn%op��UV�q;<c

Page 96: AutoLisp Reference

96 | AutoLISP ��

������ AutoLISP �� ��� getpoint ����

��

pt �� UCS ����������

�� getpoint !�"#$%&'��(�)* pt ��+,-�.%/0��1�23��4561$ LASTPOINT 789:�;)*<�+= pt )*/0+>?��@ABCD LASTPOINT �EFG36H�IJKLM��@AEF�6H

NON�PQ�/0*23;���

msg �DRS���TUV�

WX;

�� UCS ������

YZ

(setq p (getpoint)) (setq p (getpoint "[\] ")) (setq p (getpoint ’(1.5 2.0) "^��_"))

��` a���� getcorner O initget !�+$b Visual LISP ��������

cgetxxx !�d�

getreal

(getreal [msg])

������Ie AutoLISP �� ��� getreal ����

��

msg �DRS���TUV�

WX;

�����(��

fg$h����(�,WXi(�

Page 97: AutoLisp Reference

getstring | 97

��

(setq val (getreal)) (setq val (getreal "�����"))

getstring

(getstring [cr] [msg])

���� � AutoLISP ������ getstring ����

��

cr ����� ��! "# nil$%&���'()*+,

-./!012 ENTER 345�67$���'()+./38 ENTER 345�

msg �9�:���'()�

;<"

�����'()�������.'()=>?2@ ENTER 3ABC��DEF$7;< nil�

�����'()GHIJ 132 K'($getstring L;<MN� 132 K'(������'()O,P�QR (\)$%& QRSTUVWXKQR (\\)�Y���Z*+[ �\�O]�,P^_`ab�;<"�

��

cd� (setq s (getstring "e�`'f "))e�`'f Gary"Gary"

cd� (setq s (getstring T "e�g`f "))e�g`f Gary Indiana Jones"Gary Indiana Jones"

cd� (setq s (getstring T "���^_`�"))���^_`� c:\my documents\vlisp\secrets"c:\\my documents\\vlisp\\secrets"

��h i�jO� initget \����klm����noKpqrs=t3'Fuv$��h getkword \��

wx+yz����'()${;< '()

Page 98: AutoLisp Reference

98 | AutoLISP ��

getvar

(getvar varname)

��

varname ������� �� �������� AutoCAD ���������������

���

������ ! varname "#$%�����&�� nil�

'(

)*+,-.����/

01/ (getvar ’FILLETRAD)0.25

��� setvar 2��

graphscr

(graphscr)

32�45� GRAPHSCR 01�6789:;<=>�textscr 2�# graphscr 2��?@2��

���

nil

grclear

(grclear)

)ABC AutoCAD �����

DE AutoCAD FG:;

HI��JKLMNOP

Page 99: AutoLisp Reference

grdraw | 99

���

nil

grdraw

(grdraw from to color [highlight])

��

from ������ � ����������� UCS ������AutoCAD ����� !"#$%&�

to ������ � ����������� UCS ����'( ��AutoCAD ����� !"#$%&�

color )����*+���,-�./���0 -1�1��0 XOR �2��3456�78��*9,-:;<=>?@���,-A2�34�BCDEFGHIJK,-�

highlight L 0 )���� %&MN�OPQ%56R*+���ST0UV��

.WX highlight ����0 0�1 grdraw Y8ZT%&[6�

���

nil

\�] *+^ ��_Y8 grvecs `��

grread

(grread [track] [allkeys [curtype]])

aKbc8d� AutoLISP _8efghi8j`��AutoLISP �k^�lm_Y8no getxxx `�Rpq�

r��st��� uv%&(w��V

x AutoCAD �yz(olmMN�{|��

Page 100: AutoLisp Reference

100 | AutoLISP ��

��

track ��������� nil�������������

��������� !"

allkeys #�$�%� grread &'()*�"allkeys )+,-�./012345*�"016��7�8

1 9- 0: ��;<�=>? !"���@A�-�BCDEF������BGHI7IJKLM�grread ��N��O,P�QO,RSFT$UV 5�QW,RSFXY����9Z!K�[\]:)-@ ! (X,Y)�^NF AutoCAD _`<�)ab"

2 9- 1: ��cH)L��de*�Lfg!LUV�CDI7g!L�h���g!"

4 9- 2: iC curtype ��jk)�lmg!)no"

8 9- 3: pCDI7 ESC L��no.qrstu"

curtype #�$�Pvnog!)T$"EHX allkeys ��)QW- 1 � curtype ��wHx"���ElmXY grread ��yC�no)g!T$"016�7z curtype �8

0 no{|}[g!"

1 �nog!9~}[g!:"

2 no����g!"

���

grread ����O,P��QO,���v��T$)UV�QW,���0�F#���0�F��^�%���)T$"���zP�78

grread ��)���

QO,�� QW,��

� ��T$ � �v

2 LM�� �� [�UV

3 ��� ��� � !

Page 101: AutoLisp Reference

grread | 101

�� grread ������

� grread ���� ������� ESC ��������� AutoLISP ��� !"#$%&� allkeys '()*+,-./0123���45678 grread �+�9:���;<=>���?@/

AB��CDEFGHI�JKFGHL��&M?@�N�grread OPQRSTU 6 I 11 �VW�XCYZ�����[\(OPSTVW 12/]U^>CDE�_`ab���&M?@�N�STVW 12 cdeYCSTVW 6 I 11 fZOP/

4 DE /�JFGH"��&M?@gh.

0 ij9991001 i 19992001 i 29993001 i 3999Ak5l16001 i 16999

DEFGHmPOP1 FGHmPOP2 FGHmPOP3 FGHm….POP16 FGHm

5 &M?@"nC%&eo?@�OP.

pqM rstKuv

6 BUTTONS FGH 0 i 9991000 i 19992000 i 29993000 i 3999

BUTTONS1 FG�NmBUTTONS2 FG�NmBUTTONS3 FG�NmBUTTONS4 FG�Nm

7 TABLET1 FGH 0 i 32767 wxyFG�Gzm

8 TABLET2 FGH 0 i 32767 wxyFG�Gzm

9 TABLET3 FGH 0 i 32767 wxyFG�Gzm

10 TABLET4 FGH 0 i 32767 wxyFG�Gzm

11 AUX FGH 0 i 9991000 i 19992000 i 29993000 i 3999

AUX1 FG�NmAUX2 FG�NmAUX3 FG�NmAUX4 FG�Nm

12 &M?@�N"CST 6IST 11 ZOP.

pqM Muv

grread �OP{ ( �� )

|QRz} |~Rz}

{ ��ST { ��

Page 102: AutoLisp Reference

102 | AutoLISP ��

�������� ������������������ 12 �� !"#$%&'�()*+,�-./012���34��5678� grread 9�:�;

(setq code_12 (grread (setq code (grread))))

<=��>?!@AB<CD@A�E�CD���� 12 �FG-

grtext

(grtext [box text [highlight]])

H9��IJ$KLMN�OP�QRSTUVWIJX-SY��:� grtext 9��Z[\OP$]^_`aF-

��

box b���c�deOP�fg-

text ,e1hi� jkIJ$�lmn-5o text ��pq�rQ�stu-

highlight b���vwx(yzKjkIJX-

SY��:� grtext �Z[\OP${]^.w|F-5o}Y�~��:��grtext �����-

��F

text �����lmn-5o�� �MN���r�� nil-

�OPe1hi� jkIJ$

Page 103: AutoLisp Reference

grvecs | 103

�����

� box ����� 0 ���������������������� 0 �� �����!"# 1$%&'()* SCREENBOXES �+,� �����!"$-./0� highlight ���1��grtext 2��34�����5

6$3478��9��:;<=>?34���9@A34$-.��� 0�B��9CD34$-.���E�F�GHI$JKLMNO�56PQR

SCT highlight ��� grtext 2�U�������VWD�FXY4Z$[\]^CJ����_`�abXY4Z��_���9$

cd!�_

-.eS grtext 2�` box ����� -1�B�2�f�56Ug�hicd!�_$hicd!�jkl4Zm�CnoCnp q�4Zm�hicd

!rstuvw 40 8xyz${|}~S DIESEL ��i $(linelen) �+�hicd!�jk�

(setq modelen (menucmd "M=$(linelen)"))

-. box ���� -2�grtext 2���56Ug��^cd!�_$-.�^cd!��^4Z������������J��m�&����^�`�F

�f���62�Ug���_�56$box �� -1 � -2 `�HI highlight ��$

grvecs

(grvecs vlist [trans])

��

vlist �7'|� ���}~p1�z��8������*�$

��� vlist �i���� �¡�¢£�*��i¤$

trans ¥¦§¨�S�©)�ªJ�*�«��*���¬­$F

��®8¯�����°8¯�±�®8²���$

³´�

nil

Jµ¶��O·¸q8�*

Page 104: AutoLisp Reference

104 | AutoLISP ��

�����

vlist ���

([color1] from1 to1 [color2] from2 to2 ...)

�� ��������������� vlist �������� AutoCAD ��!"�# $%& 0 � 255 '(��!" )� 255�*�+��,� XOR -./01�23�45&�#6��789:��;<�=> ?@A��9

;<B�CDE,FG '(��!"H� 0�IJ2�+�� J21�#K�23LM�)NO23LM�PQ�3J2�RST23LM&����UV

���W�3

XYZ� from [ to �����XY\Z�C]&�A^ UCS �3� _TZ��&`aZ/baZ cde���XY\Z��=Z-fXYg+�Z�0

Whi�j*�= grvecs kO�l�I,Gm

AutoCAD ,I��nopq�rstu

vw

xy!"z{|tu}23~������?@��������

(grvecs ’(1 (1 2)(1 5) ��� (1,2) � (1,5) ��� 2 (2 2)(2 5) ��� (2,2) � (2,5) ��� 3 (3 2)(3 5) ��� (3,2) � (3,5) �� 4 (4 2)(4 5) ��� (4,2) � (4,5) �� 5 (5 2)(5 5) ��� (5,2) � (5,5) ���) )

�x���3� 1.0 ��w�����w������� (5.0,5.0,0.0) ��� '(I:�����}���}�C]I9�� (5.0,5.0,0.0)

’( (1.0 0.0 0.0 5.0) (0.0 1.0 0.0 5.0) (0.0 0.0 1.0 0.0) (0.0 0.0 0.0 1.0))

��� ��������������� nentselp kO

Page 105: AutoLisp Reference

handent | 105

handent

(handent handle)

handent ���������� ����������� ��

��

handle �����������

���

��� !"�handent ����#$%&'()*+,-����./0����� ���12 handent ��3456���789:$%��(;��< ����=>�� nil�

handent ������#$%&'()*+:?@��� ��AB C��� entdel ��DE=�

#FG�&'()*+G34���� �H>FG�I�����JKLF

M�

NO

PQR (handent "5A2")<�� R 60004722>

#FG�&'()SG34�GNTUVWXYZ��H>��FG���

�3[\]^�� �_�� =� ,��9/���`ab-���

help

(help [helpfile [topic [command]]])

cd�e��f�����=��e��f

� ghij

Page 106: AutoLisp Reference

106 | AutoLISP ��

��

helpfile ������� ��� helpfile ������ ("") ������ AutoCAD ���� AutoCAD ����

helpfile ��������� !������� !�� AutoCAD "#$%�������� !�� AutoCAD &�!'() .hlp�

topic *+������,-./0123��� topic ��4��� ("")���,-501���6789�

command �� �����:;/<=>�?@�ABCDEF

HELP_CONTENTS 01���GEH23�

HELP_HELPONHELP 01I�J����K���

HELP_PARTIALKEY 01LMNOP�5QR��

S�/<LM�T

command ��U?@4V WinHelp() W� fuCommand ��X��EH�� �WinHelp() W��Y?�Z Microsoft Windows SDK [ WinHelp API�

\]C

��^�_`�\] helpfile �� �a�\] nil����b��^� help��&_`c\]��� ("")��_`c\] nil�

help W�\]de�fghEijk4V�� helpfile ����l&�XmnoijkpqrNOPst�u�

vw

ABxy^� help 01 achelp.hlp [ MYCOMMAND 23z{F

(help "achelp.hlp" "mycommand")

|�Z *}~� AutoCAD ���z{�|�Z�����[I��Y�

���K�setfunhelp W��}5�A��*����u��F1c������

�u��Y��*����

Page 107: AutoLisp Reference

if | 107

if

(if testexpr thenexpr [elseexpr])

��

testexpr ������

thenexpr �� testexpr �� nil ������

elseexpr �� testexpr �� nil ������

���

if ��������������� elseexpr � testexpr � nil�� if �� nil

!"# (if (= 1 3) "YES!!" "no.")"no."

!"# (if (= 2 (+ 1 1)) "YES!!")"YES!!"

!"# (if (= 2 (+ 3 4)) "YES!!")nil

$�% progn ��

initdia

(initdia [dialogflag])

&'�()!"*+,- initdia ��#ATTDEF.ATTEXT.BHATCH.BLOCK.

COLOR.IMAGE.IMAGEADJUST.INSERT.LAYER.LINETYPE.MTEXT.PLOT.

RENAME.STYLE.TOOLBAR / VIEW

01234���5��267��8�

9:;<(=7!"�2>?

Page 108: AutoLisp Reference

108 | AutoLISP ��

��

dialogflag �������� ������ ���� 0���������������� ���� !"�#��

$�%�

�� dialogflag ��� 0�&' (��)*+,� -��(��./0%��$12�3456�

789

nil

:;

<=�>�(� initdia �?@�AB PLOT ��C

��C (command "_.PLOT")plotDEFGH� [?] <Model>C nilDEFGH� [?] <Model>C

AutoCAD �%�I>��JKL$DE�

���M-�(�0%NOPQ� !C

(initdia)(command "_.PLOT")

initget

(initget [bits] [string])

RSTUVWXDE�-� getintYgetrealYgetdistYgetangleYgetorientYgetpointYgetcornerYgetkwordYentselYnentsel Z nentselp�getstring -�#[��TUVWX��IDE-��

>\](��IDE-�^����IDE��#_`��ab��;�c getpoint -�_�`�b�#��d�� -��efVWXghij�I#kW

El��VWX����I�DEZgm���VWX_no�-��+Xpq

�rs78 VWX�`�tuv+�78�VWXL$ew�x�y��VW

Xz$_`{|����I�DE�#_`b�}Zgm~���VWX��n

o�AutoCAD ����I��DE�initget -�����9cVWXg���\�]�&��IDE-���

�\]��IDE-�(���VWX

Page 109: AutoLisp Reference

initget | 109

�� initget �������� ������������������������ !" #$%���&

�������'()�*+,-./01�2'34��567���5

68 AutoCAD 9:;<=>?��@A��&

B�

bits C�DE�F� �G�HI34JKLM�����&

NK��OPQ!RS0TUV�WX�8 YZ 0 [ 225 \]�6&��� ,- bits B� #^-_H 0&V��6�`a

1 0� 08 bc��dC ENTER e�f���g?&

2 0� 18 bc����56�f���g?&

4 0� 28 bc����h6�f���g?&

8 0� 38 34��2ijklmn\o���p Tq AutoCAD �rstu LIMCHECK ijv��wx (ON) y./z{|������������ }&

16 0� 480~j'q�8&

32 0� 58 ��������*����&�G�KOP���2kl����������,-�p��� ��

���9q��������:;w���'H��0J

K:;��������~�������8&��rstu POPUPS �w 0 AutoCAD 9$%���&

64 0� 68 bc�� Z �� Pq������������H� ¡¢&

128 0� 78 2£¤Q¥¦§����¨©ª�«e¬�­®` 34Q!��� ¯°±_H�«e¬�|&�

��²³´µG� 0a��¶7���� 7 �� 0 �·��de� ENTER e7 9��¸¬¹º&

»! AutoLISP ��¼½y¾O¿Àq�¦§ initget �� ¨P'>��ÁÂÃÄÅ��&

string �Æ«e¬Æ�¬¹º&«G-"«e¬�<= gBÇÈ

111É�Ê«e¬ËÌÍ&

��6

nil

Page 110: AutoLisp Reference

110 | AutoLISP ��

������

�� getxxx � �������������������������

�� !� "������

� #$%&'��

����(

)*(1)

)+(2)

),(4)

-./(8)

0�12 (32)

3456(64)

78 !(128)

getint • • • • •

getreal • • • • •

getdist • • • • • • •

getangle • • • • •

getorient • • • • •

getpoint • • • • •

getcorner • • • • •

getkword • • •

entsel •

nentsel •

nentselp •

Page 111: AutoLisp Reference

inters | 111

�����

string ������ �

������������������������� !"Width Height

Depth#$%&'�����

���()*�+,�-./�0 (-) 12�

���3456789�

� ����:;<��=7�+>?!@AB<��C7�+>?�=7�67

<�DEFG����HIFJK !"LType#,"eXit#�"toP#L�

� ������=7�+>?!A�MN��OP!Q�RN�A:;<�K

!"LTYPE,LT#L�S5TU!����:;<�:VWX����Y��

�0!SZ[\"EXIT,X#]^_��

"LType#."LTYPE,LT#S45���67`a]bc��d�e�f LTK^g]=C7L!hDEijklS������emDEnf���:;<�

����0!Sopqrst�67��uvw&�xy z!�eDEnf LTY � LTYP!{(nf L ]s|��

d string ��}~E=7�C7�0��!A��3OP!��3N�:;<

�!�(3�e}�nfS����� AutoCAD �)jk�

initget ����y������������0��9��nfy������!@�����^������

"local1 local2 localn _indep1 indep2 indepn"

xS�!local1 � localn ]y������!@� indep1 � indepn ]���^������

y�����.��^�������:Vu�!@�Y�����^����

����:V3����! �?�

(initget "Abc Def _Ghi Jkl")(getkword "\nEnter an option (Abc/Def): ")

nf A �� Ghi!nf _J ��� Jkl�

��  Visual LISP ����z�"�enf���¡¢£¤#�

inters

(inters pt1 pt2 pt3 pt4 [onseg])

¥4¡¦��§¨

Page 112: AutoLisp Reference

112 | AutoLISP ��

������ UCS �� ������������� inters ������������������ ��!�� inters ��"#$%&'()*+,-./ 0��!����

��

pt1 1 &2'�3��

pt2 1 &2'�4 3��

pt3 1!&2'�3��

pt4 1!&2'�4 3��

onseg ��567 nil 89�� pt ��6:�%&';<7�=>?����@A onseg ��BCDE7 nil 8��FGHIJ

K%&'/ L8 inters MN nil�

MND

�� onseg ��OPQ7 nil 8 inters MN��RS TU$���EPC�� &'VBW%&'X�3�YZ[\���]A onseg ��BCDE7 nil 8�

�FGHIJK%&'/ L8 inters MN nil���%&2'E^� inters ��MN nil�

_`

(setq a ’(1.0 1.0) b ’(9.0 9.0)) (setq c ’(4.0 1.0) d ’(4.0 2.0))

abc (inters a b c d)nil

abc (inters a b c d)nil

abc (inters a b c d nil)(4.0 4.0)

Page 113: AutoLisp Reference

itoa | 113

itoa

(itoa int)

��

int ����

���

int �� �����

��

��� (itoa 33)"33"

��� (itoa -17)"-17"

��� atoi ���

lambda

(lambda arguments expr...)

������ !"#$%&' ()*+, -.��/01234�� lambda ���lambda 5*+���6�7��)�89$:4;�<=>�?@!" ABC� lambda ����)DE - expr ���)�F apply GHIJmapcar ��K�$;LM!N�OPQR�-ST�

��

�� UV!"#����

expr AutoLISP !"#�

���

DE - expr ���

5���,���$W���XY

*+Z[��

Page 114: AutoLisp Reference

114 | AutoLISP ��

��

�������� Visual LISP ������ lambda ���

_$ (apply ’(lambda (x y z) (* x (- y z)) ) ’(5 20 14) )30_$ (setq counter 0)(mapcar ’(lambda (x) (setq counter (1+ counter)) (* x 5) ) ’(2 4 -6 10.2) ) 0(10 20 -30 51.0)

last

(last lst)

��

lst ��

���

�����

��

� � (last ’(a b c d e))E

� � (last ’(a b c (d e)))(D E)

layoutlist

(layoutlist)

����!"#$%&

��'()*+,-)./01234��

Page 115: AutoLisp Reference

length | 115

���

�����

�� (layoutlist)("�� 1" "�� 2")

length

(length lst)

��

lst ��

���

���

�� (length ’(a b c d))4

�� (length ’(a b (c d)))3

�� (length ’())0

��� vl-list-length ���

list

(list [expr...])

������������� !"#$%&��&'�()*�+�

��

expr AutoLISP �,-�

.��/-���012*�3

456�3*�,-(7)8&�

Page 116: AutoLisp Reference

116 | AutoLISP ��

���

������ ��� list �� nil�

��

��� (list ’a ’b ’c)(A B C)

��� (list ’a ’(b c) ’d)(A (B C) D)

��� (list 3.9 6.7)(3.9 6.7)

������������� !"# quote $%&�'#()��*�+# list $%,-.�/'0 ( ’) 1��2 quote $%�

��� ’(3.9 6.7) �� (list 3.9 6.7)

*34567����89:;�#�

<�= quote>vl-list* � vl-list-length $%�

listp

(listp item)

�%

item ?@AB>�C� ��

���

� item 2���� T�D��� nil�EF nil GHABIH��J"�%2 nil K listp $%�� T�

��

��� (listp ’(a b c))T

��� (listp ’a)nil

��� (listp 4.343)nil

��� (listp nil)T

LMN)�HDH�

Page 117: AutoLisp Reference

load | 117

��� (listp (setq v1 ’(1 2 43)))T

��� vl-list* � vl-list-length �

load

(load filename [onfailure])

load ��� ���� AutoLISP ����������������

filename ����� !"#$% filename ��&'(��)*��load �+,-����./01�)*�$%2-��34$56789: )*��

� .vlx� .fas� .lsp

�; load <=>? ���@ABC+,�����

filename ���DEFGHI�$ c:/function/test1��JK (/) LM�NJK (\\) OPQR STUV"$%� filename !"#�WQDESTHI�load �3� AutoCAD X+,FG�+,'( ��$%�Y�FG� Z�

[\<=]'(���load �@A��^

onfailure load _`.ab c

$% onfailure �PQR AutoLISP ��dAefgc�hijk5�onfailure �lm!"#LnoYp@qr AutoLISP l s9�� load �_`.tufvwx

abc

$%yz�dabc{|($% load � _`�dab onfailure c$% onfailure &(}�_`3~�����

e����� AutoLISP ���gc

Page 118: AutoLisp Reference

118 | AutoLISP ��

��

�������� � /fred/test1.lsp �����

(defun MY-FUNC1 (x) ... ��� ... ) (defun MY-FUNC2 (x) ... ��� ...

������ test2 ����� .lsp�.fas � .vlx � ��

� � (load "/fred/test1")MY-FUNC2

� � (load "\\fred\\test1")MY-FUNC2

� � (load "/fred/test1" "bad")MY-FUNC2

� � (load "test2" "bad")"bad"

� � (load "test2") �� AutoLISP ��

!�" #��� defun $%&' Visual LISP �������()*+$

%,-./

load_dialog

(load_dialog dclfile)

load_dialog $%01 AutoCAD �23456734 DCL �/

8$%9 unload_dialog �:;$%/<=>?@&ABCDE= load_dialog $%7FGCH DCL �/

�%

dclfile IJKFG DCL ��L)M/NO dclfile �%��IJ ����P���� .dcl/

FG DCL �

Page 119: AutoLisp Reference

log | 119

���

��������� (dcl_id)��� load_dialog ������������dcl_id ����� new_dialog � unload_dialog ������

log

(log num)

��

num ��

���

���

!

"#$ (log 4.5)1.50408

"#$ (log 1.22)0.198851

logand

(logand [int int...])

��

int �%�

���

�&��'()���* 0+�

!

"#$ (logand 7 15 3)3

"#$ (logand 2 3 15)2

��,-���./0�

��,-�12�3�45678 (AND) �9�

Page 120: AutoLisp Reference

120 | AutoLISP ��

��� (logand 8 3 4)0

logior

(logior [int int...])

��

int ���

��

�� ��������� 0�

��

��� (logior 1 2 4)7

��� (logior 9 3)11

lsh

(lsh [int numbits])

��

int ���

numbits int �����

�� numbits ���int ��� �� numbits �!�int �"�#$%&'()��*�� 0��+�,-

���./ numbits��012��

��

��3 int ������456378� �8� 31�9 0��:;����9�� <�=���9!���������lsh � 0

�>?��@A�B�C�DEF (OR) �G�

�H��I./�DE��3�G�

Page 121: AutoLisp Reference

mapcar | 121

��������C�C++ � Java � >> & <<����32 ������� 32 �������� 0� !"� 32 �#��$%&'()�

*+

,-. (lsh 2 1)4

,-. (lsh 2 -1)1

,-. (lsh 40 2)160

mapcar

(mapcar function list1... listn)

/�

function 0��

list1... listn �1�213�3��456� function /� 78�/�1

�9:�

;<=

3�

*+

,-. (setq a 10 b 20 c 30)30

,-. (mapcar ’1+ (list a b c))(11 21 31)

�:>?@A3BC.

(1+ a)(1+ b)(1+ c)

D mapcar 0�;<E��FG�3�

HIJ lambda 0�KLMN0�OE mapcar P��QRS0��/�TUV�E��WXYZ[��\]X^_J�@`�*+Ta Visual LISPbcdefgh��ijklmn�oJ lambda p mapcar.

qr�s0�/���1�213�t1uvYZwKL0�x�8=�yqE8=��zG

�3;<

Page 122: AutoLisp Reference

122 | AutoLISP ��

_$ (mapcar ’(lambda (x) (+ x 3) ) ’(10 20 30))(13 23 33)

max

(max [number number...])

��

number ���

���

������ �������������������������

��max �� 0�

��

��� (max 4.07 -144)4.07

��� (max -88 19 5 2)19

��� (max 2.1 4 8)8.0

mem

(mem)

mem ���� !"#$%&'(�'()*"+�,-./012�

GC calls AutoLISP 3456789:;<$"=��

GC run time 789:;>?"@ABCDEF�

��GHI��"JKL

�� AutoLISP !"MN%O

Page 123: AutoLisp Reference

mem | 123

LISP ���������� ������������� ������������ Dynamic memory segments statistics:!

PgSz ������"# (KB)

Used $%&��'

Free ()�*+�,�'-

FMCL ()��."/012

Segs $����'

Type 3��$�����45��6��789�

lisp :;�LISP �6:;

�<=>12�?@�A'BC

CONS ���CONS ��

::new�DE%&3��F�4��GE

DM Str����HIJ

DMxx ���KLMN LISP <O

bstack J�&P IO QR��6ST

UV�.W�XYZ.#�"#[$����'- AutoLISP \]^_`ab()�cd\���GE�efg&

KL:��h�ij�7kKL AutoCAD �lmno�b: p�qr�W0st� AutoCAD �uvwLKxy

Gz{7mem A'^wXYKL|(QRef���GE7}~XY� AutoLISP DM �ef�Y�GE L� AutoLISP 4^%& DM ����

���

nil

Page 124: AutoLisp Reference

124 | AutoLISP ��

��

��� (mem); GC calls: 23; GC run time: 298 msDynamic memory segments statistic:PgSz Used Free FMCL Segs Type 512 79 48 48 1 lisp stacks 256 3706 423 142 16 bytecode area4096 320 10 10 22 CONS memory 32 769 1213 1089 1 ::new4096 168 12 10 12 DM Str4096 222 4 4 15 DMxx memory 128 4 507 507 1 bstack bodySegment size: 65536, total used: 68, free: 0nil

member

(member expr lst)

��

expr �� ���

lst � �� expr � �

���

��� lst ���� expr���� nil�

��

��� (member ’c ’(a b c d e))(C D E)

��� (member ’q ’(a b c d e))nil

menucmd

(menucmd string)

menucmd ����� AutoCAD !�"#$%&'()*�+��,- !./�0��AutoLISP 12�3��456789 !�:;./<= !>5?@A� AutoLISP 12+��B5:C5DE !F�:G !FHIJK�

� �LM��N ���OPQ ���RDSTUV�� �<WXY

ZT !���:[\O]� !F^_

Page 125: AutoLisp Reference

menucmd | 125

��

string �������� ��������string ��������

"menu_area=value"

������ menu_area ����� !"#$��%&'()*+,-�./012�3�������4�

5�678�

B1–B4 BUTTONS 1 9 4�

A1–A4 AUX 1 9 4�

P0–P16 �5) (POP) 0 9 16�

I :;<$�

S SCREEN �

T1–T4 TABLET 1 9 4�

M DIESEL ����=)�

Gmenugroup.nametag >?@�AB�

CD�

nil

EF

��GHIJK:;<$ MOREICONS�

(menucmd "I=moreicons") �� MOREICONS ��� (menucmd "I=*") ���

�L�GHMN�5) POP11 �OP�Q�RS�TUQVWXYZ'�[ menucmd \�I]^'�

(setq s (menucmd "P11.3=?")) ��� ����(if (= s "") ���������� (menucmd "P11.3=~") �� !� �)

Page 126: AutoLisp Reference

126 | AutoLISP ��

�������� ������������������� �!"#

$%&'()*+�� (menucmd "P11.3=?") %�,-. "!."�/012!"#34

56��789:)*+/;� ������,<�2!"#5=>���?

�@��A+BC2��DEF�G wcmatch HIJK��A$%&LMNOP (~) �Q��RSTDUV�W?X�YZJ[\+

menucmd HI$]^ AutoLISP _`ab DIESEL RSTcdefgJhij+klm�� DIESEL nop%�q�rsJ AutoLISP ��noptuv+�w��-.78EF34xyz{|JRST}

(menucmd "M=$(edtime,$(getvar,date),DDDD\",\" D MONTH YYYY)") �� "~yx� 16 �� 1995"

��� �����AutoLISP ��!")���z���DIESEL J�������������+

menugroup

(menugroup groupname)

�I

groupname RST���!"�J��+

-.�

BC groupname �k85��!"�Y����-. groupname RST�Q�-. nil+

min

(min [number number...])

�I

number I�+

LM�Q�����J!"�

-.���IDJ���

Page 127: AutoLisp Reference

minusp | 127

���

������ number ���� ����� ������������� min �� 0�

��

��� (min 683 -10.0)-10.0

��� (min 73 2 48 5)2

��� (min 73.0 2 48 5)2.0

��� (min 2 4 6.7)2.0

minusp

(minusp num)

num ���

���

�� number ����� T ���� nil�

��

��� (minusp -1)T

��� (minusp -4.293)T

��� (minusp 830.2)nil

mode_tile

(mode_tile key mode)

���������

��� !"#$%&

Page 128: AutoLisp Reference

128 | AutoLISP ��

��

key ������� ��������

mode �������

0 �����

1 �����

2 ��� !"#�

3 $%&'()*�

4 +,-./0�

123

nil

namedobjdict

(namedobjdict)

4567�89:;<7�12�-=>?�@ABC;<-DE�F-DG

H�

nentsel

(nentsel [msg])

nentsel 7�IJ�K$%�LGH�MF�KNO��>PQR�STUV�GHWXYZ�![\]^_I`ab�cd>nentsel 7�cdCV� initget �e�fg��

��

msg �IJhi�� ��jklTm��>Q0Jn$%G

HoIJ�

12UV-D�]GH9:�-=>RpqrF-DGH�s

IJ�K��#t$%GHu-=v>wxyLGHq�z{�GH

Page 129: AutoLisp Reference

nentsel | 129

���

������� ��������������nentsel ������� entsel �� !"#$���%����������nentsel ����&'(�)*+,-./�01�2345167"8� entsel ����(9:��!� nentsel ����������%�012�$�����;<./2"nentsel ��=����>����?@01�A��45B���C������D���C�'01"nentsel ��E�������� SEQEND ./"

FG H.I�JK*�LM���>NOPQ./"R�+,-./"

��ST*UVW�nentsel ��DUVUV2345167"���5��ST&'<X$��UV�nentsel ��&'+,Y'/Z("

45[�*��$��(*�C&'/Z�\�*././2�C]'/

Z�&'(�)*+,��45D��W^>167"

C�'/Z_O`a67bcde67bfghi�R�&'+,Y'-(

(�Y'-(*j&'k+,[&'67l"Dhimn�op./>N�J

*1E_O`a67b (MCS) q<67bfgOde67b (WCS)"MCS r1�+,%�./�st1�$ MCS uvwxyz{D�W UCS vw|>"

FG nentsel �}&&'~�8�9ahi AutoLISP ��"nentselp ����hi�)� AutoLISP 3 ObjectARX ��~�hi9:"

CY'/Z�&'(�R+,[�>��%H�./2"�%���q,H

���*���*���xD(�+�q,D��%��./2"D(�

����E�q���@�w�����c�cst.I*������

�"

Page 130: AutoLisp Reference

130 | AutoLISP ��

��� MCS ��� WCS ���� ���� Visual LISP �������

��� AutoLISP �� AutoCAD ������������ !���"#�$

%&

��'()*+�,-./('�0123456�78"�9:;'�<='

($>?@>A,'(�01BC@>D�EF)GHI���JK$01L�

,MN/('�BO�P�Q�GHR��ST$

(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))

��� U���� entselVinitget ! nentselp 8"�EW Visual LISP �����

������XY8"�$

nentselp

(nentselp [msg] [pt])

�"

msg �QZ[�\]^$_`abc�"�de[�9:���

Z[$

pt 9:f$c�"ghLij�klm�no�pq��9:$

rst

nentselp 8"rs 4 × 4 �uv�wx_�y

Lij�klm�no��U8"�z{| nentsel 8"}~

Page 131: AutoLisp Reference

nentselp | 131

���������� ����������������

���� !����"#$%&'����(�����%�����)*�

%������+,��������-./�01234 1.0�5���67�8�9:� [M30 M31 M32 M33]�;<=0 [0 0 0 1]�������>?�"#-.@AB/�CD��E��F��%G���HIJ�GKL���MNO

PQ

�HIJRST%�U�V<0�WPX?Q

YKJZX?[)\����]^ ���67�8FWP_;`a�bcAB

/d�

efg nentsel "#�

hii hij hik hil

hji hjj hjk hjl

hki hkj hkk hkl

hli hlj hlk hll

m′n′o′jpi

hii hij hik hil

hji hjj hjk hjl

hki hkj hkk hkl

ipi ipi ipi jpi

m

n

o

jpi

⋅=

m′ mhii nhij ohik hil jpi( )+ + +=

n′ mhji nhjj ohjk hjl jpi( )+ + +=

o′ mhki nhkj ohkk hkl jpi( )+ + +=

Page 132: AutoLisp Reference

132 | AutoLISP ��

new_dialog

(new_dialog dlgname dcl_id [action [screen-pt]])

��

dlgname ������� ��

dcl_id � load_dialog��� DCL ���� �

action � ����������� AutoLISP �� �!"#$�������%&'(����)*� � ("")�!"��+ screen-pt ,-.�� action ���

/�012+3456�7��8(7�9:;< action_tile =�> DCL ? ����>@A=��BCD��������

screen-pt EFG������HIJ�KL� XMY N��(G;O���P��QJR�STUVWX:Y�Z[;

O�\]^K_�`�!"'(G��) ’(-1 -1)�abcd�

eT?`f��KLJgAutoCAD �hiHI�jkKLl�

m@[

!"noBm@ T�pBm@ nil�

q�r Visual LISP ������j�stu�v�

not

(not item)

wx�null =�����8 not =���Zy�z{|}3~{|�7�=��

��

item AutoLISP �� �

d�w4����?`(��8����w4����

��w4���[�"Pp) nil

Page 133: AutoLisp Reference

nth | 133

���

�� item ���� nil�� T��� nil�

��� (setq a 123 b "string" c nil)nil

��� (not a)nil

��� (not b)nil

��� (not c)T

��� (not ’())T

��� null ���

nth

(nth n lst)

��

n ����������������� � 0 !"#�

lst ��

���

lst ��$ n ������ n %� lst �&'(����) nth �� nil�

��� (nth 3 ’(a b c d e))D

��� (nth 0 ’(a b c d e))A

��� (nth 5 ’(a b c d e))nil

�����$ n ���

Page 134: AutoLisp Reference

134 | AutoLISP ��

null

(null item)

��

item AutoLISP ����

�� item �� nil��� T���� nil�

��

��� (setq a 123 b "string" c nil)nil

��� (null a)nil

��� (null b)nil

��� (null c)T

��� (null ’())T

��� not ���

numberp

(numberp item)

��

item AutoLISP ����

�� item �������� T���� nil�

� !" ��#$% nil

� !&"��������

Page 135: AutoLisp Reference

open | 135

��

��� (setq a 123 b ’a)A

��� (numberp 4)T

��� (numberp 3.8348)T

��� (numberp "Howdy")nil

��� (numberp a)T

��� (numberp b)nil

��� (numberp (eval b))T

open

(open filename mode)

��

filename ��� ������������������ �

���� !�" open # $ !% AutoCAD &'()�

mode �*���+,%����-./01234��56

789:�;<�

r ��-./=>�

w ��-.1=>��� filename ?@A�"BCD��E��F������@A�"GH$I��J�KL<MN

������J�O�A- close P�QR��STUVWX1Y��Z�

a ����-.34=>��� filename ?@A�"BC<MD��E��F[�� filename @A�"��\��E]���^_`I��J�a��-b1Y����J34`I

��J�Sc�

mode ��56%d12e1�A AutoCAD 2000 6f�ghZ�mode Oij-e1kl�

��<M���m$n AutoLISP I/O P�op

Page 136: AutoLisp Reference

136 | AutoLISP ��

���

���open ���� ��� I/O ����������������� !r"# filename $%&' open �� nil�

() & DOS *+,-./01�2345&67�2��89&�2:;<=����>?@ABCTRL + ZCDE ASCII F 26G�&H7��8IJK CTRL + Z @A8 L����>?MNO$P�QRSTU���V���W� OPEN ��� "a"BX<GY &��/0Z[\��2��Q]X<�V'

^_`ab./0cU&��2��:;d7 CTRL + Z >?@A�

ef

ghiU��j

klj (setq a (open "c:/program files/acad2000/help/filelist.txt" "r"))#<file "c:/program files/acad2000/help/filelist.txt">

m�n]ef, open Z����$%&j

klj (setq f (open "c:\\my documents\\new.tst" "w"))#<file "c:\\my documents\\new.tst">

klj (setq f (open "nosuch.fil" "r"))nil

klj (setq f (open "logfile" "a"))#<file "logfile">

or

(or [expr...])

or ��opq p,�pq rsKtDuv�wxyz nil pq �

��opq Du{4| (OR) }~�>�

Page 137: AutoLisp Reference

osnap | 137

��

expr ������

��

����� nil ����� T� �������� nil����������� nil

��� or !"#$�������"#$������� T

%&

'() (or nil 45 ’())T

'() (or nil ’())nil

osnap

(osnap pt mode)

��

pt *

mode +,-�./01234�54�6�789:;<=,

>� mid?cen @A�B<=,CDEFGHI

��

*��JKL���78>��JKMNL�OP78��OP78QRES

TU�789:;A���� nilosnap V����*KWSXYZ[\]^_`ab APERTURE �cd

%&

'() (setq pt1 (getpoint))(11.8637 3.28269 0.0)

'() (setq pt2 (osnap pt1 "_end,_int"))(12.1424 3.42181 0.0)

efg789:;$EShU*ijk34*�l��m*

Page 138: AutoLisp Reference

138 | AutoLISP ��

polar

(polar pt ang dist)

��

pt ������

ang �� ������������������ X � !"#$%&'�

dist ()*� pt �+,

-.�

/0 pt )*��12�-.������

34

polar 5678���9

:;9 (polar ’(1 1 3.5) 0.785398 1.414214)(2.0 2.0 3.5)

polar 5678���9

:;9 (polar ’(1 1) 0.785398 1.414214)(2.0 2.0)

prin1

(prin1 [expr [file-desc]])

��

expr <=>� AutoLISP ?@ABCD)*� expr�EFGHI

J�KL

file-desc M$ACN�OP�OPQR=

-.�

expr ��STFU��VWXY��Z prin1 -.K=[

\ UCS ]^_`�ab��)*��c)*+,d���e-.X�

\:;JCD78?@A�f?@AMghCN�OPi

Page 139: AutoLisp Reference

prin1 | 139

���������� ��� prin1 ���������������� !"#$%��&��'(�)*+,-./

01

234 (setq a 123 b ’(a))(A)

234 (prin1 ’a)AA

56�23$%789 A/

234 (prin1 a)123123

56�23$%789 123/

234 (prin1 b)(A)(A)

56�23$%789 (A)/

:;<=>� file-desc�5601�?�@AB�CD5/�� f E��=F�GHI�$J�KL�KLMNO�PQ6�R�STKLHUVOW�78

9VOW4

234 (prin1 "Hello" f)"Hello"

�� expr VOW�XYZ[VO�P prin1 '�\]� \ ^_`aVO��Q�bB/

Z[cd

cd ef

\\ \ VO

\" " VO

\e Esc VO

\n g�O

\r 9hO

\t TAB VOi[�Oj

\nnn kl[cd� nnn �VO

Page 140: AutoLisp Reference

140 | AutoLISP ��

�������� �����

��� (prin1 (chr 2))"\002""\002"

��� Visual LISP ���������������

princ

(princ [expr [file-desc]])

� !�"#$ prin1 !%&'()*� !+� expr �������"#,-./0�1234�56)prin1 12789�:9; load !<=), princ 12�789>?@A read-line B !CD�

�!

expr ��EF AutoLISP 789�G12HI� expr),-JKL

MFNO�

file-desc @P:91Q�RS�RSTU��

VWX

expr �X�Y-Z�![ \ !)> princ VWN�]�

��� Visual LISP ���������������

print

(print [expr [file-desc]])

� !�"#$ prin1 !%&'()*� !^ expr �_�$`�ab12LM�$NO�

�!

expr ��EF AutoLISP 789�G12HI� expr),-JKL

MFNO�

file-desc @P:91Q�RS�RSTU��

^��M12789)F+789Pcd1Q�RS�

^��M12789)F+789Pcd1Q�RS�

Page 141: AutoLisp Reference

progn | 141

���

expr �������� ����� print ������

�� Visual LISP ���������������

progn

(progn [expr]...)

�� ! "#$%&'()*��+,-./0#$%&1��23�! progn ���

expr "#45# AutoLISP $%&�

���

67"#$%&���

89

:;<=>�if ���?@A��B nil �<=>��."# then $%&CD1���E9�FG! H progn ���IJKL.M#$%&�1�N

(if (= a b) (progn (princ "\nA = B ") (setq a (+ a 10) b (- b 10)) ))

prompt

(prompt msg)

�OPQ� AutoCAD RS��prompt ���M#PQTU��V�W msg�X

Y�Z[ princ ��\I]�

^_2.`"#$%&CD1��a��67b#$%&��

�PQc�d��"#V�W

Page 142: AutoLisp Reference

142 | AutoLISP ��

��

msg ����

nil

��

�� (prompt "�� ")�� nil

��� Visual LISP ���������������

quit

(quit)

���� quit� !�"#���"# : quit/exit abort��$%&'()*��+ AutoCAD � �,-�.�

��� exit /��

quote

(quote expr)

��

expr AutoLISP 012�

expr ���

��

�� (quote a)A

34�01256789 ’a���

:;%&'(<�)*

�012=>?@A

Page 143: AutoLisp Reference

read | 143

��� !’aA

��� (quote (a b))(A B)

��� function ��

read

(read [string])

read ���� ����� ����������������� !�"#

��

string � �string ��$%&'(� �)*+,-

"#.

read ���/����01���� !2"#34567���read "# nil

34� ��*+8,-9�: 9;' (<=> LISP ? @�A���BC"#/������

DE

��� (read "hello")HELLO

��� (read "hello there")HELLO

��� (read "\"Hi Y’all\"")"Hi Y’all"

��� (read "(a b c)")(A B C)

��� (read "(a b c) (d)")(A B C)

��� (read "1.2300")1.23

"#� ������'(���FG

Page 144: AutoLisp Reference

144 | AutoLISP ��

��� (read "87")87

��� (read "87 3.2")87

read-char

(read-char [file-desc])

��

file-desc ���� � open��������������� file-

desc�� read-char ��� !"#$%&' !(��

)*+

,����(�� ASCII -�./0123(��4(�56�7�read-char 8�)*9:;1��ASCII -< 10��

=>

?>%@AB file-desc ���CD read-char .��"#$EFG�H�

��� (read-char)

��"#$<I�JK read-char LMNO !�

ABC65

NO !< ABC� read-char )*PQ:(� (A) � ASCII -�?RS:T read-char �UNVW)*��"#$%XY�H� ASCII - 66 (B)Z67 (C) [ 10 �;1���

��� (read-char)66

��� (read-char)67

��� (read-char)10

��� !"#$4����%\!Q:(��]^_(�`;abcd� ASCII -+e)*

Page 145: AutoLisp Reference

read-line | 145

����������� ��� read-char ����������

��� (read-char)

read-line

(read-line [file-desc])

��

file-desc ���� !"# open$�%&'(���)*+,-. file-

desc�/ read-line 0�������123��)

456

read-line 73�8 9!:;<=>? $)*+ read-line @AB��>?CD�/45 nil)

EF

G7HI'(���

��� (setq f (open "c:\\my documents\\new.tst" "r"))#<file "c:\\my documents\\new.tst">

J� read-line 0��173�=�

��� (read-line f)"To boldly go where nomad has gone before."

0����173�=�

��� (read-line)To boldly go"To boldly go"

redraw

(redraw [ename [mode]])

*+:K���� redraw ���LMNOPQR)*+��LSTUBVWX�

LYMNZ-.VW)

redraw ��[\]^_`abc�VWde�f REGEN ��ghiJVWGjklIMm_`)

0��a\'(��173=>? P�8 9

MNOPQRaOPQR1��n-.[o!VW$

Page 146: AutoLisp Reference

146 | AutoLISP ��

��

ename �������

mode ����������������mode ��������

1 � ��

2 !"��#$%&��'

3 ����

4 &����

����() (mode=3) *+,&����() (mode=4)-.$��

/0 ename 123��#456789�:�;'<=���>?@ mode ���AB�redraw C�DE���FGHI��JKLM�N@ mode ���OB�FPLM<=���

QR�

redraw C�QR�ST� nil�

regapp

(regapp application)

��

application UV�WXYZ[��*+�H\Z]^��_

� AutoLISP `aZ]H\�bc�d�� snvalid ef�

�gh AutoCAD �ijk�lV���$�mnDo�pqrs

Page 147: AutoLisp Reference

rem | 147

���

������� ����������� nil����������

�������������� APPID !"#$��#%&�'($)*+�,-�.�����

/0 (regapp "ADESK_4153322344")(regapp "DESIGNER-v2.1-124753")

�1 234+�5��������6789:5�;�<=>?@+�AB

CDE�7F��5����GH�4�IJ"KLMNOP /QRS�T67UDE�VW"�� ���$LXYZ��[\]^�.���_`�a�Lb

�c$�� (1040 2.1)�

rem

(rem [number number...])

d�

number e1���

��f�W��Qgh�d�ijk��� rem ���� (rem ... (rem (rem num1 num2) num3)... ) �l��

��gh�d�ijk��rem mno p�q\rsd��0����ght����� rem �u���v7uw���x�l�v7ut�����yz�{��

Uu���v7uw���|��{�

Page 148: AutoLisp Reference

148 | AutoLISP ��

���

����� number ��� ��� rem �� ���� rem ������������rem �� 0������� number ���rem �� number�

�� ��� (rem 42 12)6

��� (rem 12.0 16)12.0

��� (rem 26 7 2)1

repeat

(repeat int [expr...])

��

int ����

expr ������ �!"#�

���

$%��&'(� �!"#(������ expr ���repeat �� nil�

��

��� (setq a 10 b 100)100

��� (repeat 4 (setq a (+ a 10)) (setq b (+ b 100)))500

&'%�a � 50�b � 500�repeat �� 500�

�)*+,-����repeat ��$%��*+,�

��� (repeat 100 "Me" "You")"You"

./012(3��!"#45678�(9�&'�:��$%��!"#(�

Page 149: AutoLisp Reference

reverse | 149

reverse

(reverse lst)

��

lst ��

���

��

�� (reverse ’((a) b c))(C B (A))

rtos

(rtos number [mode [precision]])

� mode�precision ������� UNITMODE�DIMZIN�LUNITS � LUPREC ���� rtos ������ number �����

��

number ���

mode ���� !"#$%&�mode �'�()* AutoCAD ���� LUNITS �+,��-./0�

1 12

2 3�

3 45678�9:;7<=

4 >?678�@�7<=

5 @�

A��BCDEF�G��

A��HIJ���

Page 150: AutoLisp Reference

150 | AutoLISP ��

precision ������

mode � precision ��� ����� LUNITS � LUPREC����������

rtos ���� LUNITS � LUPREC ���

!"

#$%�&'()*+�,-./0+�,-12�34,-567 mode 8 3.4 1 59�UNITMODE �����!"�#$%:;<

=>

?@�� xA

BCA (setq x 17.5)17.5

D x � EF8GH+�,-�#$%��8 4A

BCA (setq fmtval (rtos x 1 4))"1.7500E+01"

D x � EF8I�,-�#$%��8 2A

BCA (setq fmtval (rtos x 2 2))"17.50"

D x � EF8)*+�,-�#$%��8 2A

BCA (setq fmtval (rtos x 3 2))"1’-5.50\""

D x � EF8/0,-�#$A

BCA (setq fmtval (rtos x 4 2))"1’-5 1/2\""

D x � EF82�,-�#$A

BCA (setq fmtval (rtos x 5 2))"17 1/2"

����� UNITMODE ?8 1 5�J?�KL34MNO34PQ�R rtos !"�#$%STU)*V (mode = 3).U/0V (mode = 4) �U2�V (mode = 5) �34WQXY>�A

BCA (setvar "unitmode" 1)1

BCA (setq fmtval (rtos x 3 2))"1’5.50\""

BCA (setq fmtval (rtos x 4 2))"1’5-1/2\""

Page 151: AutoLisp Reference

set | 151

��� (setq fmtval (rtos x 5 2))"17-1/2"

��� Visual LISP ���������� ���

set

(set sym expr)

set ��� setq ���� set ���������� setq ���� ������

��

sym �!�

expr AutoLISP "#$�

%&�

"#$���

'(

)*+���,-�! a ./ 5.0�

(set ’a 5.0)(set (read "a") 5.0)(setq a 5.0)

set 0 setq ,12-�!3/�4����� set 56%&�!�"#$3/���� setq 78�

��� (set (read "a") 5.0)5.0

��� (setq (read "a") 5.0); *** 9:�;<9:

��� setq ���

-=!���!>��.?@4�"#$��

Page 152: AutoLisp Reference

152 | AutoLISP ��

set_tile

(set_tile key value)

��

key ������� ��

value � �������������� value ������

���

����� value ��

setcfg

(setcfg cfgname cfgval)

��

cfgname � ������� !�"# cfgval ������cfgname ��$%&'()*�� �+

"AppData/application_name/section_name/.../param_name"

� �,-./ 496 0� �

cfgval � ��,-./ 512 0� �setcfg 1234�� ��567! getcfg ���

���

'89:;<�setcfg �� cfgval�'8 cfgname =>�setcfg �� nil�

?@

(ABCD AppData/ArchStuff �E� WallThk �����"; 8�F��� � "8"+

GH+ (setcfg "AppData/ArchStuff/WallThk" "8")"8"

I�J getcfg K��

�"LMN����

DO:�PQR acad.cfg S�� AppData �E

Page 153: AutoLisp Reference

setenv | 153

setenv

(setenv varname value)

��

varname �������� ������� �������

����������� !"#�

value ������$ varname ��%�

&'%

value

()

*+,-. MaxArray ����%/ 100000

,-0 (setenv "MaxArray" "10000")"10000"

�12��34567*89: AutoCAD ;<6=>�

?�@ getenv A��

setfunhelp

(setfunhelp c:fname [helpfile [topic [command]]])

��

c:fname ������BC�D,-EC:XXX A�FG!��HI c: JK�

.�� ���/��%

$LMNO��"PBC�DA��Q(�BCR?ST,-�LM;�UVWBXY�LM

Z[�\]

Page 154: AutoLisp Reference

154 | AutoLISP ��

helpfile �������� � helpfile ������������� ���������� AutoCAD ���� !"#��

�����������AutoCAD ��� helpfile $%&'(��� .hlp ��)�*+����AutoCAD ,-�����. .ahp #�� ��/)�*�� AutoCAD 01�2���# helpfile

topic ��������#3456�

command ������78 9:; Windows #< fuCommand ��

=>?

��@A�=>B. c:fname 9:#����C�=> nil

DE��F� c:fname ��<CGHIJ c:�K�F�E�<CL�MNO��<

CPQ

RS

TU#RS�V�WXYZE��[\] setfunhelp E�\^_ AutoCAD �� (acad.hlp) # circle 34`abcd

(defun c:foo () (getstring "Press F1 for help on the foo commad:"))(setfunhelp "c:foo" "acad.hlp" "circle")

(efgh�\] foo �i�jhk F1 lmn circle 34

DRSo<WXnS�KpHqrsV �qr\]��tuvw%x#�

��jhy��zE�`abc

�V�. test #E�d

�id (defun c:test()(getstring "\nTEST: " )(princ))C:TEST

yE�_��{`bc�\] HELP_PARTIALKEY fuCommand z���|line}~]d

�id (setfunhelp "c:test" "acad.hlp" "line" "HELP_PARTIALKEY")"c:test"

Page 155: AutoLisp Reference

setq | 155

�� test ���������� F1 � �������������line������ !�"�����#�

$% &' defun ()*+ C:XXX ()��,-./0 setfunhelp $1 23()4567� 89 :;�<=�>' defun ()*+?@'A*+ ��B�C=>' setfunhelp ()

DEF defun G help ()

setq

(setq sym expr [sym expr]...)

�H AutoLISP IJKL() MN�O setq () ?P>'�QR@STKL

E)

sym ST UVWXE)

expr YZ[

\]L

^B?@ expr L

_`

a ()>'bcd a e� 5.0f

��f (setq a 5.0)5.0

gPO a h�iL��j\]k) 5.0

a ��elm@cd b G cf

��f (setq b 123 c 4.7)4.7

setq \]^B?@cd L

`�b s e�"Snf

b?@oR@ST Lel�p�YZ[ L

Page 156: AutoLisp Reference

156 | AutoLISP ��

��� (setq s "it")"it"

��� x �

��� (setq x ’(a b))(A B)

��� Visual LISP ������� �AutoLISP ����

setvar

(setvar varname value)

��

varname ���� �������

value ������� !"#$%&'( varname�)*+,�� '-��. value '/01 -32,768 2 +32,767 34�

56'

)*78. setvar 56 value�

9�

$ AutoCAD :;<=>? 0.5 @AB�

��� (setvar "FILLETRAD" 0.50)0.5

setvar CDEF

GH AutoCAD ��1(IJK3L�MNOPQR+,�� '�)*1�� STUV�CD setvar W�G@+,��>?X'�YX'Z[\]^ST�_@ AutoCAD ��`abc�

1CD setvar W�d� AutoCAD +,�� ANGBASE `�value ��efgh'�ij AutoCAD � SETVAR ��kl�setvar ��$��mhnef�oD setvar W�d� AutoCAD +,�� SNAPANG `���pmqrs AutoCAD tu 0 hvwxyz{�`|}~|B?� gh'ef �i�j SETVAR ��kl�SETVAR ��$Y��ef7qrs+,�� ANGBASE ;h�ABh�

�� UNDO ��k[��� setvar W�r CVPORT +,���� �d�

>? AutoCAD +,����'

Page 157: AutoLisp Reference

setview | 157

���������� AutoCAD ���� �

��� getvar ���

setview

(setview view_descriptor [vport_id])

��

view_descriptor ���� ��� VIEW �� �� tblsearch ��� � !"�

vport_id #��$�%&'(��()�*+ vport_id , 0�-��()%&'(��

./0 CVPORT ���%1 vport_id ��

� 2

*+34- setview ��� view_descriptor�

sin

(sin ang)

��

ang /56,78�96�

,$�():;<=(�

/>�?@� 96�AB2C/56,78D

Page 158: AutoLisp Reference

158 | AutoLISP ��

���

��� ang �� ����������

��

��� (sin 1.0)0.841471

��� (sin 0.0)0.0

slide_image

(slide_image x1 y1 width height sldname)

��

x1 ���� !� X "#$��%&�����'(����

y1 ���� !� Y"#$��%&�����'(����

width )%*���%&�����

height )%+���%&�����

sldname ,-.�/��0�1,-2� (.sld) 3,-42� (.slb) 5�67,-.�89 sldname �:;<= VSLIDE ��3>�2�589,-.�:?6��@�A Visual LISP ����

��5�BCD)%E��0�FGHI�J;K89 sldname�

sldname � libname(sldname)

,-�L67!�� !��MN1O�PQR�STU1 (x1,y1)�VO�LW7!�XH!�Y�L67!�Z[�\ (wid,hgt) ]9�wid < hgt '(1����^R (0,0) 1)%���� !�0�_`aGbcd� dimx_tile < dimy_tile efXH!�TU�

���

gh sldname �ijk�

=lmno�[pq)%��5r AutoCAD ,-.

Page 159: AutoLisp Reference

snvalid | 159

��

(slide_image 0 0 (dimx_tile "slide_tile") (dimy_tile "slide_tile") "myslide")(end_image)

snvalid

(snvalid sym_name [flag])

snvalid ������ EXTNAMES �� ������������ EXTNAMES ��� 0�snvalid �� AutoCAD 2000 ��� �!"#$����� EXTNAMES ��� 1%&'�(�snvalid �� AutoCAD )*�+,�!"#$���-. EXTNAMES �/0�1�2345��67#$89:

� ;<=!>��=!

� ?=!@

� �ABC�$D�EFGHIJFG=!�

�� EXTNAMES ��� 1�AutoLISP K!"L$D�MN3CO<�

P�

sym_name =!@�Q !"L�$D�!"L$RSTU=VW��

=!>XY! ($)W6Z[ (_) >\=! (-) ]^_=!`a�?=!@b-c!"$�

flag d��Q sym_name.ebfg�hiA[ (|)�jg�b:

0 k sym_name e3lhiA[�%&'�(

1 k sym_name eg�hiA[%m3lbEFGHIJFG=!(

no�

�� sym_name bpc�!"L$D��no T�f�no nil�

��`a!"L$�q=!�pcr

Page 160: AutoLisp Reference

160 | AutoLISP ��

�� EXTNAMES ��� 1��� ���� �������� ���������� �!

�"�#���$%&'(

�� EXTNAMES ��� 0��"�#���$%)*+,* - �.� A-Z/�0 � (0-9)�12� ($)��34 (_) �5 � (-)(

67

�8�679: EXTNAMES ��� 1!

;<! (snvalid "hocus-pocus")T

;<! (snvalid "hocus pocus")T

;<! (snvalid "hocus%pocus")T

�8�679: EXTNAMES ��� 0!

;<! (snvalid "hocus-pocus")T

�"�#=�>?��� �

< > ,@"�)@"

/ \ AB�CAB

" D"

: E"

? F"

* G"

| HB

, IJ

= K"

‘ LD"

; E" (ASCII 59)

Page 161: AutoLisp Reference

sqrt | 161

��� (snvalid "hocus pocus")nil

��� (snvalid "hocus%pocus")nil

�������� ���

��� (snvalid "hocus|pocus")nil

�����������������������

����� flag � �!� 1�"# snvalid �� sym_name �����$���%&'(�)*+,-.*+��/�

��� (snvalid "hocus|pocus" 1)T

sqrt

(sqrt num)

num !%0 ,1 /�

23!

1 �

4�

��� (sqrt 4)2.0

��� (sqrt 2.0)1.41421

ssadd

(ssadd [ename [ss]])

#1 5623*+ �789

:;<%=>/?@ABCD��,EFG�BCD

Page 162: AutoLisp Reference

162 | AutoLISP ��

��

ename �����

ss ��

� ������ ssadd ������������������ �� ��!��"�#$%����� ename�����&'#�(�����

� ��!��")"$%*�����+� ss�ssadd �,-.��/01(�2�

345

6�789:���

;<

=�2>/&'��"�6���?/01@A�2�B34C�� ss D0���E;�� (�?FGHIJK��LMNO6>�PQ�

� R>/���@S=T�2�U�VW ssadd ���XY�Z�[\��]^�

� e1 _`�a2b&'������c

dec (setq e1 (entnext))<���c 1d62d60>

� ss _`��c

dec (setq ss (ssadd))<Selection set: 2>

fg�de� e1 ��h/1C ss �i��2c

dec (ssadd e1 ss)<Selection set: 2>

jk e1 lg���c

dec (setq e2 (entnext e1))<���c 1d62d68>

� e2 h/1 ssc

dec (ssadd e2 ss)<Selection set: 2>

Page 163: AutoLisp Reference

ssdel | 163

ssdel

(ssdel ename ss)

��

ename �����

ss ��

��

������������������� nil�

������������ !���������"#$%���

&'

�('���� e1 �� ss �)*+�� e3 �� ss �)*,

-., (ssdel e1 ss)<Selection set: 2>

��/0�� e1 1�� ss�

-., (ssdel e3 ss)nil

23 e3 ��� ss �)*�456��� nil�

ssget

(ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list])

��75#$�89:;<=9:>?9:��@A�B%�CDEF

GH�IJ�KLMN�9:��@AOP ssget QRS�T ssget 6������U#$V��W�#$XY;Z[\]^_�

���� @AW��_

`a��@Abc�

Page 164: AutoLisp Reference

164 | AutoLISP ��

��

sel-method ������� ������ �����

C ���

CP ���������� ���!�"#��$�

F %��

I &'�(� �)*+ PICKFIRST ,-� "�$�

L ./0�12"345678��

P 34569:"� ;�

W �(� �

WP �<���=>�"#��$�

X ?6�12�@A�B X � ���CDE�FG filter-list ���H ssget � �12I"#�JK���LMNOPJQI"JK�78RST"JK�

:E UV"�� WXYI"#���

:N )*+ ssget Z["\]I�^�JK_` ssnamex abcde�fghi"j/kl�m�n\�(N��oW

XpJ>� ���"JK�q5j/klr7st`�

�uv�� ��wx�:N 7yz{|� ;I"�6x}JK�~@�@A`�� B56��JK�@ BlockReferenceNPolygonMesh ������$"�JK��� ssget ��� �JK�����I�w\�ssget ���z��JK�@ BlockReference � PolygonMesh$./0� ;I�q��z)� ;I���6x}JK�C ssnamex ab"�6JK"�JKkl�w!x�

:S ����5� ;�

Page 165: AutoLisp Reference

ssget | 165

pt1 ��������

pt2 ��������

pt-list ��

filter-list ��� ������� filter-list ���������������

������ !�" ssget #!$%&����'()�*+,-./0123����

��4(5678��9:�(5����;<�AutoCAD = ,->?@8�A�����

BCD

��EF"BCGH����IJ���:�� ��"BC nil�

����;<KL

� MN, :N ��;<O���,-��678PQRST� BlockReferenceUPolygonMesh VW0XYZ[�\RS�]^ ssget �_`a\RSbcd��e�fg�ssget hijk�lRST� BlockReference m PolygonMesh[������e�nopqrskM���e%tX8uIRS�9 ssnamex vw�x8RS�\RSyz{f�u�|} :N ;<fs~�x8RS��7����f��|a��GH�����,��~��7�����

� M MDI ��eN, L ��;<O���78������f7 pbr����������67��Z���� AutoCAD �R�����V�����n��Zrsp`f�6�nO�N, L ��� ssget �BC nil�

o�

(),-������������

��� (ssget)<Selection set: 2>

Page 166: AutoLisp Reference

166 | AutoLISP ��

����� (2,2) ���� �

��� (ssget ’(2 2))nil

������ ���� ����������

��� (ssget "_P")<Selection set: 4>

������ ���� ������������� !�" (0,0) # (1,1)�

��� (ssget "_C" ’(0 0) ’(1 1))<Selection set: b>

������ ���� �$ (0,0) % (5,5) ���&'(��)���

��� (ssget "_W" ’(0 0) ’(5 5))<Selection set: d>

��*+�,-�./01�*+23456789��):���� ;

<=>?��� @'(A(�� &�B9CDEFG"H PICKFIRST )IJ�K�L�

��� (ssget "_I" ’((0 . "LINE") (62 . 5)))<Selection set: 4>

<=&MNO�PQRS ssget TU;pt_list VWXY'(+Z[\]D^��;

���P�

��� (setq pt_list ’((1 1)(3 1)(5 2)(2 4)))((1 1) (3 1) (5 2) (2 4))

������ ���� � pt_list �+Z�_`a'(7bcd���)5e���

��� (ssget "_CP" pt_list)<Selection set: 13>

������ ���� � pt_list �+Z�_`a'(��)B9D^���

��� (ssget "_WP" pt_list ’((0 . "LINE") (62 . 5)))<Selection set: 8>

f)HXg�Uhi ssget TUJ�jklmn�K�;�� kop AutoCAD �qJrstuv��/ AutoLISP XwxyJz{_| 128 ��� ;}~�� �U��%�F����AutoCAD k��������� �/�hi ssget TUfk>? nil;./��O�� �� nil ���X�MN��� ;

Page 167: AutoLisp Reference

ssgetfirst | 167

������ Last ���� AutoCAD ����������������� AutoCAD ������� !�� "#$%��&��� !'�()��"

ssget *+,-��./0�1234�56�7�8*+9:;<=>"

?@A Visual LISP ������'�����BC�D�����EFGH�"

ssgetfirst

(ssgetfirst)

I�J sssetfirst *+�@+KL�8*+MNOP�����H"H'�Q��RSTUVWXYZ[\)X�Z�]R^_�����Q`�RSTUVWa

XYZbX�Z�]R^_����"H'�P����'��c�����T nil�d��e9f nil"

gc 8*+hijk12]l'0mnoD]pno'�]R�[qijk6

]l��Drst=u'�]R"

?@A ssget D sssetfirst *+"

sslength

(sslength ss)

@+

ss ���"

MNv

w+"

xyzW��TX�Z�DXYZ�

{|�����'���}]R~+���%r�f��w+MN

Page 168: AutoLisp Reference

168 | AutoLISP ��

��

������ �������

��� (setq sset (ssget "L"))<Selection set: 8>

�� sslength �����������

��� (sslength sset)1

ssmemb

(ssmemb ename ss)

��

ename ��� !

ss �!

"#$

%& ename ' ss �()*ssmemb "#��� !%& ename +'()*ssmemb "# nil!

��

,-.����*��� e2 '� ss �()*/ e1 +' ss �()�

��� (ssmemb e2 ss)<���� 1d62d68>

��� (ssmemb e1 ss)nil

ssname

(ssname ss index)

ssget 0�12�������3'4���*/+5"#6��789:;<=>?@*ABCD entnext 0�EF6��!

GHI��7��@'J'��()

"#��KLMN��O���7��@����

Page 169: AutoLisp Reference

ssnamex | 169

��

ss ����

index ������ ������������������

�������� (0)��������� 32767 ������� !"#�$%� index ���

&'(

)*+,-&'��.�)* index �/�01�����20���ssname &' nil�

34

�5����������.67

897 (setq ent1 (ssname ss 0))<��.7 1d62d68>

�5�����:����.67

897 (setq ent4 (ssname ss 3))<��.7 1d62d90>

��5����� 32767 ������� !"#�$%� index ���4)7

(setq entx (ssname sset 50843.0))

;�< entnext =��

ssnamex

(ssnamex ss [index])

>=�?@ABCD�$EFGHI�JGH�����KL@ABM�$NO

IPQR�S�����

��

ss ����

index ������ ������������������

�������� (0)�

�5T1���UVW%�XY

Page 170: AutoLisp Reference

170 | AutoLISP ��

���

���ssnamex �� index �� ������������ ����������� index �� !�"��#$%%�&'��()� *$�+ ���,������� ������� index -.�/012�()� 34��56ssnamex �� nil�

ssnamex !��� ��7#$% 8%%� *$9%:;&<=>��,?�(@A BC:;&<=>DE�(#$/F$�� FGH BC�*

#$=>�()�I$�� 9%J&'K$LMN�(@A ID 6OPQ/RQ 0 S�TU��� ���,V���(@A�W X���OYDQ=>��7��U�� T�

((sel_id1 ename1 (data))(sel_id2 ename2 (data)) ... )

Z%812�(@A IDN

DE=>�(��[DFGH 9%\A�ZN]7#$FGH ID 6O^Q 0 S�T_`7a =>b�

(polygon_id point_description_1 point_description_n... )

FGH ID 6c -1 def� -1 gh�iQ,jklm�WaD�Zno@A=>Npqrstuvt/tw�*$a =>b&'K$LMNa=>b ID 6O:=> x yzTu�x {a,#$|� }l~��}l~�/�DE

=>pqrt @~/�DE=>tw��#� ����

(point_descriptor_id base_point [unit_or_offset_vector])

�(@A ID

ID ��

0 ��X�BCO� Last All T

1 Pick

2 Window / WPolygon

3 Crossing / CPolygon

4 Fence

Page 171: AutoLisp Reference

ssnamex | 171

����������� ID �

����� 0,0,1���� unit_or_offset_vector�

��

� Pick��� 1� !"#$%&'(�)* data �+,������-. WCS �/0�$123 (1,1) 4"5�6,$%�����78��9:�

;<� (ssnamex ss3 0)((1 <$%=� 1d62da0> 0 (0 (1.0 1.0 0.0))))

�>?@AB@>CDAC"# E&'(�)* data �"F$%9G�HIJ�K) ID ��HIJLM�'(NO�PQ.HIJ�R9"#�$%STU(V�W3XYZG[\����-]>C !"3�6,$%�����7

8��9:�^_`HIJ ID � -1��

;<� (ssnamex ss4 0)((3 <$%=� 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))))

�a" !&'(�)*�6,]b��cd���ef�����

"#ab$%ghi�C����-6jklmgn� Z �"#a&Cop�gq�����78��9:�

;<� (ssnamex ss5 0)((4 <$%=� 1d62d88> 0 (0 (5.28135 6.25219 0.0) ) (0 (5.61868 2.81961 0.0) ) (0 (5.52688 3.75381 0.0) ) ) )

�� ID

ID rs

0 tuvq

1 wq

2 gqqx

Page 172: AutoLisp Reference

172 | AutoLISP ��

sssetfirst

(sssetfirst gripset [pickset])

gripset ���������� ������ pickset ���������� ����������������������� !"��#$%

&'����(� sssetfirst )�*+��,�� pickset �������-�� gripset ��(�

./01)�$�2340567�8����9��:;23<=.��

->?@ABCDEFG�DXF HIJ 69(�KL<������%&MNOP��QRSITUV

(setq ss (ssget (list (cons 301 (getvar "ctab")))))

��

gripset 3�������� gripset J nil WX�� pickset�Y sssetfirst ��Z�� pickset��� gripset J nil W[�� pickset�Y sssetfirst \]^_`a��bcd,���

pickset *�������

efg

��K����

h9

ij�klm�nopZ7qr����astuklv 1�Zw7m�>?1x���V

yzV (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))yzV (setq gripset (ssget "_l"))<Selection set: a5>

{| gripset �}w7����

klv 2 Z*~��� gripset ��V

yzV (entmake (list (cons 0 "line") ’(10 0.0 10.0 0.0) ’(11 10.0 10.0 0.0)))

���"��� ����� ����

Page 173: AutoLisp Reference

sssetfirst | 173

((0 . "line") (10 0.0 10.0 0.0) (11 10.0 10.0 0.0))��� (ssadd (entlast) gripset)<Selection set: a5>

������� ����� 2�

��� (setq 2onlyset (ssget "_l"))<Selection set: a8>

��� 3 ������ gripset ��

��� (entmake (list (cons 0 "line") ’(10 10.0 10.0 0.0) ’(11 10.0 0.0 0.0)))((0 . "line") (10 10.0 10.0 0.0) (11 10.0 0.0 0.0))��� (ssadd (entlast) gripset)<Selection set: a5>

������� ����� 3�

��� (setq pickset (ssget "_l"))<Selection set: ab>

�� pickset ��� �!

��� 4 ������ gripset " pickset ��

��� (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))��� (ssadd (entlast) gripset)<Selection set: a5>��� (ssadd (entlast) pickset)<Selection set: ab>

#$�gripset ��� 1-4�pickset ��� 3 " 4�2onlyset ���� 2!

%& gripset �'()*+ ,-./�

��� (sssetfirst gripset)(<Selection set: a5>)

01 gripset '()*+ ,-./�

��� (sssetfirst nil)(nil)

%&,-./� pickset ' ()*+�

��� (sssetfirst nil pickset)(nil <Selection set: ab>)

%& 2onlyset '()*+ ,-./�� pickset ' ()*+�

��� (sssetfirst 2onlyset pickset)(<Selection set: a8> <Selection set: ab>)

Page 174: AutoLisp Reference

174 | AutoLISP ��

���� sssetfirst ������� sssetfirst ���������������������2onlyset � !"#�$%&�'���(

��( (sssetfirst 2onlyset(<Selection set: a8>)

)* ��� AutoCAD �����+, �� sssetfirst�

-�. ssget � ssgetfirst /0�

startapp

(startapp appcmd [file])

�0

appcmd 123�4'5���6�,78�13��9 appcmd %&:;<=>?�startapp @ABCDEF PATH GH�=>IJKL6�,7�

file 123�4'5"#�MN�?O�

PQR

�9STUPQVW 0 �X0�YUPQ nil�

Z�

�[\]^_ Windows `ab�c"# acad.lsp MN�

��( (startapp "notepad" "acad.lsp")33

�9�d�0e;fg�hij�klmlnI�����`abop my stuff.txt MNq5r��[st(

��( (startapp "notepad.exe" "\"my stuff.txt\"")33

^_ Windows 6�,7

Page 175: AutoLisp Reference

start_dialog | 175

start_dialog

(start_dialog)

����������� new_dialog ��� ������������������������ !"#�����$ done_dialog ���%&�done_dialog ��'()*+,accept-./01%&2 OK 3456()*+ ,cancel-./01%&2 Cancel 3457(8�

start_dialog ��9:;��

<#=

start_dialog ��<# done_dialog ��.>?@!;� status�ABCDE��F3

E OK 34G<# 1��F3E Cancel 34G<# 0�HI� term_dialog ��JKL:���G<# -1�M2�NOP done_dialog ����QR 1 .S�T!.>?��UV�start_dialog ��WXYZ�=<#�[.\]^_R`�ab�

start_image

(start_image key)

������c�de�� fill_imagefslide_image 6 vector_image g���hi/0jklmn����`�ab�� end_image ��o>?�

;�

key *pq�rs���/0�key ;�tuQvw�

<#=

NOxyz<# key ;��{z<# nil�

|} ~�I start_image 6 end_image ��.������ set_tile ���

������Y/��P���

� ����/0�.��hi/0jkn�

Page 176: AutoLisp Reference

176 | AutoLISP ��

start_list

(start_list key [operation [index]])

����� add_list ��� start_list �������������� end_list ����

key ������� !"#�key �$%&'(�

operation )���*+,�-�./�01�23��4-56

78

1 9:;�-��<=

2 >?@�-�A

3 BCD-��EF@-�GHIJKL

index )����M add_list ��*9:�-�A�-�N�O7A�P� 0�QRS��T��U index �HI5� 0�

QR start_list V+,9:./�UWX index ��

YZ5

[\�-��]^�

_` V*a start_list b end_list ���6cd� set_tile ��

strcase

(strcase string [which])

[\ef� !N�-�!ghij-�!N�-�

���N�kl�mnop&(g'(�YZ

Page 177: AutoLisp Reference

strcat | 177

��

string ����

which ������ ��� nil�string �������������������������

!�

����

"#

$%& (strcase "Sample")"SAMPLE"

$%& (strcase "Sample" T)"sample"

strcase '��()*+,-�./���0����12�

strcat

(strcat [string [string]...])

��

string ����

!�

������3���strcat !456����

"#

$%& (strcat "a" "bout")"about"

$%& (strcat "a" "b" "c")"abc"

$%& (strcat "a" "" "c")"ac"

$%& (strcat)""

�78���9:�;85���< !

Page 178: AutoLisp Reference

178 | AutoLISP ��

strlen

(strlen [string]...)

��

string �����

��� ����� string ���strlen ��������� �������������strlen 0�

!

"#$ (strlen "abcd")4

"#$ (strlen "ab")2

"#$ (strlen "one" "two" "four")10

"#$ (strlen)0

"#$ (strlen "")0

subst

(subst newitem olditem lst)

��

newitem %&�'�

olditem %&�'�

lst '�

(��)*+����,�����

-',./012�34',56�7+�12892:;�<=>?=�@�'

Page 179: AutoLisp Reference

substr | 179

���

����� newitem �� ��� olditem��� lst ���� olditem�subst ����� lst�

��

��� (setq sample ’(a b (c d) b))(A B (C D) B)

��� (subst ’qq ’b sample)(A QQ (C D) QQ)

��� (subst ’qq ’z sample)(A B (C D) B)

��� (subst ’qq ’(c d) sample)(A B QQ B)

��� (subst ’(qq rr) ’(c d) sample)(A B (QQ RR) B)

��� (subst ’(qq rr) ’z sample)(A B (C D) B)

� assoc � !�"�subst #$%&'()*+���,*-./*����0�1�

234 who 567*+��

��� (setq who ’((first john) (mid q) (last public)))((FIRST JOHN) (MID Q) (LAST PUBLIC))

892 old 567 (FIRST JOHN)�new 567 (FIRST J)�

��� (setq old (assoc ’first who) new ’(first j))(FIRST J)

:9�*+��;<=���

��� (subst new old who)((FIRST J) (MID Q) (LAST PUBLIC))

substr

(substr string start [length])

substr #$>.?@ string �A�<BC.?@9���DA�C.?@�EFG; start B.?H�I�JK7 length�

��.?@��<BC.?@

Page 180: AutoLisp Reference

180 | AutoLISP ��

��

string �����

start ��� string �������������������� 1�

length ��� � string ������������� !� length�"#���$%& string �'(�

)* string ��������+,� 1�-./01234567�8�9� nth . ssname:;<=>?@���67�+,A� 0�

BCD

����

EF

GH= (substr "abcde" 2)"bcde"

GH= (substr "abcde" 2 1)"b"

GH= (substr "abcde" 3 2)"cd"

tablet

(tablet code [row1 row2 row3 direction])

��

code ��I�JKDL�=

0 BC8�BCMNOP�-QRSJ�TUVW/X�

��

1 YZ[\]^���_�OP�-QRSJ�TU]^`

�OP_� (row1, row2, row3, . direction)�

ab._���cdOP

Page 181: AutoLisp Reference

tblnext | 181

row1, row2, row3

�������������� ��������

� row3 ������� (Z) ����� 1�� � row3 �������!"#�$� 1 ���tablet %�&�'()*+,-� 1�

direction #������./01234567 (WCS) 89:�;<=>8��� 8?�@?�

� � direction ABCDE��tablet %�&FGH�I2-JKLM'(� direction NOPQR�%�� direction $S�

'(,

� tablet %�TUVW�H'( nil�X-J7YZ0 ERRNO 2[VW\]�

1^�_ Visual LISP ��������`a CbAutoLISP cd>ef:�

gh

U tablet %�ij�klm�Z�.noZ�p

(tablet 1 ’(1 0 0) ’(0 1 0) ’(0 0 1) ’(0 0 1))

qr��Z��st�AutoCAD *Btuvwxy��� �\���� 56�h��� z{"��� �56� (5000,15000)�|}��U~���� AutoCAD �U�56�9����

TABMODE 7YZ0� AutoLISP h�N2*��� -J�����

^�_ Visual LISP ��������bKL��� f�

tblnext

(tblnext table-name [rewind])

���U tblnext )�H����&'(8���#����tblsearch %�N2-J�����#����� ��"N��� rewind �+,$� nil�|}%

��&(�����8����J�� ¡¢H��#����

���8�£¤�#¥

Page 182: AutoLisp Reference

182 | AutoLISP ��

��

table-name �������� �� table-name �� "LAYER"� "LTYPE"�"VIEW"�"STYLE"�"BLOCK"�"UCS"�"APPID"�

"DIMSTYLE" � "VPORT"�����������

rewind ����������� nil�� !���"#�$�

%&'()�

* �

��+,-&'()�.�/0123��45* �()� DXF 678�������$9 ()-�.�* nil�:.�;<�0* =>?@�()�

AB

"#��$�%&'CDE

FGE (tblnext "layer" T)((0 . "LAYER") (2 . "0") (70 . 0) (62 . 7) (6 . "CONTINUOUS"))

* ��HI�JE

(0 . "LAYER") ���� (2 . "0") ��� (70 . 0) �� (62 . 7) ��� �������������� (6 . "CONTINUOUS") ����

KLMN* �$9 -1 O�AutoCAD 0PQRS'��$TU&VW* �()�SV3X��YZ tblnext .�[\0* ��$�J&'()�W1�SV]^_`&'�[�a�bcde-�� nil �%f'�� �gAhi !,�jk$���]l�Rmno��$�%&'()�

pq�$"rs�()$tH-&' -2 O��O�u�qI$�%&'Cv�Cvwx�� �yz�{|�}~�C4$ &'w� BOX �q���E

FGE (tblnext "block")((0 . "BLOCK") (2 . "BOX") (70 . 0) (10 9.0 2.0 0.0) (-2 . <CvwE 1dca370>))

* ��HI�JE

Page 183: AutoLisp Reference

tblobjname | 183

(0 . "BLOCK") ���� (2 . "BOX") ��� (70 . 0) �� (10 9.0 2.0 0.0) �� X,Y,Z (-2 . <���� 1dca370>) �� ��

entget � entnext ���� -2 � ���������������������������� ssadd ������� !"#$ �%& -2 � ����'(�)� entnext ����*+�,-./�0!���1-./�23 !��43�5)� entnext ���67 nil�

�8 !-./ �9:���;< tblnext ��=67� -2 ���>?�-� ENDBLK �������

@A BC vports ���67DE VPORT FGH�=I� vports ��JKL VPORT GH��M� tblnext ��NOP Q�

tblobjname

(tblobjname table-name symbol)

(�

table-name RST�U.VWL�SXF��(��YZ[\]�

symbol RST�U.VWL�SX�

67>

�8^��_67SXF`�����

tblobjname 67������C entget � entmod ab�

c�

de�fgWL-hi ESC-01 �����

fg� (tblobjname "block" "ESC-01")<���� 1dca368>

67U.SXFhi����

Page 184: AutoLisp Reference

184 | AutoLISP ��

tblsearch

(tblsearch table-name symbol [setnext])

��

table-name ������� ��������������

symbol ������� ��������������

setnext ������������ nil�tblnext �� !"�#$%&'(�)*�+,'- tblnext ��.�/$%012� tblsearch '-301 45 !6, !�78�tblsearch �9: tblnext ;� ! <=�

01�

�� tblsearch ��>?@��A�����A B5 !�/$%CD tblnext ��EF GH01� !���IJ>?)* !�/01 nil�

*K

LM NO��A�PstandardQ R�*HS

NOS (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

(term_dialog)

��TU5 DCL RV&WX.YZU[-\= ]^�AutoCAD _`a'- term_dialog ���b��c-defghijk�

01�

term_dialog ��lm01 nil�

T�� ���e����A

YZno3J ijk�$p-qrs@/tB*

Page 185: AutoLisp Reference

terpri | 185

terpri

(terpri)

terpri �������� I/O���� ��������� prin1�princ � print

���

nil

textbox

(textbox elist)

��

elist ������� ���!"# $%&' entget ����(�(%&)*

+,- elist �����.��/0�1�..23(4567 8��9:��;6�

textbox ��<=>?(@A(�1�..2

���

+,BC8��DEFGHEI(�JK8�� nil

textbox ����(ILMN�."#(OP Q�R�."#(S I1 (0,0,0) 0TUVW1 0XY Z[R�."#1\](��^1_`a�(��^bFc(!�d�ef�!�/+ g g p3 K8����(hDEi�1I (0.0 0.0 0.0)hDEI�(�j�k�.(S IlmnR�.(@Aop(qfV(rsthuEI�(�j�RopP(vwVxy5zt�.({|

}~ ��(HEI��1LMmn�.(opP(qfVgvwV

-���w��DE���

ztDEj��."#(�� ���mnR�.(DEopP("V��

Page 186: AutoLisp Reference

186 | AutoLISP ��

��

������ ����������������

�� (textbox ’((1 . "Hello world.")))((0.000124126 -0.00823364 0.0) (3.03623 0.310345 0.0))

textpage

(textpage)

textpage ����� textscr

!"#

nil

textscr

(textscr)

!"#

textscr ��$%!" nil.

trace

(trace [function...])

trace ��&'(�����)*+, -�.'(��/01#2�34567)*89:5;</=>��?89@A�BC�DE/0FGH IJ�K3

LMN>���O0PQ

RSTUVWXY�ZUV

WXY�ZUV?[�� AutoCAD Flip Screen \]^H

A_ AutoLISP <`2�ab��

Page 187: AutoLisp Reference

trace | 187

�� Visual LISP IDE �������� ����� Visual LISP Trace ����� Visual LISP ��������� ��� AutoCAD �����

�� � AutoCAD ���� !" Visual LISP#�$ AutoCAD %&'(�)*+�"���,-Visual LISP Trace ���./01���234 trace � �� AutoCAD 56789 Visual LISP :;89< IDE ��� Visual LISP =�>?��@�;AB489�CDE Trace ���4� FGH1.I Visual LISP�

JK untrace 89�LM�

NO

function K��PQO4RS���TUVNOtrace WX�

YZ[

\]�^_`a trace 4QOP���TbcNOtrace YZ nil�

de

VfPg foo:4QOhi=QO4�LMj

��j (defun foo (x) (if (> x 0) (foo (1- x))))FOO

��j (trace foo)FOO

kK foolmn�j

��j (foo 3)�o (FOO 3) �o (FOO 2) �o (FOO 1) �o (FOO 0) n�j nil n�j nil n�j niln�j nil

kK untrace pq�LMj

��j (untrace foo)FOO

rNs untrace QO�

Page 188: AutoLisp Reference

188 | AutoLISP ��

trans

(trans pt from to [disp])

��

pt �������� ����������� ��

������������

from ����� !"#��$%��&' pt ()*+�������,-./0

0 12)*+�WCS�

1 34)*+�56 UCS�

2 7�� 0 #�� 1 �893:�;56<=(>;)*+ (DCS)� 7�� 3 �893:�;56?@AB<=( DCS�

3 CAB DCS�D3E�� 2�

to ����� !"#��$%��&'FG�()*+�

HI(����J/K�L from ���

disp -MNOPQ, nilRS pt T,����UQV���WX�

-M from # to ��V !"YZ[V\ entnext�entlast�entsel�nentsel ] ssname ^_�FG( !"�`ab��Sc�d'ef(ef)*+ (OCS) g(�hGijkl�eEcmefOCS ^nE WCSe`mefOCS ] WCS oB(klVApT��93��$%�������q�(����VhGklef OCS (r�stu�vVeE OCS ^nE WCS (wmef`sklxQyz{pT�

FG/

\�� to &'()*+�;(������#����

S����#����|��)*+kl�r��)*+

Page 189: AutoLisp Reference

trans | 189

��

��������UCS �� �� Z ��� 90 ��

��� (trans ’(1.0 2.0 3.0) 0 1)(2.0 -1.0 3.0)

��� (trans ’(1.0 2.0 3.0) 1 0)(-2.0 1.0 3.0)

��� ���������� Visual LISP ���������� �� !"

�#�$�%&'()*+�,-��./012�3456/789�:$;

12()�345.12()� OCS � < UCS�

(trans text-insert-point text-ename 1)

=>?@A;BCDE�F5 :!GH"

IJK�;5LM< entmod NO�PQR�ST;U5VWXYZL� ['U()� OCS \H"�#�#C$;]I( UCS ^Y (1,2,3)V%&' MOVE ��Z�?:$;U^Y_. UCS � []� OCS�

(trans ’(1 2 3) 1 circle-ename)

=>?@A;BC^Y_`<]�]abP"

�#�#C'cd4e/f5�gh$ij/789�k/fl5mFnoU5

pq�?rs;'cd4�5. UCS � < DCS�

(trans user-point 1 2)

=>t;89�u/fl5. OCS � < DCS�

(trans endpoint line-ename 2)

v�?@Awxj'cd4�5y89u/fl5z�{oV|} Z � Z�.~��k/fl5mFn{'cd4�5pq"

trans NO�@A� ��5�v:$��E Z � �/f���Ln��"�&'� Z �_������� from � ��A�UL���/f5����/fXY"#C���/fXY���� Z L��� 0.0�#C���/f5���� Z L��\��"

� ��5�� Z � L

From �4� Z � L

WCS 0.0

UCS �R �

OCS 0.0

Page 190: AutoLisp Reference

190 | AutoLISP ��

type

(type item)

��

item ���

��

item ��� ������ nil����������� nil�����

� ������� !"#$

DCS %&'()*+,-�UCS XY ,- + ()./�

PSDCS %&'()*+,-�UCS XY ,- + ()./�

��������

012345 Z 6. ( �� )

From 78 Z 6.

type 9������

��� :;

ENAME <=>

EXRXSUBR ?@ ObjectARX ABCD

FILE EFGH�

INT I�

Page 191: AutoLisp Reference

type | 191

��

���������� ��

(setq a 123 r 3.45 s "Hello!" x ’(a b c))(setq f (open "name" "r"))

��

(type ’a) �� SYM(type a) �� INT(type f) �� FILE(type r) �� REAL(type s) �� STR(type x) �� LIST(type +) �� SUBR(type nil) �� nil

��������� type �������

LIST �

PAGETB ��� �

PICKSET !"#

REAL $%�

SAFEARRAY Safearray

STR &'(

SUBR )* AutoLISP ��+,-./FAS +0VLX12345���60AutoCAD0789:�45� LISP ;23��<=>?@ SUBR ABC

SYM 'D

VARIANT �E

USUBR 6 LISP0�45��FGH��

VLA-object ActiveX �I

type ��JK��LMN ( �� )

�LMN OP

Page 192: AutoLisp Reference

192 | AutoLISP ��

(defun isint (a) (if (= (type a) ’INT) TYPE ����� T ���� T nil ��� nil ))

unload_dialog

(unload_dialog dcl_id)

��� dcl_id���� new_dialog � �������� DCL ���

������� �� DCL ��!"#�$�%��&% DCL '()*+�

dcl_id DCL ��,-.!/0�� load_dialog ��

123

unload_dialog � 4512 nil�

6�7 load_dialog 8 new_dialog � �

untrace

(untrace [function...])

function �9:;� �.<�=>?@* function!untrace �A�

123

BC�DEFG untrace �� ;�=>?@* function!untrace 12 nil�

�� DCL ��

HI@*� �JK,L

Page 193: AutoLisp Reference

vector_image | 193

��

������� foo �� ���

��� (untrace foo)FOO

��� trace ��

vector_image

(vector_image x1 y1 x2 y2 color)

������������� !"# start_image �$%&'() (x1,y1) *) (x2,y2) +,-./01�2) (0,0) 3,�� !�4'56789: dimx_tile ; dimy_tile �<=>?@�5�A��

��

x1 B-)� X A��

y1 B-)� Y A��

x2 BC)� X A��

y2 BC)� Y A��

color AutoCAD DE�F6G�3HI�JKDELMN-�

����������� !'+,-./01

DEOP�QRS

DELM ADI TUQ VW

–2 BGLCOLOR AutoCAD �XYZ���[\E

–15 DBGLCOLOR �����[\E

–16 DFGLCOLOR ������\E"]^&

–18 LINELCOLOR �����1�DE

Page 194: AutoLisp Reference

194 | AutoLISP ��

���

����� ��

��

(setq color -2) ; AutoCAD ������(vector_image 0 0 (dimx_tile "slide_tile") (dimy_tile "slide_tile") color)(end_image)

ver

(ver)

ver ����������� �

���

���!"#$%&'(

"Visual LISP version (nn)"

)* version +,-./01nn +23./45�67!"�

23./45�67!"���&'(

(de) 84(en) 9: /;:;4(es) <=>4(fr) ?4(it) @AB4

��

CD( (ver)"Visual LISP 2000 (en)"

��,- AutoLISP ./0�!"#

Page 195: AutoLisp Reference

vl-acad-defun | 195

vl-acad-defun

(vl-acad-defun ’symbol)

symbol ��������

���� c: ��������� ObjectARX ������������� � vl-acad-defun !"#�

$%&

'()�

vl-acad-undefun

(vl-acad-undefun ’symbol)

symbol ��������

�� � vl-acad-undefun *+, c: ���)-�.*+/0 vl-acad-defun ��12

����)-�

$%&

34�$% T�53467���8 AutoLISP 9')-�:�$% nil�

vl-arx-import

(vl-arx-import [’function | "application"])

;<=>?�@ABCDE VLX ����5� ObjectARX/ADSRX ����FGHI��� � vl-arx-import ��� ObjectARX/ADSRX ����91JFG���

K AutoLISP ����)-L��M7�

*+, AutoLISP �����)-� ObjectARX ����5NO �P�

K ObjectARX/ADSRX ��FGQ@ABCDE VLX

Page 196: AutoLisp Reference

196 | AutoLISP ��

��

function ������� ��

application ������ ���������

������������� nil��vl-arx-import !"�#$�%&'�(� ��%�

)*+

,-��

�� #$ VLX ./�01 �2345678)* nil�9(� ADS-DEFUN ��:;<��#$ VLX ����=�

>?

./@A67�BC vl-arx-import �5D7E

1 :AFGHIJ� VLISP KLM�8NO#PE

(vl-doc-export ’testarx)(defun testarx () (princ "This function tests invoking an ARX app ") (vl-arx-import ’c:cal) (c:cal))

2 Q�RST����U:1GHKV� VLX�WXRYZ�%&'����UW[�

3 \] geomcal.arx���^,\]��

4 \]8_/�����

`a vl-arx-import �b��c@defGH=� vl-arx-import g��NOhi�jklmKV8_/�������n vl-arx-import g��:o2� c:cal ��

lpq�>?=�c@�AFGHrG vl-arx-import g�E

(vl-arx-import "geomcal.arx")

s>:� geomcal.arx =�t�(� ��uv c:cal lw�

Page 197: AutoLisp Reference

vl-bb-ref | 197

vl-bb-ref

(vl-bb-ref ’variable)

��

Variable �������� �

���

� symbol ���� ���

��

����������� �

� � (vl-bb-set ’foobar "Root toot toot")"Root toot toot"

!" vl-bb-ref #������� foobar ���

� � (vl-bb-ref ’foobar)"Root toot toot"

$�% vl-bb-set &��'(��� ���)*�$�% Visual LISP ����

����+#�����,-�./�

vl-bb-set

(vl-bb-set ’symbol value)

��

’symbol ���������� �

value 0&�1�23��

���

456 symbol� value�

���������� ��

�����������

Page 198: AutoLisp Reference

198 | AutoLISP ��

��

��� (vl-bb-set ’foobar "Root toot toot")"Root toot toot"��� (vl-bb-ref ’foobar)"Root toot toot"

�� vl-bb-ref �� ������������� Visual LISP ����

�������������� !�

vl-catch-all-apply

(vl-catch-all-apply ’function list)

��

’function ��function ��"#$%& defun �'() lambda *+,�

list *�-./012�����

345

6789:34�;<�=7�67>?@A�vl-catch-all-apply 34BC@ADE�

��

67 vl-catch-all-apply ;<�89�:F7GH< apply B��6I�JK�

_$ (setq catchit (apply ’/ ’(50 5)))10

_$ (setq catchit (vl-catch-all-apply ’/ ’(50 5)))10

H< vl-catch-all-apply �LMN"#OP@A�QRSTMUVW�67H< apply XYZ[\]�^_�:�

_$ (setq catchit (apply ’/ ’(50 0))); @A�]�$\

H< apply X>?`ab^_�cdK@Aef�

67H< vl-catch-all-apply

c��*012gh�iOP@A

Page 199: AutoLisp Reference

vl-catch-all-error-message | 199

_$ (setq catchit (vl-catch-all-apply ’/ ’(50 0)))#<%catch-all-apply-error%>

vl-catch-all-apply ������������ ��� vl-catch-all-error-message ������ �������

_$ (vl-catch-all-error-message catchit)"���� "

��� �� �� vl-catch-all-error-message ! vl-catch-all-error-p ��"#$ Visual LISP ��������%��&'(�

vl-catch-all-error-message

(vl-catch-all-error-message error-obj)

��

error-obj ) vl-catch-all-apply ����� �

�*

+,�����-./�

01

�� vl-catch-all-apply 23���

_$ (setq catchit (vl-catch-all-apply ’/ ’(50 0)))#<%catch-all-apply-error%>

vl-catch-all-apply ����4������� "�� vl-catch-all-error-message 5#��6�������

_$ (vl-catch-all-error-message catchit)"���� "

��� �� �� vl-catch-all-apply ! vl-catch-all-error-p ��"#$ Visual LISP ��������%��&'(�

7��� �-./

Page 200: AutoLisp Reference

200 | AutoLISP ��

vl-catch-all-error-p

(vl-catch-all-error-p arg)

��

arg �����

��

�� ���� vl-catch-all-apply,���������� T���� nil�

��

�� vl-catch-all-apply ����

_$ (setq catchit (vl-catch-all-apply ’/ ’(50 0)))#<%catch-all-apply-error%>

�� vl-catch-all-error-p !" vl-catch-all-apply ����������

_$ (vl-catch-all-error-p catchit)T

#�$ vl-catch-all-apply % vl-catch-all-error-message &��'( Visual LISP ��

����)�*��+,-�

vl-cmdf

��

(vl-cmdf [arguments] ...)

vl-cmdf &�% command &�./�01234���56789:�vl-cmdf &�1;< AutoCAD =>?@AB87�CD����1EFGH)AIJ���K9L;< AutoCAD =>�MN�command &�KOP��QR34S AutoCAD�8'1TU��?�=>VWXYZ[;<\�

��=>�]�)^_�`a&��]��� vl-cmdf 1;<=>?@�b<&

�]��N command �1Z[;<=>�;<"&�]��

7c=>1dG vl-cmdf ]��eUfg�N1dG command ]���hij� vl-cmdf &�klmn\1 command )9W�� getxxx �op�

!"����� vl-catch-all-apply �������

;< AutoCAD =>

Page 201: AutoLisp Reference

vl-cmdf | 201

��

arguments AutoCAD ������

���� �����arguments ��������������������� ("") � !"#$ ENTER %�&'()�*+��,- vl-cmdf �$ ESC �&'()���./01� AutoCAD ���

234

T

567�8'9 Visual LISP :�� vl-cmdf�;�*<=>? AutoCAD @A:�8'��B�-CDE�F234 (T) GHI JKL@A:�M AutoCAD NOPQDE�RS�TUVWXY AutoCAD @AZ[\ ��R]^�*<NO��_`aO���

)b

8' AutoCAD �� ��cd*e VLISP JKL �fDEghij�Fklmn? command � vl-cmdf ]o�pqr

��r (command "line" (getpoint "point?") ’(0 0) "")line stu(�r point?stg(�� [vw (U)]r��r nil

x- command S�y�� LINE ���za{,- getpoint |��

��r (VL-CMDF "line" (getpoint "point?") ’(0 0) "")point?line stu(�rstg(�� [vw (U)]r��r T

dx- vl-cmdf S�y,- getpoint |�c67RS getpoint }H�~point?� �f�za{�� LINE ���

Page 202: AutoLisp Reference

202 | AutoLISP ��

���������� ��� LINE ������������������ !"�#$%&'(�)

��) (command "line" (getpoint "point?") ’(0) "")line *+,��) point?*+���- [./ (U)])��) ERASE nil0123)*+24�)*56 *78 0 �

command 9�:;���<=��> AutoCAD ?@ABC�� DEAFGH8������

��) (VL-CMDF "line" (getpoint "point?") ’(0) "")point?IJKLMN : %O8 ads_cmd �PQ���nil

R� vl-cmdf S����TUBC;��� DEGH8����� AVWX����

��Y command 9��

vl-consp

(vl-consp list-variable)

vl-consp 9�Z+'[\�]^_`���+a�

��

list-variable ��

bcd

#" list-variable �A� nil �� ebc T ]ebc nil�

��

_$ (vl-consp nil)nil

_$ (vl-consp t)nil

_$ (vl-consp (cons 0 "LINE"))T

Z+��]� nil

Page 203: AutoLisp Reference

vl-directory-files | 203

vl-directory-files

(vl-directory-files [directory pattern directories])

��

directory �������� ���������������

� nil�vl-directory-files �������

pattern ������� �� DOS � ������������� nil�vl-directory-files !�� "*.*"

directories "�#���$%�&'()��*+��,-��./0

123

-1 4/5���

0 /5� 6��7890:�

1 4/5� �

$%0

� 6*+/&���;<�=��� �� �>$% nil�

?@

_$ (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

(vl-doc-export ’function)

ABCDEF�GHI� VLX JC vl-doc-export K��,L��K�M5NOPQR VLX ��S�GHI�

/5N���'�T<�

�K�D���S',�

Page 204: AutoLisp Reference

204 | AutoLISP ��

�������� ��� vl-doc-export ��������� ����defun ��������

��

’function !�"#$%&����

'()

*+,�

-.

/0�12%3�� kertrats.lsp ��4����567�89#:;<=>?� VLX�VLX ���#:7 kertrats.vlx��� vl-doc-export �@ABCD kertrats.vlx ��EF�GH kertrats ��I

(vl-doc-export ’kertrats)(defun kertrats () (princ "This function goes nowhere") )

vl-doc-import

(vl-doc-import application [’function...])

���JK�89#:;< VLX =����LMNOPQRS�ECD��� VLX =MT����

�������� ��� vl-doc-export ��������� ����defun ��������

��

application U V�W,$MN��X�� VLX ��YZ��#:=�$[\ .vlx ]^#�

function S_`a_ !�W,$MN�����b*W,���c

Xde application MT���FfeMN�

'()

*+,�

fOPMT���MNH VLX #:;<

Page 205: AutoLisp Reference

vl-doc-ref | 205

��

� ldatatest ����� ldataget

(vl-doc-import "ldatatest" ’ldataget)nil

vl-doc-ref

�� ��������� VLX ��������������� �����!"#$%

(vl-doc-ref ’symbol)

&

’symbol '(!"#)*%

+,$

symbol-.#!"#$%

��

/0 (vl-doc-ref ’foobar)"Rinky dinky stinky"

1&2 vl-doc-set � %

vl-doc-set

(vl-doc-set ’symbol value)

�� ��3 VLX ���������45��� �����!"#$%

�� �����67 vl-doc-set 89� set%

&

’symbol '(!"#)*%

value :;$%

���� �������!"#$

45��� �����!"#$

Page 206: AutoLisp Reference

206 | AutoLISP ��

���

��� value

� � (vl-doc-set ’foobar "Rinky dinky stinky")"Rinky dinky stinky"

��� vl-doc-ref ��

vl-every

(vl-every predicate-function list [list]...)

vl-every ������������������� !��"#$���%&'()*��+,-&'���.�/����+0123+456.���78

9:;�<

��

predicate-function

)*��=>0?@A���������B vl-every CD

������E+FG@AHIJKLM�� Tpredicate-function ��>0NH/OPQR��

� ST (��U ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

list V)*��

���

�� predicate-function 9W����-X��Y nil �+���� T+Z"�� nil

[\]^_`/?Z abM�

_$ (vl-every’(lambda (fnm) (> (vl-file-size fnm) 0)) (vl-directory-files nil nil 1) )T

[\cd9W����-?ZX�e

Page 207: AutoLisp Reference

vl-exit-with-error | 207

�� NLST ������� ’<=� �

_$ (setq nlst (list 0 2 pi pi 4))(0 2 3.14159 3.14159 4)_$ (vl-every ’<= nlst (cdr nlst))T

�����������

$ (vl-every ’= ’(1 2) ’(1 3))nil

_$ (vl-every ’= ’(1 2) ’(1 2 3))T

�������� nil��� vl-every ���������� !�"#$%��&'()*+�������� T��� vl-every %,-.�/�� (1,2) �01 !2345���"6789�5����)*�+:�7�;���<

,�= vl-every ��> nil �+

�?�@ABC vl-every DE������+8�������FGH��I��� nil�

_$ (setq alist (list 1 2 3 4))(1 2 3 4)_$ (setq junk nil)nil$ (vl-every ’= junk alist)T

���� T��� vl-every ,- nil �9�JKLM7�;���<,NOPQ1RS�TU !VWXYZ+[\:]�vl-every ^��> nil �+

vl-exit-with-error

(vl-exit-with-error msg)

_`�Wa%bcdefg�hi� VLX+ji vl-exit-with-error 9�#kW *error* `��lmno�pq��7rstC+

u�

msg vwx+

^pqy VLX z{,-|}~�kW#�defg� *error* `�

Page 208: AutoLisp Reference

208 | AutoLISP ��

���

��

�� ����� vl-exit-with-error ���������������� *error* !"

(defun *error* (msg) ... ; # VLX ���� /$%&'()%*+(vl-exit-with-error (strcat "My application bombed! " msg)))

,�- vl-exit-with-value !./ Visual LISP ������(�0MDI &'�12*+3�

vl-exit-with-value

(vl-exit-with-value value)

VLX *error* *+45.�� vl-exit-with-value !����6�� VLX �78�

�!

value 9:��

���

value

�� vl-exit-with-value �;!� 3 ��6�� VLX � !"

(defun *error* (msg) ... ; # VLX ���� /$%&'()%*+ (vl-exit-with-value 3))

,�- vl-exit-with-error !< Visual LISP ������(�0MDI &'�12*+3�

����6=>?������ VLX � !

Page 209: AutoLisp Reference

vl-file-copy | 209

vl-file-copy

(vl-file-copy source-file destination-file [append])

���������� �������vl-file-copy ���������������� ���

��

source-file �� �!"#$����%&'!"()�*+,�

vl-file-copy �- AutoCAD ./01234�

destination-file �� �!"05���%&'!"()�*+,�vl-file-

copy ���67 AutoCAD ./012�

append %&!"8��9�:�; nil�source-file �� � destination-file <=�05���>?@�

AB:

%&CDEAB)��FEAB nil�

AB nil �G�HIJKLMN

� source-file �OP� source-file ;01� '!" append � append �:; nil�9 destination-file QRS-�� TUVW destination-file <=���,TX���;6YZ@� source-file [ destination-file \]

^_

� autoexec.bat � newauto.batN

_$ (vl-file-copy "c:/autoexec.bat" "c:/newauto.bat")1417

� test.bat � newauto.batN

_$ (vl-file-copy "c:/test.bat" "c:/newauto.bat")nil

`a�K; newauto.bat QRS-��bc�!" append ���

���������� ������

Page 210: AutoLisp Reference

210 | AutoLISP ��

�������� append ��

_$ (vl-file-copy "c:/test.bat" "c:/newauto.bat" T)185

�������� append �� T�

vl-file-delete

(vl-file-delete filename)

��

filename ��������� !" #$�%&'(��)*

+,#vl-file-delete -. AutoCAD /012�34�

56�

%&��756 T� 89756 nil�

:;

� newauto.bat�

_$ (vl-file-delete "newauto.bat")nil

'(� <=!"��. AutoCAD /012�'( newauto.bat !"�

� c:\ 12� !" newauto.bat�

_$ (vl-file-delete "c:/newauto.bat")T

� ����>�+,�?@AB. !"�

vl-file-directory-p

(vl-file-directory-p filename)

� !"

C�!"#DE�+,#

Page 211: AutoLisp Reference

vl-file-rename | 211

��

filename �������� �����������vl-file-directory-p �� AutoCAD ��������

!"

� filename #���$ ! T�%$ ! nil�

&'

_$ (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

(vl-file-rename old-filename new-filename)

��

old-filename ����()*����� �����������

vl-file-rename � AutoCAD ��������

new-filename ����(+,���-�.�

/0 ��������vl-file-rename 1)*�2���34 AutoCAD �����

!"

�)*�56$ ! T�%$ ! nil�

)*���

Page 212: AutoLisp Reference

212 | AutoLISP ��

��

_$ (vl-file-rename "c:/newauto.bat" "c:/myauto.bat")T

vl-file-size

(vl-file-size filename)

��

filename ����� �����������������

vl-file-size � AutoCAD � !"#$%�

&'(

��)*+ vl-file-size &',- filename ����������./0vl-file-size &' nil��� filename 1!"�23��vl-file-size &' 0�

��

_$ (vl-file-size "c:/autoexec.bat")1417

_$ (vl-file-size "c:/")0

�45���#61 c:/ 1!"78 vl-file-size &' 0�

vl-file-systime

(vl-file-systime filename)

��

filename ������9$����:�

&'(

�;<=>?@A�B,����%C��+&' nil�

������D�EF

&'�����4GH;<@A

Page 213: AutoLisp Reference

vl-filename-base | 213

����������

� �

� �

� �����

� �����

� �

� �

� �

� �����������������������

��

_$ (vl-file-systime "c:/program files/acad2000/sample/visuallisp/yinyang.lsp")(1998 4 3 8 10 6 52 0)

���� !"#�$%&'() 1998 *�� 4 +,-.,/�� 10 ���0 , '() 6:52:0�

vl-filename-base

(vl-filename-base filename)

12

filename ��!"3�456�vl-filename-base 7289:!"�;<=�

���

��>? filename �456�@ABCDEFG!"�HIJKL3�

��

_$ (vl-filename-base "c:\\acadwin\\acad.exe")"ACAD"

_$ (vl-filename-base "c:\\acadwin")"ACADWIN"

EF!"�HIJKL3���!"�3M

Page 214: AutoLisp Reference

214 | AutoLISP ��

vl-filename-directory

(vl-filename-directory filename)

��

filename ������� ����������vl-filename-directory ����������� ��!"#$% (/) &'$% (\) ()*+,-��

./0

������12� filename �3,�

45

_$ (vl-filename-directory "c:\\acadwin\\acad.exe")"C:\\ACADWIN"

_$ (vl-filename-directory "acad.exe")""

vl-filename-extension

(vl-filename-extension filename)

��

filename ���������&67��vl-filename-extension ����������� ��

./0

������ filename �67��./����)"89 (.) :;�12���<= filename ��67��vl-filename-extension ./ nil�

45

_$ (vl-filename-extension "c:\\acadwin\\acad.exe")".EXE"

>?����@&67��./��� �

./���67��A>?�����B3,

Page 215: AutoLisp Reference

vl-filename-mktemp | 215

_$ (vl-filename-extension "c:\\acadwin\\acad")nil

vl-filename-mktemp

(vl-filename-mktemp [pattern directory extension])

��

pattern �������� ������������ nil�vl-

filename-mktemp �� $VL~~�

directory �� ���������� �����������

� nil�vl-filename-mktemp !"#$%&'� (

� pattern )��� �� TMP *+,-)��� �� TEMP *+,-)��� �� ./� �

extension �� ���012��34������������

� nil�vl-filename-mktemp �� pattern ��)34�56789�:�� ;�

<=>

������� �?�"(

directory\base<XXX><.extension>

@)(

base AB pattern CD� 5 E��

XXX � 3 E��FGHI

�JK VLISP ��LMN VLISP OP)�QR vl-filename-mktemp ST���

UV

_$ (vl-filename-mktemp)"C:\\TMP\\$VL~~004"

�����WXFG���

Page 216: AutoLisp Reference

216 | AutoLISP ��

_$ (vl-filename-mktemp "myapp.del")"C:\\TMP\\MYAPP005.DEL"

_$ (vl-filename-mktemp "c:\\acadwin\\myapp.del")"C:\\ACADWIN\\MYAPP006.DEL"

_$ (vl-filename-mktemp "c:\\acadwin\\myapp.del")"C:\\ACADWIN\\MYAPP007.DEL"

_$ (vl-filename-mktemp "myapp" "c:\\acadwin")"C:\\ACADWIN\\MYAPP008"

_$ (vl-filename-mktemp "myapp" "c:\\acadwin" ".del")"C:\\ACADWIN\\MYAPP00A.DEL"

vl-get-resource

(vl-get-resource text-file)

��

text-file ����� VLX � .txt � ���� ������� .txt ����

���

������� text-file ����

��

�� getres.vlx � ��� LISP !"#$%�& print-readme �'�(�& readme.txt ��)� �print-readme '��"*+,

(defun print-readme () (princ (vl-get-resource "readme")) (princ) )

-. getres.vlx /01 print-readme,

_$ (print-readme)There is very important information here!Be sure to thoroughly read the following!Are you ready?Here it comes...

�� VLX 23� .txt � ���

Page 217: AutoLisp Reference

vl-list* | 217

vl-list*

(vl-list* object [object]...)

��

object �� LISP ���

��

vl-list* �� list �� �������� object ����������� cdr ���� vl-list* �������� !�"���#$�������������"%&�'()*+,-.��&���/0 1+2����3��45

���06

� �� object 789� !�"� !�� ��/0 object ��:; !�"�#$�� ��������� !�<=>�?@ABCD�"��#$��

� ��=>�?@ABCD�"����

EF

_$ (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)

G�H list ��

vl-list->string

(vl-list->string char-codes-list)

-.I���

��J��K��LMN�OPQRSOPT

Page 218: AutoLisp Reference

218 | AutoLISP ��

��

char-codes-list ����������� ��� 256�

���

������������� char-codes-list �������

!

_$ (vl-list->string nil) ""

_$ (vl-list->string ’(49 50))"12"

"�# vl-string->list $��

vl-list-exported-functions

(vl-list-exported-functions [appname])

��

appname ����%&'( VLX )*+,���-�./ .vlx 012�

���

�345$������6789:%& VLX 45$��;�� nil�67

<= appname ��>?��@ nil�vl-list-exported-functions ��A945$�B�C6 c: $�DEF.G: VLX 2HIJ45$��

!

_$ (vl-list-exported-functions "whichexpns")("WHICHNAMESPACE")

"�# vl-list-loaded-vlx $��

B545$�

Page 219: AutoLisp Reference

vl-list-length | 219

vl-list-length

(vl-list-length list-or-cons-object)

��

list-or-cons-object

������

���� ������������������ list-or-cons-object ������� nil�

������vl-list-length ��������� nil� !"�#$ LISP ������� ����%�&'()�

*+

_$ (vl-list-length nil)0

_$ (vl-list-length ’(1 2))2

_$ (vl-list-length ’(1 2 . 3))nil

,�- listp ���

vl-list-loaded-vlx

(vl-list-loaded-vlx)

./����012 AutoCAD 34!56�789:;< VLX "=>?���@A012 AutoCAD 34!56� VLX "=>?��� nil�

vl-list-loaded-vlx ��BCDEFG12349:;<H� VLX "=>?�

IJ����

�01234!56�KA789:;< VLX 3L

Page 220: AutoLisp Reference

220 | AutoLISP ��

��

���� AutoCAD �� ����� VLX ��

_$ (vl-list-loaded-vlx)nil

������ �� VLX ��

���� VLX ���� VLX ����� !"#$�%&'()*+�

_$ (load "c:/my documents/visual lisp/samples/foo1.vlx")nil_$ (load "c:/my documents/visual lisp/samples/foo2.vlx")nil

���� AutoCAD �� ����� VLX ��

_$ (vl-list-loaded-vlx)(FOO1 FOO2)

vl-list-loaded-vlx.,-./��00��� VLX ,-�

��1�23!"�%&'()*+� VLX�

_$ (load "c:/my documents/visual lisp/samples/foolocal.vlx")nil

������ VLX ��

_$ (vl-list-loaded-vlx)(FOO1 FOO2))

vl-list-loaded-vlx 4567819��� VLX (foolocal.vlx)�:!����;��<��%&'(�=��#$�%&'(�

vl-load-all

(vl-load-all filename)

�-

filename >?@����ABC�DEF�GH AutoCAD IJ�KLMN)�OPQRSMN%�TUV>?�WX%�

vl-load-all 4YZ?[\�]^�

_���<`�ab� AutoCAD �) ,Qc"� AutoCAD [d)8eab�[\�)

Page 221: AutoLisp Reference

vl-load-com | 221

���

������� filename vl-load-all �������

��

$ (vl-load-all "c:/my documents/visual lisp/examples/whichns.lsp")nil_$ (vl-load-all "yinyang.lsp")nil

vl-load-com

(vl-load-com)

����� Visual LISP ����� AutoLISP ���Visual LISP �� ! AutoLISP "#$ ActiveX % AutoCAD &'(�)* +,-��. ActiveX "/012�345��26789��%:;<=���

���>?�� vl-load-com �@ABCD�

���

����

EFG Visual LISP ������H�IJ/�� AutoLISP ��K�

vl-load-reactors

(vl-load-reactors)

���L vl-load-com M+ N/OPQRSTUV�

EFG vl-load-com ���

W Visual LISP ��XY��� AutoLISP

��&'()*��

Page 222: AutoLisp Reference

222 | AutoLISP ��

vl-member-if

(vl-member-if predicate-function list)

vl-member-if ��� list ����� �� predicate-function ��������� predicate-function ������ nil�� vl-member-if �������� �!"#$ member ��%�

��

predicate-function

&'���()*�+,-%���./01���

23+,45��678�� T�predicate-function ��)*94:;<#=.

� >? (��@ ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

list A&'���

���

��* ��&'���B��CD�EFGD���HI�JK����

�LK�� ��&'67�vl-member-if �� nil�

%M

:N�OPQRST.

_$ (COMMAND "_.LINE" ’(0 10) ’(30 50) nil)nil

��U�VST��:N�OPW4 vl-member-if ��XYU��Z[�.

_$ (vl-member-if ’(lambda (x) (= (cdr x) "AcDbLine")) (entget (entlast)))((100 . "AcDbLine") (10 0.0 10.0 0.0) (11 30.0 50.0 0.0) (210 0.0 0.0 1.0))

\�] vl-member-if-not ���

^�_`�a3��bcde^

Page 223: AutoLisp Reference

vl-member-if-not | 223

vl-member-if-not

(vl-member-if-not predicate-function list)

vl-member-if-not ��� list ������� predicate-function � ����������� nil�vl-member-if-not �������������� member �����

predicate-function

!"���#$%&'(��)*���+,-.� ��

/0'(12 �345�� T�predicate-function �6$%7189:�;�+

� <= (��> ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

list ?!"���

��6

��%@AB!"34�C���DE�FGHE ��IJ�KL���

�KL�M<N!"34�vl-member-if-not �� nil�

*O

_$ (vl-member-if-not ’atom ’(1 "Str" (0 . "line") nil t))((0 . "line") nil T)

P Q vl-member-if ���

vl-position

(vl-position symbol list)

symbol 'R AutoLISP <=�

S�TU&V0�WX����Y nil

�� ��Z[�\]

Page 224: AutoLisp Reference

224 | AutoLISP ��

list ��

���

��� symbol list ��������� ���� symbol��� nil�

��������� ���! 0�"�� ���! 1#$%&�

'(

_$ (setq stuff (list "a" "b" "c" "d" "e"))("a" "b" "c" "d" "e")_$ (vl-position "c" stuff)2

vl-prin1-to-string

(vl-prin1-to-string data)

data )� AutoLISP *�

���

+,-.��� data �/0�1234567 prin1 81��'�

'(

_$ (vl-prin1-to-string "abc")"\"abc\""

_$ (vl-prin1-to-string "c:\\acadwin")"\"C:\\\\ACADWIN\""

_$ (vl-prin1-to-string ’my-var)"MY-VAR"

��9 vl-princ-to-string :�

�� LISP *�+,-�12;567 prin1 :<=��'

Page 225: AutoLisp Reference

vl-princ-to-string | 225

vl-princ-to-string

(vl-princ-to-string data)

��

data �� AutoLISP ���

��

�� ���� data ����� ������ princ ������

_$ (vl-princ-to-string "abc")"abc"

_$ (vl-princ-to-string "c:\\acadwin")"C:\\ACADWIN"

_$ (vl-princ-to-string ’my-var)"MY-VAR"

!�" vl-prin1-to-string #��

vl-propagate

(vl-propagate ’symbol)

��

symbol �$ %& AutoLISP '(�

��

)*&�

+,- (vl-propagate ’radius)nil

�� LISP ������� �.��� princ #�/0���

1'(�23456�7�89:;<=>?@AB AutoCAD �C��7�56DEFG�HI��J

Page 226: AutoLisp Reference

226 | AutoLISP ��

vl-registry-delete

(vl-registry-delete reg-key [val-name])

��

reg-key ����� Windows �� ��

val-name ������ reg-key �����

����� val-name ����� nil�� !��"#�����$% val-name &'�� nil�(� )#� �*�+%���

,-�

��./�,- T�0�,- nil�

12

_$ (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

3 '(��4)#��56� ��7)#56�89:; vl-registry-

descendents <=>)#+%�5��

?�@ vl-registry-descendentsAvl-registry-read B vl-registry-write (��

vl-registry-descendents

(vl-registry-descendents reg-key [val-names])

! Winows ��C)#�� �&�

,-�����5�&�DE�F�

Page 227: AutoLisp Reference

vl-registry-read | 227

��

reg-key ������ Windows �

val-names ����� reg-key �����

���� val-names ����� nil������������� ���!�� val-name "��� nil��#�$% reg-key �&'(�

)*�

��+,�)*�����-�)* nil�

./

$ (vl-registry-descendents "HKEY_LOCAL_MACHINE\\SOFTWARE")("Description" "Program Groups" "ORACLE" "ODBC" "Netscape" "Microsoft")

0�1 vl-registry-delete2vl-registry-read 3 vl-registry-write #��

vl-registry-read

(vl-registry-read reg-key [val-name])

��

reg-key ������ Windows ����

val-name ����� ��������

���� val-name ����� nil���4���56�������!�� val-name "��� nil�#��56���7�&'��

)*�

��+,�)*� ����8�����-�)* nil�

./

_$ (vl-registry-read "HKEY_CURRENT_USER\\Test")nil

_$ (vl-registry-write "HKEY_CURRENT_USER\\Test" "" "test data")"test data"

9:��� /�9�)* Winodws ���;<��8

Page 228: AutoLisp Reference

228 | AutoLISP ��

_$ (vl-registry-read "HKEY_CURRENT_USER\\Test")"test data"

��� vl-registry-delete�vl-registry-descendents � vl-registry-write ��

vl-registry-write

(vl-registry-write reg-key [val-name val-data])

��

reg-key �� �� Windows �����

�� ��� vl-registry-write �� HKEY_USERS �KEY_LOCAL_MACHINE

val-name �� ������� !

val-data �� ������"

#$%�� val-name �&!' nil ()*+�� ,-!#$��. val-name /%�� val-data (012��

34!

#$56( vl-registry-write 34 val-data 7(34 nil

89

_$ (vl-registry-write "HKEY_CURRENT_USER\\Test" "" "test data")"test data"_$ (vl-registry-read "HKEY_CURRENT_USER\\Test")"test data"

��� vl-registry-delete�vl-registry-descendents � vl-registry-read ��

vl-remove

(vl-remove element-to-remove list)

: Windows ���;<=��

>?�; @A

Page 229: AutoLisp Reference

vl-remove-if | 229

��

element-to-remove

��������� �� LISP ����

list ���

��

list�������� element-to-remove �������� ��

!"

_$ (vl-remove pi (list pi t 0 "abc"))(T 0 "abc")

vl-remove-if

(vl-remove-if predicate-function list)

��

predicate-function

#$%�&��'�()*+!�%�,-./)���

01�(2345678�� Tpredicate-function ���92:;<=,

� >? (%�@ ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

list �#$��

��

������ list ��� A predicate-function �� nil ���

!"

_$ (vl-remove-if ’vl-symbolp (list pi t 0 "abc"))(3.14159 0 "abc")

��B�CD���� EFG#$%����HI��

Page 230: AutoLisp Reference

230 | AutoLISP ��

vl-remove-if-not

(vl-remove-if-not predicate-function list)

��

predicate-function

�������� ���������������

��� ������ !" T�predicate-function �#$�%&'(�

� )* (��+ ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

list ,���-�

!"#

-�./01 list /�234 predicate-function !"5 nil #�67�

�8

_$ (vl-remove-if-not ’vl-symbolp (list pi t 0 "abc"))(T)

vl-some

(vl-some predicate-function list [list]...)

��

predicate-function

�������� ���������������

9 vl-some :;�-��������<�������!" T�predicate-function �#$�%&'(�

� )* (��+ ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

!"=2:;-/�23>?@�����67AB�-

CDEF�G�<�67AHIJ nil

Page 231: AutoLisp Reference

vl-sort | 231

list ������

vl-some ������ ����������������������������� !"�#����$�%&� '()��*+���,-

. nil /�0/1234�56�7+�� �89��:;2<=>�?40/�

,-/

@A predicate-function ,-. nil /�B��,-()/�CB��,- nil�

DE

FG�DEHI nlst ��/��JCK9LM���N

_$ (setq nlst (list 0 2 pi pi 4))(0 2 3.14159 3.14159 4)_$ (vl-some ’= nlst (cdr nlst))T

vl-sort

(vl-sort list comparison-function)

��

list OP��

comparison-function

QR���STUJOV �WD���NXY@FZ��

��@A� ���[\]^]7�#���>_�B,- T 5. nil /�comparison-function �/TU`a@FbcN

� de (��f ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

,-/

��g hi list ����Wj��[k comparison-function lm�^]\n�� Topqrst����

uv�m�QR��w*� ���\]

Page 232: AutoLisp Reference

232 | AutoLISP ��

��

�����

_$ (vl-sort ’(3 2 1 3) ’<)(1 2 3) ;

� ���������� 3�

� Y ��������

_$ (vl-sort ’((1 3) (2 2) (3 1)) (function (lambda (e1 e2) (< (cadr e1) (cadr e2)) ) ) )((3 1) (2 2) (1 3))

�����

_$ (vl-sort ’(a d c b a) ’(lambda (s1 s2) (< (vl-symbol-name s1) (vl-symbol-name s2)) ) )(A B C D) ; � � �����!�� A

vl-sort-i

(vl-sort-i list comparison-function)

��

list "���

comparison-function

#$%��&'()"*��+�,%��-./01��

�2/�3�����4 3��567829:; T <= nil ��comparison-function ,�'(>?/0@A�

� �� (%�B ) � ’(LAMBDA (A1 A2) ...) � (FUNCTION (LAMBDA (A1 A2) ...))

:;�

�2C��� list �56,DE�2+F��G comparison-function HI,JK���LMNO,56�

PQRI,#$%����,562S:;56,DE�

Page 233: AutoLisp Reference

vl-string->list | 233

��

�������

_$ (vl-sort-i ’("a" "d" "f" "c") ’>)(2 1 3 0)

��� ���� "f" "d" "c" "a"�"f" ��������������� 2� "d" ��� �������� 1�!"#$�

�%���&'�

_$ (vl-sort-i ’(3 2 1 3) ’<)(2 1 3 0)

()*+,-�./0� 3 �����

� Y 123 45���

_$ (vl-sort-i ’((1 3) (2 2) (3 1)) (function (lambda (e1 e2) (< (cadr e1) (cadr e2)) ) ) )(2 1 0)

3����

_$ (vl-sort-i ’(a d c b a) ’(lambda (s1 s2) (< (vl-symbol-name s1) (vl-symbol-name s2)) ) )(4 0 3 2 1)

()*,-�./0� a �����

vl-string->list

(vl-string->list string)

6&

string �7�

89'

:��;���<�=�>& ?@ string �AB���?C�

��

_$ (vl-string->list "")nil

D�7EF��?C

Page 234: AutoLisp Reference

234 | AutoLISP ��

_$ (vl-string->list "12")(49 50)

��� vl-list->string ���

vl-string-elt

(vl-string-elt string position)

��

string ��� ��

position � ���������� ���� 0������ position ������ ���� !"#$%&'(�

#$�

)��*+,-�.� � ASCII *+�

/0

_$ (vl-string-elt "May the Force be with you" 8)70

vl-string-left-trim

(vl-string-left-trim character-set string)

��

character-set � � 1��234�� �

string � � 5�34 character-set�

#$�

� � 67 string �8� � 9�:; charac ter-set ��� <=234�

#$� ��,-�.� � ASCII *+

5� ��>?34,-�

Page 235: AutoLisp Reference

vl-string-mismatch | 235

��

_$ (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

(vl-string-mismatch str1 str2 [pos1 pos2 ignore-case-p])

��

str1 ������ ��

str2 ������ ��

pos1 ��������� �������������� ! 0�

pos2 ��������� �������������� ! 0�

ignore-case-p �����"#! T �$%&'()�*�+,'()�

-./

���

��

_$ (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

-.0�� �1�"#23���45�6789�5:

Page 236: AutoLisp Reference

236 | AutoLISP ��

vl-string-position

(vl-string-position char-code str [start-pos [from-end-p]])

��

char-code �������� �����

str ������ ���

start-pos �������������� ���� 0!�"#$ 0�

from-end-p %&'�� T�(��) ���*+���, pos *-�

./$

�����) �������, char-code ����%&0�, ��(./ nil�

12

_$ (vl-string-position (ascii "z") "azbdc")1

_$ (vl-string-position 122 "azbzc")1

_$ (vl-string-position (ascii "x") "azbzc")nil

32���� ��456�7z8 ��)9,:;<���� ���= 0���= 1 >?�� z�@�� z (��= 3 >A

_$ (vl-string-position (ascii "z") "azbzlmnqc")1

)9,:���"#BC!�vl-string-position DEF,�= 1 >�7z8 �G%&):,9���%32H��(DEF,�= 3 >�7z8A

_$ (vl-string-position (ascii "z") "azbzlmnqc" nil t)3

� ����I?JK ASCII �� �

Page 237: AutoLisp Reference

vl-string-right-trim | 237

vl-string-right-trim

(vl-string-right-trim character-set string)

��

character-set ����������

string ������� character-set

���

��������� character-set ������

��

_$ (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

(vl-string-search pattern string [start-pos])

��

pattern �����������

string ��������� pattern

start-pos �� �!"���#$%& '(�) 0

���

���!"*+,- pattern �%& ./0*+���1�� nil ���234

���%&) 0

����56�,-��

�������,-��

Page 238: AutoLisp Reference

238 | AutoLISP ��

��

_$ (vl-string-search "foo" "pfooyey on you")1

_$ (vl-string-search "who" "pfooyey on you")nil

_$ (vl-string-search "foo" "fooey-more-fooey" 1)11

vl-string-subst

(vl-string-subst new-str pattern string [start-pos])

��

new-str ����� � pattern�

pattern ������� ������

string �������� pattern�

start-pos ������� !�"#�$%&' 0�

()* !+,-./0��vl-string-subst 1 �����23456�7��

89&

:; �< string �&�

��

=Obi-wan> �=Ben>?

_$ (vl-string-subst "Obi-wan" "Ben" "Ben Kenobi")"Obi-wan Kenobi"

=Obi-wan> �=Ben>?

_$ (vl-string-subst "Obi-wan" "Ben" "ben Kenobi")"ben Kenobi"

@ABC �D' vl-string-subst @A�E=Ben>������=ben>+F/0�=b>����

=Obi-wan> �=Ben>?

�����BC��� �

Page 239: AutoLisp Reference

vl-string-translate | 239

_$ (vl-string-subst "Obi-wan" "Ben" "Ben Kenobi Ben")"Obi-wan Kenobi Ben"

���������� Ben��� vl-string-subst �����������

� Obi-wan��� Ben����������������

_$ (vl-string-subst "Obi-wan" "Ben" "Ben \"Ben\" Kenobi" 3)"Ben \"Obi-wan\" Kenobi"

���� Ben������!" vl-string-subst #��������$%��&'����(��)*����

vl-string-translate

(vl-string-translate source-set dest-set str)

+,

source-set -.������/0�

dest-set �����1�� source-set �����

str ����23�$%4���

567

289��: str �7�

;<

_$ (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

(vl-string-trim char-set str)

2��������

�������4=>?@AB��

Page 240: AutoLisp Reference

240 | AutoLISP ��

��

char-set ������� ������

str �������� char-set�

���

����� str ���

��

_$ (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

(vl-symbol-name symbol)

��

symbol �� LISP ���

���

�������������� !�"#$%�

��

_$ (vl-symbol-name ’S::STARTUP) "S::STARTUP"

_$ (progn (setq sym ’my-var) (vl-symbol-name sym))"MY-VAR"

_$ (vl-symbol-name 1); *** &' : ��()&' : symbolp 1

����*�� ����

Page 241: AutoLisp Reference

vl-symbol-value | 241

vl-symbol-value

(vl-symbol-value symbol)

���� eval ������� LISP � ���

��

symbol �� LISP ���

��

����� symbol � �

��

_$ (vl-symbol-value ’t)T

_$ (vl-symbol-value ’PI)3.14159

_$ (progn (setq sym ’PAUSE) (vl-symbol-value sym))"\\"

vl-symbolp

��

(vl-symbolp object)

object �� LISP !�

��

"# object $��%�� T�&%�� nil�

��

_$ (vl-symbolp t)T

_$ (vl-symbolp nil) nil

��'()*+���

,*-* !.&$��

Page 242: AutoLisp Reference

242 | AutoLISP ��

_$ (vl-symbolp 1)nil

_$ (vl-symbolp (list 1))nil

vl-unload-vlx

(vl-unload-vlx appname)

��

appname ������� ������� VLX ������������� .vlx � ��

vl-unload-vlx !��"���#$%&����� VLX �����

'()

*+,-.'( T�/. vl-unload-vlx 01234�

56

7 vlxns 8�� ������������9:;<0"� vlxns=

;<= (vl-unload-vlx "vlxns")T

>?@A"� vlxns=

;<= (vl-unload-vlx "vlxns"); *** 34 : BC� LISP ���� VLXNS

D?� vl-unload-vlx ;<EFG� HIJK�L�������

M�N load O vl-vlx-loaded-p !��

"�PQ�� ������� VLX ����

Page 243: AutoLisp Reference

vl-vbaload | 243

vl-vbaload

��

(vl-vbaload filename)

filename �������� Visual Basic ��

���

�������������

��

$ (vl-vbaload "c:/program files/acad2000/sample/vba/drawline.dvb")"c:\\program files\\acad2000\\sample\\vba\\drawline.dvb"

��� vl-vbarun ���

vl-vbarun

��

(vl-vbarun macroname)

macroname ����� �� Visual Basic !�

���

macroname�

��

� VBA �"#$

$ (vl-vbaload "c:/program files/acad2000/sample/vba/drawline.dvb")"c:\\program files\\acad2000\\sample\\vba\\drawline.dvb"

%&� �'�!$

_$ (vl-vbarun "drawline")"drawline"

��� vl-vbaload ���

� Visual Basic �

%& Visual Basic !

Page 244: AutoLisp Reference

244 | AutoLISP ��

vl-vlx-loaded-p

(vl-vlx-loaded-p appname)

��

appname ����� VLX �� �

���

���� ������� T��������� nil�

��

�� vlxns �� ����� !"#$%&'(

)*( (vl-vlx-loaded-p "vlxns")nil

�� ��� !"#$%&'�

+,�� vlxns(

)*( (load "vlxns.vlx")nil

�� vlxns �� ��-.��(

)*( (vl-vlx-loaded-p "vlxns")T

/��01 vlxns 2345,!"#$%&'0���678�2�9:;�� <=>?#$%&'�vl-vlx-loaded-p :�� nil�

@�A load B vl-unload-vlx C��

vlax-3D-point

(vlax-3D-point list) D (vlax-3D-point x y [z])

��

list 2 ED 3 E��#F�GFH�

IJKL$%&'<=����

MNO ActiveX PQ#RSTUVWHXY

Page 245: AutoLisp Reference

vlax-add-cmd | 245

x, y ������� X � Y �

z ������� Z �

� �

�������������������

��

$ (vlax-3D-point 5 20)#<variant 8197 ...>

_$ (vlax-3D-point ’(33.6 44.0 90.0))<variant 8197 ...>

�� vlax-make-safearray!vlax-make-variant!vlax-safearray-fill � vlax-safearray-put-element "��

vlax-add-cmd

(vlax-add-cmd global-name func-sym [local-name cmd-flags])

#$ vlax-add-cmd %&'"�()* AutoCAD +,�-./0"�12#$ c: 34�$56%&()78 AutoLISP +,�-9: c: "��;<=%>��

vlax-add-cmd "�#?� AutoLISP "�0@3AutoCAD AB2C* ObjectARX DE�+,�0 AutoCAD +,FGH2#$�vlax-add-cmd "�GIJ9 ObjectARX acedRegCmds K�LM�N-GIJ��O ObjectARX PQ AcEdCommandStack 9R�ST�

vlax-add-cmd "�UV'+,S(O+,��NWX1YZ[\]+,^�vlax-

add-cmd '+,_`O� doc-ID� doc-ID <aWX�bcde��Nfg1YZ[ VLX \]+,^�vlax-add-cmd '+,_`O� VLC-Ddoc-ID:VLX-name�;h VLX-name <\] vlax-add-cmd.�i$jk1�

lm =>#$ vlax-add-cmd nopqris9R�"��6=>$5tnoris� u"��

'+,_`O AutoCAD vw+,x2

Page 246: AutoLisp Reference

246 | AutoLISP ��

��

global-name ����

func-sym ���� ��� AutoLISP ���

local-name �������� global-name��

cmd-flags �������� ACRX_CMD_MODAL + ACRX_CMD_REDRAW��

������

ACRX_CMD_MODAL (0) �� !"#$%�&' (#

$�

ACRX_CMD_TRANSPARENT (1) �� !"#$%)*

' (#$�

+,����

ACRX_CMD_USEPICKSET (2) -./0123%� AutoCAD 45678� #$&9:;123<�&-.=78>?�

ACRX_CMD_REDRAW (4) -./0123=>?3%

�@ABC AutoCAD 456�#$):;123D>?3�

EFG%78H ACRX_CMD_USEPICKSET D ACRX_CMD_REDRAWIJFDK78 ACRX_CMD_REDRAW LM�NO���PQRST�U ObjectARX Reference VW4�XCommand StackY�

Z[�

EF\]IZ[ global-name ���EF acedRegCmds->addCommand(...) Z[^_`aI��Z[ nil�

Mb

cb4� hello-autocad ��d� c: ef< vlax-add-cmd @!g� ObjectARX h��#$ij� AutoCAD #$klj�

_$ (defun hello-autocad () (princ "hello Visual LISP"))HELLO-AUTOCAD

_$ (vlax-add-cmd "hello-autocad" ’hello-autocad)"hello-autocad"

T�U vlax-remove-cmd ���

Page 247: AutoLisp Reference

vlax-create-object | 247

vlax-create-object

(vlax-create-object prog-id)

���������� ������ vlax-create-object ��� <Component> ����������� !"#$���%&� ����� vlax-get-object$'(�)*�����+,-./01234� ���56

78�9:; vlax-create-object�<=>��?��4@� $

prog-id ABC� DE�� ActiveX ���F�GHB$prog-id IJ2K

<Vendor>.<Component>.<Version>

)K

AutoCAD.Drawing.15

LMN

������VLA ��#$

O

�� Excel ���� K

_$ (vlax-create-object "Excel.Application")#<VLA-OBJECT _Application 0017b894>

vlax-curve-getArea

(vlax-curve-getArea curve-obj)

curve-obj �PQ VLA ��$

���������

LMRSTU

Page 248: AutoLisp Reference

248 | AutoLISP ��

���

����� ���������� nil�

��

����� ����� !"#

vlax-curve-getarea ����$!"%

ellipseObj &�'(!" VLA )*�

�� +,-./!" ��#

_$ (vlax-curve-getArea ellipseObj)4.712393

vlax-curve-getDistAtParam

(vlax-curve-getDistAtParam curve-obj param)

��

curve-obj ��� VLA )*�

param ���'0��1 23�

���

��45��������6'0�� 78�9��� nil�

����:;<6'0�� ��= 78

Page 249: AutoLisp Reference

vlax-curve-getDistAtPoint | 249

��

�� splineObj ������� �

vlax-curve-getDistAtParam ��� ���� �

��� �����

_$ (setq startSpline (vlax-curve-getStartParam splineObj))0.0

� ��� 0 ���

��� ����

_$ (setq endSpline (vlax-curve-getEndParam splineObj))17.1546

� ����� 17.1546�

���� ����

_$ (vlax-curve-getDistAtParam splineObj ( / (- endspline startspline) 2))8.99417

������� � 8.99417�

vlax-curve-getDistAtPoint

(vlax-curve-getDistAtPoint curve-obj point)

!"� ��������� #$%

Page 250: AutoLisp Reference

250 | AutoLISP ��

��

curve-obj ���� VLA �

point curve-obj ��� ���� WCS ��

���

�������������� nil

�! ��"# splineObj $% vlax-curve-getDistAtParam � ���&'(

)* OSNAP +,-�./012(3'(4-��5

_$ (setq selPt (getpoint))(4.91438 6.04738 0.0)

6#7'(89�:0#��;<5

_$ (vlax-curve-getDistAtPoint splineObj selpt)5.17769

vlax-curve-getEndParam

(vlax-curve-getEndParam curve-obj)

��

curve-obj ���� VLA �

���

��������=>����������� nil

"# ellipseObj $% vlax-curve-getArea � ��?@!A�B�CDE��'(�>���5

_$ (vlax-curve-getendparam ellipseObj)6.28319

>���+ 6.28319 (pi x 2).

F�G vlax-curve-getStartParam B�

��'(>����

Page 251: AutoLisp Reference

vlax-curve-getEndPoint | 251

vlax-curve-getEndPoint

(vlax-curve-getEndPoint curve-obj)

��

curve-obj ���� VLA ��

��

������������������ nil

��

�� vlax-curve-getArea ���� ���!

_$ (vlax-curve-getEndPoint ellipseObj)(2.0 2.0 0.0)

vlax-curve-getParamAtDist

(vlax-curve-getParamAtDist curve-obj dist)

��

curve-obj ���� VLA ��

dist ���"#$%&'(��$)

��

����������*����� nil

�%&���+, WCS ��-

�$%&'(�."#$)�%&��

Page 252: AutoLisp Reference

252 | AutoLISP ��

��

�� splineObj �� vlax-curve-getDistAtParam ����� ����������� ������ 1.0 ����

_$ (vlax-curve-getParamAtDist splineObj 1.0)0.685049

vlax-curve-getParamAtPoint

(vlax-curve-getParamAtPoint curve-obj point)

��

curve-obj ��� VLA � �

point curve-obj.!"#�$%& WCS '�

()*

+,-./()$0��1�23/() nil�

��

�� ellipseObj �� vlax-curve-getArea ��45�67 OSNAP �89�:;<=> ?45@9��

_$ (setq selPt (getpoint))(7.55765 5.55066 0.0)

AB<����*�

_$ (vlax-curve-getParamAtPoint ellipseObj selPt)4.58296

vlax-curve-getPointAtDist

(vlax-curve-getPointA2tDist curve-obj dist)

��

curve-obj ��� VLA � �

()� &�����

()� !����������%& WCS '

Page 253: AutoLisp Reference

vlax-curve-getPointAtParam | 253

dist ����������� ���

���

�������������� ��������� nil�

!

" splineObj # vlax-curve-getDistAtParam !$ %���&' %�������( 1.0 �)

_$ (vlax-curve-getPointAtDist splineObj 1.0)(2.24236 2.99005 0.0)

vlax-curve-getPointAtParam

(vlax-curve-getPointAtParam curve-obj param)

*+

curve-obj ,-. VLA /0�

param +����� *+�

���

�������������� ��������� nil�

!

12!$�" splineObj # vlax-curve-getDistAtParam !$ %���

34�� ��*+)

_$ (setq startSpline (vlax-curve-getStartParam splineObj))0.0

34�� 56*+)

_$ (setq endSpline (vlax-curve-getEndParam splineObj))17.1546

&�� $�)

_$ (vlax-curve-getPointAtParam splineObj ( / (- endspline startspline) 2))(6.71386 2.82748 0.0)

�����78*+� �

Page 254: AutoLisp Reference

254 | AutoLISP ��

vlax-curve-getStartParam

(vlax-curve-getStartParam curve-obj)

��

curve-obj ���� VLA �

��

��������������������� nil

��

�� ellipseObj �� vlax-curve-getArea �� �!"#�$%�����&

_$ (vlax-curve-getstartparam ellipseObj)0.0

'�( vlax-curve-getEndParam )�

vlax-curve-getStartPoint

(vlax-curve-getStartPoint curve-obj)

��

curve-obj ���� VLA �

��

������������*�+,*������ nil

��

-. vlax-curve-getArea �� !"���*&

_$ (vlax-curve-getStartPoint ellipseObj)(2.0 2.0 0.0)

�/!"�0*12*"3456�

��$%�����

��$%���*78 WCS 9

Page 255: AutoLisp Reference

vlax-curve-isClosed | 255

�� vlax-curve-getDistAtParam ���������

_$ (vlax-curve-getStartPoint splineObj)(1.73962 2.12561 0.0)

vlax-curve-isClosed

(vlax-curve-isClosed curve-obj)

��

curve-obj ��� VLA ���

���

��������� T����� nil�

��

! vlax-curve-getArea �����"���

_$ (vlax-curve-isClosed ellipseObj)T

! vlax-curve-getDistAtParam �������"���

_$ (vlax-curve-isClosed splineObj)nil

vlax-curve-isPeriodic

(vlax-curve-isPeriodic curve-obj)

��

curve-obj ��� VLA ���

!#!��"���$%&�'(�"�)�*

!#!��"�+,-./01"23�456+7-89� dT�:;�<=>�� u�1?��0� (u + dT) = � (u) @A

Page 256: AutoLisp Reference

256 | AutoLISP ��

���

����� ����� T����� nil�

��

�� vlax-curve-getArea ��������� ��

_$ (vlax-curve-isPeriodic ellipseObj)T

�� vlax-curve-getDistAtParam ���������� ��

_$ (vlax-curve-isPeriodic splineObj)nil

vlax-curve-isPlanar

(vlax-curve-isPlanar curve-obj)

��

curve-obj ���� VLA !�

���

��"#$%��&'���� T����� nil�

��

���"#$% vlax-curve-getArea �������&'�

_$ (vlax-curve-isPlanar ellipseObj)T

���"#$% vlax-curve-getDistAtParam ��������&'�

_$ (vlax-curve-isPeriodic splineObj)nil

���"#$%��&'

Page 257: AutoLisp Reference

vlax-curve-getClosestPointTo | 257

vlax-curve-getClosestPointTo

(vlax-curve-getClosestPointTo curve-obj givenPnt [extend])

��

curve-obj ���� VLA ��

givenPnt �� WCS ������ �����

extend ����������� nil�vlax-curve-getClosestPointTo �!"��#$%��

&'�

��()*&'+,�� -�./+�0*&' nil

12

3������� 45678�9:;

&'�� �<= (6.0, 0.5) ���;

_$ (vlax-curve-getClosestPointTo arcObj ’(6.0 0.5 0.0))(6.0 1.5 0.0)

$%9:>�&'�� �<= (6.0, 0.5) ���;

_$ (vlax-curve-getClosestPointTo arcObj ’(6.0 0.5 0.0) T)(5.7092 0.681753 0.0)

&'�� ?������� WCS �

Page 258: AutoLisp Reference

258 | AutoLISP ��

vlax-curve-getClosestPointToProjection

(vlax-curve-getClosestPointToProjection curve-obj givenPnt normal [extend])

��

curve-obj ���� VLA �

givenPnt WCS ��� ������������

normal WCS ������ ������

extend � �����!"#$% nil vlax-curve-getClosestPointToProjection �&'���()*��

vlax-curve-getClosestPointToProjection +����,- givenPnt . normal �/���� 01�����234 givenPnt ����01 vlax-curve-getClosestPointToProjection +5 �67��,89���� :;<��1��

;<#

� => ?;<@A���B��CD�@ E?;< nil

vlax-curve-getFirstDeriv

(vlax-curve-getFirstDeriv curve-obj param)

��

curve-obj ���� VLA �

param �# ��������

;<#

� =>?;<CD��@ E?;< nil

�+����,���F1 ;<�������G� WCS �H

;<�����IJ�KBLMNG� WCS �H

Page 259: AutoLisp Reference

vlax-curve-getSecondDeriv | 259

��

������� splineObj vlax-curve-getDistAtParam ������ ��

�� �������

_$ (setq startSpline (vlax-curve-getStartParam splineObj))0.0

�� �������

_$ (setq endSpline (vlax-curve-getEndParam splineObj))17.1546

��� ���������� �

_$ (vlax-curve-getFirstDeriv splineObj ( / (- endspline startspline) 2))(0.422631 -1.0951 0.0)

vlax-curve-getSecondDeriv

(vlax-curve-getSecondDeriv curve-obj param)

��

curve-obj !"#� VLA $%�

param �&�� �'����

()&

*+,-.()/01#2�3.() nil�

��

������� splineObj vlax-curve-getDistAtParam ������ ��

�� �������

_$ (setq startSpline (vlax-curve-getStartParam splineObj))0.0

�� �������

_$ (setq endSpline (vlax-curve-getEndParam splineObj))17.1546

() ���45��6�� 7� WCS �8

Page 260: AutoLisp Reference

260 | AutoLISP ��

��������� ����

_$ (vlax-curve-getSecondDeriv splineObj ( / (- endspline startspline) 2))(0.0165967 0.150848 0.0)

vlax-dump-object

(vlax-dump-object obj [T])

obj VLA ���

T �������vlax-dump-object �� obj ������

!"

��#$% ! T�����&'(��)�vlax-dump-object *+,-./�

01

_$ (setq aa (vlax-get-acad-object))#<VLA-OBJECT IAcadApplication 00b3b91c>

_$ (vlax-dump-object aa); IAcadApplication: AutoCAD 2345�61; 78"�; ActiveDocument (RO) = #<VLA-OBJECT IAcadDocument 01b52fac>; Application (RO) = #<VLA-OBJECT IAcadApplication 00b3b91c>; Caption (RO) = "AutoCAD - [Drawing.dwg]"...T

����789������

_$ (vlax-dump-object aa T); IAcadApplication: AutoCAD 2345�61; 78"�; ActiveDocument (RO) = #<VLA-OBJECT IAcadDocument 01b52fac>; Application (RO) = #<VLA-OBJECT IAcadApplication 00b3b91c>; Caption (RO) = "AutoCAD - [Drawing.dwg]"...

����78�:;<=�������

Page 261: AutoLisp Reference

vlax-ename->vla-object | 261

; ������; EndUndoMark (); Eval (1); GetInterfaceObject (1); ListAds (); ListArx ()...T

vlax-ename->vla-object

(vlax-ename->vla-object entname)

��

entname ��AutoLISP ���

���

VLA �

��

_$ (setq e (car (entsel)))<���� 27e0540>

_$ (vlax-ename->vla-object e)#<VLA-OBJECT IAcadLWPolyline 03f713a0>

��� vlax-vla-object->ename ���

vlax-erased-p

(vlax-erased-p obj)

��

obj VLA �

���

����� !�� T "!�� nil�

# AutoLISP ���$%& VLA

'()"���

Page 262: AutoLisp Reference

262 | AutoLISP ��

vlax-for

(vlax-for symbol collection [expression1 [expression2 ...]])

��

symbol ������� ���� VLA ���

collection VLA ������ ���

expression1, expression2...

��������

���

� �� !����� !"�����#�$%�

&'

()�*+�,-./������01 vlax-dump-object2

(vl-load-com) ; 34 ActiveX 56(vlax-for for-item (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)) ) (vlax-dump-object for-item) ; 71��89)

vlax-get-acad-object

(vlax-get-acad-object)

���

VLA ���

&'

_$ (setq aa (vlax-get-acad-object))#<VLA-OBJECT IAcadApplication 00b3b91c>

:;����������<=#�

>?@A AutoCAD BC��DE AutoCAD FGHI��

Page 263: AutoLisp Reference

vlax-get-object | 263

vlax-get-object

(vlax-get-object prog-id)

��

prog-id �������� �����prog-id �����

appname.objecttype

�� appname �� ����objecttype �� �����objecttype ������ �

!" #$�%&� ���&'()*+,-� ��� prog-id�./�Microsoft® Office � ��0-1234&5&'()� Visual Basic® �678�

9:;

� �����/<=>&?&@A�BC��D.�E9: nil�

F.

GH Excel ���� �����

_$ (vlax-get-object "Excel.Application")#<VLA-OBJECT _Application 0017bb5c>

vlax-get-or-create-object

(vlax-get-or-create-object prog-id)

9:� �����@AD.

9:� �����@AD.�/<� ��IJK@A�ELMND.

Page 264: AutoLisp Reference

264 | AutoLISP ��

��

prog-id ������ ActiveX � ��������prog-id �����

<Vendor>.<Component>.<Version>

���

AutoCAD.Drawing.15

���

� �

��

_$ (vlax-get-or-create-object "Excel.Application")#<VLA-OBJECT _Application 0017bb5c>

vlax-get-property

(vlax-get-property object property)

� �!� vlax-get�

��

object VLA � �

property �"#������$%&�'(�

���

� '(���

��

%&)* AutoCAD � �)+�

_$ (setq acadObject (vlax-get-acad-object))#<VLA-OBJECT IAcadApplication 00a4b2b4>

,- AutoCAD ActiveDocument '(�

_$ (setq acadDocument (vlax-get-property acadObject ’ActiveDocument))#<VLA-OBJECT IAcadDocument 00302a18>

���./01� �

%& VLA � �'(

Page 265: AutoLisp Reference

vlax-import-type-library | 265

�� ActiveDocument ��� ModelSpace ���

_$ (setq mSpace (vlax-get-property acadDocument ’Modelspace))#<VLA-OBJECT IAcadModelSpace 00c14b44>

�� ���������

�������� VLA ���

$ (setq vlaobj (vlax-ename->vla-object e))#<VLA-OBJECT IAcadLWPolyline 0467114c>

����������

$ (vlax-get-property vlaobj ’Color)256

��� vlax-property-available-p vlax-put-property !"�

vlax-import-type-library

(vlax-import-type-library :tlb-filename filename [ :methods-prefix mprefix :properties-prefix pprefix :constants-prefix cprefix])

�"

filename #$%&'()�*� +,�-.)��

� )�* (.tlb) /��* (.olb) +� ,01 (.exe) +� 23)�*45�* (.dll) +� 67)�*�89 �

� :;,< LoadTypeLib API =>� +?@

-ABC tlb-filename D�EF&AutoCAD �GHI +JKEFDLM�

mprefix NO��PQ2RS!"��T�U-&-A)�*23 Calculate PQ&V mprefix �"WX� cc-&Y Visual LISP Z[\� cc-Calculate �2RS!"�]�"�^B_�`a�

b)�*Dcdef

Page 266: AutoLisp Reference

266 | AutoLISP ��

pprefix �������� ������������� Width ��������� �! pprefix "#$ cc-�% Visual LISP &'($ cc-get-Width ) cc-put-Width ��� �*� �+,-$./�

cprefix �����012������������� ccMaxCountOfRecords ��������� �! cprefix "#$ cc-�% Visual LISP &'($ cc-ccMaxCountOfRecords. �12�*� �+,-$./�

34567 vlax-import-type-library 89� :;<=�>��

?@-

��'A%?@ T�

B�

CD Microsoft Word™ ����$EF)��GH��.msw-/��$12GH��.mswc-/I

$ (vlax-import-type-library :tlb-filename "c:/program files/microsoft office/msword8.olb" :methods-prefix "msw-" :properties-prefix "msw-" :constants-prefix "mswc-")T

J4

K vlax-import-type-library LM����N6OP vlax-import-type-library �QRST0U��

6V�WX� Visual LISP 0�vlax-import-type-library Y6Z[:!\Y6&':][��6^_WX� Visual LISP 0�`abcUdO&ef�6>� vlax-import-type-library :�Mghij�klmI

� ��hno6\p�qrstZ[pauv�%\w6 tlb-file-name � 0GHx�yz�

� Ud�{�\w|}~ AutoLISP ������Z[ vlax-import-type-library ����2|������#��*� ��

Page 267: AutoLisp Reference

vlax-invoke-method | 267

� � AutoLISP ������� vlax-import-type-library��� ����������������������

!" vlax-typeinfo-available-p #$�

vlax-invoke-method

(vlax-invoke-method obj method arg [arg...])

%#$� AutoCAD 2000 &'�()�* vlax-invoke�

!$

obj VLA +,�

method -.�/-0�1�2�����

arg 2345���!$�6789:!$��;<�

=>?

@AB�����

CD

ED AddCircle ���F' AutoCAD GH�IJKLM�

AddCircle �NKL!$1�MO�PQ�AddCircle ��2R1��MO*KLST�U��VWXYLZ[\$]^�$_�`a vlax-3d-point b AutoLISP cdef*gh�ST$i��j

_$ (setq circCenter (vlax-3d-point ’(3.0 3.0 0.0)))#<variant 8197 ...>

k� vlax-invoke-method � AddCircle ��IJMj

_$ (setq mycircle (vlax-invoke-method mspace ’AddCircle circCenter 3.0))#<VLA-OBJECT IAcadCircle 00bfd6e4>

!" vlax-get-property�vlax-method-applicable-p�vlax-property-available-p l vlax-put-property #$�

�1�� ActiveX ��

Page 268: AutoLisp Reference

268 | AutoLISP ��

vlax-ldata-delete

(vlax-ldata-delete dict key [private])

��

dict VLA ���AutoCAD ������� ��������

key ������������

private �� private ������� !"#�$ VLX %& vlax-ldata-delete�' vlax-ldata-delete � dict ()*+, LISP �-�.�/0&1���23�4�5 vlax-ldata-get�6

78�

��9:'78 T�;'78 nil .��-<=>6�

?@

A��(BC LISP �-D

_$ (vlax-ldata-put "dict" "key" ’(1))(1)

0& vlax-ldata-delete )* LISP �-D

_$ (vlax-ldata-delete "dict" "key")T

��EF%& vlax-ldata-delete )*GH��-�1I�J78 nil�KL��(M

<E,1�-�

_$ (vlax-ldata-delete "dict" "key")nil

4�5 vlax-ldata-get�vlax-ldata-list N vlax-ldata-put I��

vlax-ldata-get

(vlax-ldata-get dict key [default-data] [private])

�����()* LISP �-

>������(OP LISP �-

Page 269: AutoLisp Reference

vlax-ldata-get | 269

��

dict VLA ���AutoCAD �������� �������

key �����������

default-data ��������������� !" LISP �#�

private �� private �$%&�'()*+,&- VLX ./ vlax-ldata-get�� vlax-ldata-get 0 dict �123� LISP �#�

���4 private��56� default-data�789:;�< nil�

=>?�0)*+,&- VLX ��78@/AB� dict C key ��ADEF3�C%3�GH�3��#IJ0AK VLX �LM�N%3��#78OPQR/ST12�

!$

key �$�

BU

0 Visual LISP VWXYZ[\]^

_$ (vlax-ldata-put "mydict" "mykey" "Mumbo Dumbo")"Mumbo Dumbo"

_$ (vlax-ldata-get "mydict" "mykey")"Mumbo Dumbo"

_`0 VLX �@/3��#�ab

1 0 Visual LISP VWXYZ[\]^

_$ (vlax-ldata-put "mydict" "mykey" "Mumbo Dumbo")"Mumbo Dumbo"

_$ (vlax-ldata-get "mydict" "mykey")"Mumbo Dumbo"

2 0cd�XYZ[ef�g:@/hijR/STk9cdij< VLX�@/hijR/STklm�hnokpq�r0hR/STstk�suh)*+

,&-k�

Page 270: AutoLisp Reference

270 | AutoLISP ��

(vl-doc-export ’ldataput)(vl-doc-export ’ldataget)(vl-doc-export ’ldataget-nilt)(defun ldataput () (princ "This is a test of putting private ldata ") (vlax-ldata-put "mydict" "mykey" "Mine! Mine! " T))(defun ldataget () (vlax-ldata-get "mydict" "mykey"))(defun ldataget-nilt () (vlax-ldata-get "mydict" "mykey" nil T))

3 �� VLX ���

4 � ldataput �� ����

_$ (ldataput)This is a test of putting private ldata

������ ldataput ������������� "Mine! Mine!" �!"#�

5 � ldataget $% LISP ���

_$ (ldataget)"Mumbo Dumbo"

&'( ldataget )*���+, ldataput ������-./0 ldataget 123 vlax-ldata-get 45�6� private ���78ldataget $%���.9 1 :;< Visal LISP =>?;23 vlax-ldata-put @A����

_$ (ldataget-nilt)"Mine! Mine! "

6 � ldataget-nilt $% LISP ���

_$ (ldataget-nilt)"Mine! Mine! "

-B)*C ldataput ��� ���8/0 ldataget-nilt 123 vlax-ldata-get.46�� private ���

7 1 Visual LISP =>?DE;FG ldataget-nilt HI�238$% ����

_$ (vlax-ldata-get "mydict" "mykey" nil T)"Mumbo Dumbo"

1<JKLMNO VLX ;23 vlax-ldata-get 48PQ� private ���RS6�� dict T key8UV�1, ���WUXY7EZ8[$%, ����

&�\ vlax-ldata-put]vlax-ldata-delete T vlax-ldata-list ���

Page 271: AutoLisp Reference

vlax-ldata-list | 271

vlax-ldata-list

(vlax-ldata-list dict [private])

��

dict VLA ���AutoCAD �������� �������

private ��������� VLX �� vlax-ldata-list ! private �"# nil $ vlax-ldata-list %&'()*+, VLX -�./�0�1234���5� 6�7 vlax-ldata-get�8

9:"

;� (key . value) <=�2>?�

@A

5� vlax-ldata-put )B��-� LISP �0C

$ (vlax-ldata-put "dict" "cay" "Mumbo Jumbo ")"Mumbo Jumbo "$ (vlax-ldata-put "dict" "say" "Floobar ")"Floobar "

5� vlax-ldata-list DE)B*FdictG-� LISP �0C

_$ (vlax-ldata-list "dict")(("say" . "Floobar ") ("cay" . "Mumbo Jumbo "))

6�7 vlax-ldata-get�vlax-ldata-delete H vlax-ldata-put I��

vlax-ldata-put

(vlax-ldata-put dict key data [private])

JK����-� LISP �0

)B������-� LISP �0

Page 272: AutoLisp Reference

272 | AutoLISP ��

��

dict VLA ���AutoCAD ������� ��������

key ������������

data �������� LISP ���

private � !"#$%&' VLX () vlax-ldata-put�* private �+, nil�- vlax-ldata-put ./01 VLX ���23456��

78+

data �+�

9:

_$ (vlax-ldata-put "dict" "key" ’(1))(1)

$ (vlax-ldata-put "dict" "cay" "Gumbo jumbo")"Gumbo jumbo"

;�< vlax-ldata-get�vlax-ldata-delete = vlax-ldata-list >��

vlax-ldata-test

(vlax-ldata-test data)

��

data ?@�AB� LISP ���

78+

� ��4CD?EFGH�=IJ�-78 T�K-78 nil�

9:

L����MKNOH�3D?EFG� ldataP

_$ (vlax-ldata-test "Gumbo jumbo")T

L���MKND?EFGH�

Page 273: AutoLisp Reference

vlax-make-safearray | 273

���������� ���� ldata�

_$ (vlax-ldata-test yinyang)nil

��� vlax-ldata-get�vlax-ldata-delete�vlax-ldata-list � vlax-ldata-put ���

vlax-make-safearray

(vlax-make-safearray type ’(l-bound . u-bound) [ ’(l-bound . u-bound)...)]

��������� 16 !���"�#$%&'()*+,�

�- 0

./0 123./0�

45- :vlax-false

67 nil

89 :*+, (vlax-vbEmpty)

;< SafeArray

Page 274: AutoLisp Reference

274 | AutoLISP ��

��

type SafeArray ������� ��

vlax-vbInteger (2)— ���

vlax-vbLong (3)— ����

vlax-vbSingle (4)— ������

vlax-vbDouble (5)— ������

vlax-vbString (8)— ���

vlax-vbObject (9)— ��

vlax-vbBoolean (11)— ���

vlax-vbVariant (12)— !

"#$���%& ����'��$() �*+,

- ����./01�'23 AutoCAD $�4567 8�

’(l-bound . u-bound)

9:;�<=�>�

?@�

AB� SafeArray�

CD

ABEFG 0 HI=JK�����:;�L�

_$ (setq point (vlax-make-safearray vlax-vbDouble ’(0 . 3)))#<safearray...>

MN vlax-safearray->list O�P SafeArray �QRS&/%�

$ (vlax-safearray->list point)(0.0 0.0 0.0 0.0)

TUVW*�L$�XYZ[\]^I8/ 0�

Page 275: AutoLisp Reference

vlax-make-variant | 275

���������� ������ 1 ���

$ (setq matrix (vlax-make-safearray vlax-vbString ’(1 . 2) ’(1 . 2) ))#<safearray...>

��� vlax-make-variant�vlax-safearray-fill�vlax-safearray-get-dim�vlax-safearray-get-element�vlax-safearray-get-l-bound�vlax-safearray-get-u-bound�vlax-safearray-put-element�vlax-safearray-type�vlax-safearray->list � vlax-variant-value ����� !"��#$%&���� Visual LISP ������

�'� Safearray(�

vlax-make-variant

(vlax-make-variant [value] [type])

value )*+,-.�/�01234��-.5��6 vlax-vbEmpty 789:;�<=�

type -.�78�>?@ABCDEFGH�

vlax-vbEmpty (0)— :;�<9I2/=

vlax-vbNull (1)— JKLMNO

vlax-vbInteger (2)— P8

vlax-vbLong (3)— QP8

vlax-vbSingle (4)— RSTUV

vlax-vbDouble (5)— WSTUV

vlax-vbString (8)— ���

vlax-vbObject (9)— XY

vlax-vbBoolean (11)— Z[/

��-.O78

Page 276: AutoLisp Reference

276 | AutoLISP ��

vlax-vbArray (8192)— ��

������� ������������ ���

���� ����������� AutoCAD �� !"#$%�

&'��� type�vlax-make-variant () value ��*��+,��)-.�/0��123 LISP �)-.�+,$4�)-.5

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— 678��-.9:

vlax-make-safearray— vlax-vbArray

;<�

=>�$4�

?@

AB vlax-make-variant �+,�=>$45

_$ (setq varnil (vlax-make-variant))#<variant 0 >

C�+,=>D78% (vlax-vbEmpty) �$4��EB/F�GHIBJK:?�L 5

_$ (setq varnil (vlax-make-variant nil))#<variant 0 >

=>.$4MNO�PQ� 55

_$ (setq varint (vlax-make-variant 5 vlax-vbInteger))#<variant 2 5>

RSTUVW�XYZO�� type ���[\]'5

Page 277: AutoLisp Reference

vlax-map-collection | 277

_$ (setq varint (vlax-make-variant 5))#<variant 3 5>

������vlax-make-variant ���� ������������������������ !"#$� %�&'()*+��,-.�

�/012 type 3��456�789

_$ (setq varstr (vlax-make-variant "ghost"))#<variant 8 ghost>

-:;<=�>*+�?@��� vlax-vbArray AB�>C������6�-:;<=DEF��>*+�G��*H I�DEF�>9

$ (setq 4dubs (vlax-make-safearray vlax-vbDouble ’(0 . 3)))#<safearray...>

JK�DEF�>��*+9

_$ (vlax-make-variant 4dubs)#<variant 8197 ...>

L3M vlax-make-safearrayNvlax-variant-change-typeNvlax-variant-type O vlax-variant-value P��QR#$*+STUV�L3M Visual LISP ������

CW#$*+X�

vlax-map-collection

(vlax-map-collection obj function)

3�

obj YZ[\ VLA ]^�

function -_$` obj 1ab lambda Zc'�

de

fg�3� obj�

�P�_$`[\Chi]^

Page 278: AutoLisp Reference

278 | AutoLISP ��

��

(vlax-map-collection (vla-get-ModelSpace acadDocument) ’vlax-dump-object); IAcadLWPolyline: AutoCAD Lightweight Polyline ���; ��; Application (RO) = #<VLA-OBJECT IAcadApplication 00a4ae24>; Area (RO) = 2.46556; Closed = 0; Color = 256; ConstantWidth = 0.0; Coordinate = ...�� ������ ...; Coordinates = (8.49917 7.00155 11.2996 3.73137 14.8 5.74379 ... ); Database (RO) = #<VLA-OBJECT IAcadDatabase 01e3da44>; Elevation = 0.0; Handle (RO) = "53"; HasExtensionDictionary (RO) = 0; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 01e3d7d4>; Layer = "0"; Linetype = "BYLAYER"; LinetypeGeneration = 0; LinetypeScale = 1.0; Lineweight = -1; Normal = (0.0 0.0 1.0); ObjectID (RO) = 28895576; ObjectName (RO) = "AcDbPolyline"; PlotStyleName = "ByLayer"; Thickness = 0.0; Visible = -1T

vlax-method-applicable-p

(vlax-method-applicable-p obj method)

��

obj VLA ���

method ���������� !"#�$%�&'�

()

*+��,-.$%�/() T�0/() nil�

��

12��30,-45$%

Page 279: AutoLisp Reference

vlax-object-released-p | 279

������� LightweightPolyline ��

_$ (vlax-method-applicable-p WhatsMyLine ’copy)T

_$ (vlax-method-applicable-p WhatsMyLine ’AddBox)nil

�� vlax-property-available-p ��

vlax-object-released-p

(vlax-object-released-p obj)

�� ���� VLA ����� command "ERASE" � vla-erase��������� ��!"� vlax-release-object#$%&'()*� +,-.�/012

,3�45678VLA ���9:���

��

obj VLA ���

;<=

>?��@:���ABCDE obj � AutoCAD ,3���8F;< T8>?��GH��8F;< nil�

IJ

K Excel L�MNCDEO7 AutoCAD ,3

_$ (setq excelobj (vlax-get-object "Excel.Application"))#<VLA-OBJECT _Application 00168a54>

�� Excel ��

_$ (vlax-release-object excelobj)1

� vlax-object-released-p PQ��@:��

_$ (vlax-object-released-p excelobj)T

RS��TU@:��

Page 280: AutoLisp Reference

280 | AutoLISP ��

vlax-product-key

AutoCAD ���������� ��������

(vlax-product-key)

���

�� AutoCAD ����������

��

_$ (vlax-product-key)"Software\\Autodesk\\AutoCAD\\R15.0\\ACAD-1:409"

vlax-property-available-p

(vlax-property-available-p obj prop [check-modify])

obj VLA !"�

property �#$����%&'()�*+�

check-modify ,-%&� ��. T�vlax-property-available-p /()�01*+�

���

,-2%& check-modify � ��$3�4. T�5!"67%&*+�8 �� T�9:�� nil�,-%& check-modify � ��. T�5;*+4�$;*+4<01�vlax-property-available-p �� nil�

��

=��> LightweightPolyline !"?

_$ (vlax-property-available-p WhatsMyLine ’Color)T_$ (vlax-property-available-p WhatsMyLine ’center)nil

�� AutoCAD � Window �����

@&!"A967%&*+

Page 281: AutoLisp Reference

vlax-put-property | 281

����� Circle ���

_$ (vlax-property-available-p myCircle ’area)T

�� ��������������

_$ (vlax-property-available-p myCircle ’area T)nil

���� nil�� !"#$%&area'()�*+(),-./�0

�1 vlax-method-applicable-p 2 vlax-put-property ��0

vlax-put-property

(vlax-put-property obj property arg)

+��3 vlax-put0

��

obj VLA ��0

property 456748�9:;<=�()0

arg ;<=�>0

��>

?�@AB�� Nil0

C�

D��EF GF�

$ (vlax-put-property vlaobj ’Color 1)nil

�1 vlax-get-property 2 vlax-property-available-p ��0

<= ActiveX ���()

Page 282: AutoLisp Reference

282 | AutoLISP ��

vlax-read-enabled-p

(vlax-read-enabled-p obj)

��

obj VLA ���

��

���� ��� T����� nil�

vlax-release-object

(vlax-release-object obj)

��

obj VLA ���

������������ obj ������

��

�� �

vlax-remove-cmd

!"# AutoCAD $%&'()*+,('-)*�

(vlax-remove-cmd global-name)

��

global-name . )*/012�+ T�� global-name 3 T��%&,()*- VLC-AppName 4 VLC-VLIDE5�

� ��6��

������

%&'()*+'-)*

Page 283: AutoLisp Reference

vlax-safearray-fill | 283

���

������� T���� ������ nil�

��

��� vlax-add-cmd ���� �

_$ (vlax-remove-cmd "hello-autocad")T

�� vlax-remove-cmd�

_$ (vlax-remove-cmd "hello-autocad")nil

�� vlax-remove-cmd �� nil�� �� !"#�

$%& vlax-add-cmd '(�

vlax-safearray-fill

(vlax-safearray-fill var ’element-values)

%(

var )*+(,-.� SafeArray�

’element-values /"0#(12��3� ����(4567(189�

(4:�;��� ����(4<=(1289�>(

?@�89ABCDE��

F=;G(1element-values HI�3�J3+2K>3FL=(12�:G�

���

var

��

MN:>:GOPQ(1�

_$ (setq sa (vlax-make-safearray vlax-vbdouble ’(0 . 2)))#<safearray...>

# SafeArray �892"0(,

Page 284: AutoLisp Reference

284 | AutoLISP ��

�� vlax-safearray-fill ����

_$ (vlax-safearray-fill sa ’(1 2 3))#<safearray...>

���� �

_$ (vlax-safearray->list sa)(1.0 2.0 3.0)

� vlax-safearray-fill �����������

$ (vlax-safearray-fill sa ’(-66))#<safearray...>

���� �

_$ (vlax-safearray->list sa)(-66.0 2.0 3.0)

������������������ !"#���$%���&'()*

+�&�,�-�.��� !/0������$ 12�� vlax-put-element 3�'

� vlax-safearray-fill ������4��� !5���678.���

_$ (vlax-safearray-fill sa ’(1 2 3 4))9:;<=>safearray-fill =>'��?@'

()AB�����CD���78����� vlax-safearray-fill 3�EF9:GH'

+AB@I���$ 12J vlax-safearray-fill AB��KL�M�L 5L��N�OLPQD����I'RS�TUVW��,IXYZ�� "�NI[

78.���

_$ (setq mat2 (vlax-make-safearray vlax-vbString ’(0 . 1) ’(1 . 3)))#<safearray...>

�� vlax-safearray-fill ����

_$ (vlax-safearray-fill mat2 ’(("a" "b" "c") ("d" "e" "f")))#<safearray...>

\� vlax-safearray->list 3�]^ mat2 � �

_$ (vlax-safearray->list mat2)(("a" "b" "c") ("d" "e" "f"))

��_ vlax-make-safearray`vlax-safearray-get-dim`vlax-safearray-get-element`vlax-safearray-get-l-bound`vlax-safearray-get-u-bound`vlax-safearray-put-element`vlax-safearray-type`vlax-safearray->list a vlax-variant-value 3�'

Page 285: AutoLisp Reference

vlax-safearray-get-dim | 285

vlax-safearray-get-dim

(vlax-safearray-get-dim var)

��

var ������� SafeArray�

� �

����� var ������ var �� SafeArray��� �����

��

� sa-int !� SafeArray"

_$ (setq sa-int (vlax-make-safearray vlax-vbinteger ’(1 . 4)))#<safearray...>

#$ vlax-safearray-get-dim � sa-int ���"

_$ (vlax-safearray-get-dim sa-int)1

%�& vlax-make-safearray'vlax-safearray-get-l-bound ( vlax-safearray-get-u-bound )��

vlax-safearray-get-element

(vlax-safearray-get-element var element...)

��

var ������� SafeArray�

element... ���*+,-.�/0�.1�23!��4�5*+

!6���237��4�*+�.1�58�4���9

:�

� SafeArray 2;���

� <=�4>�/0

Page 286: AutoLisp Reference

286 | AutoLISP ��

���

����

� �������������� 1 ���

$ (setq matrix (vlax-make-safearray vlax-vbString ’(1 . 2) ’(1 . 2) ))#<safearray...>

�� vlax-safearray-put-element !���

_$ (vlax-safearray-put-element matrix 1 1 "a")"a"_$ (vlax-safearray-put-element matrix 1 2 "b")"b"_$ (vlax-safearray-put-element matrix 2 1 "c")"c"_$ (vlax-safearray-put-element matrix 2 2 "d")"d"

�� vlax-safearray-get-element "���#$���#�����

$ (vlax-safearray-get-element matrix 1 2)"b"

%�& vlax-make-safearray'vlax-safearray-get-dim'vlax-safearray-get-l-bound'vlax-safearray-get-u-bound ( vlax-safearray-put-element )�

vlax-safearray-get-l-bound

(vlax-safearray-get-l-bound var dim)

��

var *+���,-./ SafeArray

dim �����#$�/ 1

���

0��12��345����678 var 9:��; dim <=57>?/ 0 ;@A�������6�B��CDEF

��GH��I$��345����6

Page 287: AutoLisp Reference

vlax-safearray-get-u-bound | 287

��

�������� SafeArray �

(vlax-make-safearray vlax-vbString ’(1 . 2) ’(0 . 1) ))

� �����������

_$ (vlax-safearray-get-l-bound tmatrix 1)1

������ 1 ���

� �����������

$ (vlax-safearray-get-l-bound tmatrix 2)0

������ 0 ���

��� vlax-make-safearray�vlax-safearray-get-dim � vlax-safearray-get-u-bound ���

vlax-safearray-get-u-bound

(vlax-safearray-get-u-bound var dim)

��

var !"#�$%&' SafeArray�

dim ���������' 1�

()

*�"+,��-./01��2��3 var 45��6 dim 78/�9:' 0 6;<������2"=()>?@A�

��

�������� SafeArray �

(vlax-make-safearray vlax-vbString ’(1 . 2) ’(0 . 1) ))

� ������01���

_$ (vlax-safearray-get-u-bound tmatrix 1)2

()BC��D���-./01��2

Page 288: AutoLisp Reference

288 | AutoLISP ��

������ 2 �

� ����������

$ (vlax-safearray-get-u-bound tmatrix 2)1

������ 1 �

��� vlax-make-safearray�vlax-safearray-get-dim � vlax-safearray-get-l-bound ���

vlax-safearray-put-element

(vlax-safearray-put-element var index... value)

��

var �������� SafeArray�

index... ����!�"#$"%��&'�()�����*"%

�+����()�����,"%-+����./�0�

value $"%1 SafeArray &'���

23�

"%1��&'�� value�

45

6789:;�<=������

_$ (setq point (vlax-make-safearray vlax-vbDouble ’(0 . 2)))#<safearray...>

>? vlax-safearray-put-element @A���

_$ (vlax-safearray-put-element point 0 100)100_$ (vlax-safearray-put-element point 1 100)100_$ (vlax-safearray-put-element point 2 0)0

1BC��D�E&'F�

Page 289: AutoLisp Reference

vlax-safearray-type | 289

���������� �

$ (setq matrix (vlax-make-safearray vlax-vbString ’(1 . 2) ’(1 . 2) ))#<safearray...>

�� vlax-safearray-put-element ��� �

_$ (vlax-safearray-put-element matrix 1 1 "a")"a"_$ (vlax-safearray-put-element matrix 1 2 "b")"b"_$ (vlax-safearray-put-element matrix 2 1 "c")"c"_$ (vlax-safearray-put-element matrix 2 2 "d")"d"

��������� vlax-safearray-fill ������ ������� !" vlax-safearray-put-element ��#�$%�

(vlax-safearray-fill matrix ’(("a" "b") ("c" "d")))

�&' vlax-safearray-get-element(vlax-safearray-fill ) vlax-safearray-type ���

vlax-safearray-type

(vlax-safearray-type var)

&�

var *+ SafeArray ,-�

./0

12 var *+ SafeArray�3./�45�67�

2 5�8 (vlax-vbInteger)

3 95�8 (vlax-vbLong)

4 :;<=>� (vlax-vbSingle)

5 ?;<=>� (vlax-vbDouble)

8 ��� (vlax-vbString)

9 @A (vlax-vbObject)

./ SafeArray BCD� E�FG8

Page 290: AutoLisp Reference

290 | AutoLISP ��

11 ��� (vlax-vbBoolean)

12 �� (vlax-vbVariant)

� var �� SafeArray ��������

��

�������� !"#$%�� &

_$ (setq point (vlax-make-safearray vlax-vbDouble ’(0 . 2)))#<safearray...>$ (setq matrix (vlax-make-safearray vlax-vbString ’(1 . 2) ’(1 . 2) ))#<safearray...>

'( vlax-safearray-type )* SafeArrays +�,-.&

_$ (vlax-safearray-type point)5_$ (vlax-safearray-type matrix)8

/�0 vlax-make-safearray 1��

vlax-safearray->list

(vlax-safearray->list var)

��

var �� SafeArray +�2�

���

3�

��

�������� &

_$ (setq point (vlax-make-safearray vlax-vbDouble ’(0 . 2)))#<safearray...>

'( vlax-safearray-put-element 45� &

63+78�� SafeArray 9+:;

Page 291: AutoLisp Reference

vlax-tmatrix | 291

_$ (vlax-safearray-put-element point 0 100)100_$ (vlax-safearray-put-element point 1 100)100_$ (vlax-safearray-put-element point 2 0)0

��������

_$ (setq pointlist (vlax-safearray->list point))(100.0 100.0 0.0)

�� �� vlax-safearray->list ������������

_$ (vlax-safearray->list matrix)(("a" "b") ("c" "d"))

��� vlax-make-safearray�vlax-safearray-fill � vlax-safearray-put-element ���

vlax-tmatrix

(vlax-tmatrix list)

��

list ��� ��!"#$%&�'( 4 %�)!*+����,-�.%/0�

12)

34� SafeArray �56!�� 4x4 ��,-�

78��,-9�"):7�5; tmatrix�

_$ (setq tmatrix (vlax-tmatrix ’((1 1 1 0) (1 2 3 0) (2 3 4 5) (2 9 8 3))))#<variant 8197 ...>

<= vlax-safearray->list >��?@AB tmatrix �)�

_$ (vlax-safearray->list (vlax-variant-value tmatrix))((1.0 1.0 1.0 0.0) (1.0 2.0 3.0 0.0) (2.0 3.0 4.0 5.0) (2.0 9.0 8.0 3.0))

12 VLA CDE=� 4x4��,-�FG��

Page 292: AutoLisp Reference

292 | AutoLISP ��

�������� ������������ 90 ��

(defun Example_TransformBy () ; / lineObj startPt endPt matList transMat)

(vl-load-com) ; �� ActiveX ��(setq acadObject (vlax-get-acad-object))(setq acadDocument (vla-get-ActiveDocument acadObject))(setq mSpace (vla-get-ModelSpace acadDocument))

;; ��

(setq startPt (getpoint "Pick the start point")) (setq endPt (vlax-3d-point (getpoint startPt "Pick the end point"))) (setq lineObj (vla-addline mSpace (vlax-3d-point startPt) endPt))

;;; ������ ! transMat "#;;; $���%&'( (0,0,0) �� 90 �);;; *�+, 4 -./�0/��12-./;;; +, 4 -34��/�����56

(setq matList (list ’(0 -1 0 0) ’(1 0 0 0) ’(0 0 1 0) ’(0 0 0 1)))

;;; �� vlax-tmatrix �/��7"8)

(setq transmat (vlax-tmatrix matlist)) ;;; �9:��������

(vla-transformby lineObj transMat) (vla-zoomall acadObject)

(princ "The line is transformed ") (princ))

vlax-typeinfo-available-p

Visual LISP ;<� TypeLib =>?@9ABCDEFGH�IJ-%&)KL%&HMNK TypeLib =>OPQ AcadDocumentR)

(vlax-typeinfo-available-p obj)

�3

obj VLA %&)

@9ST9UV�%&1FGWS TypeLib =>

Page 293: AutoLisp Reference

vlax-variant-change-type | 293

���

�� TypeLib ����� T���� nil

��� vlax-import-type-library ��

vlax-variant-change-type

(vlax-variant-change-type var type)

vlax-variant-change-type �����������������������

��

var ��� �!��

type " var ��#var ��$�%������� type ���&'()�*+,-.

vlax-vbEmpty (0) /012

vlax-vbNull (1) $3456��

vlax-vbInteger (2) 7��

vlax-vbLong (3) 87��

vlax-vbSingle (4) 9:;<=�

vlax-vbDouble (5) >:;<=�

vlax-vbString (8) ?@A

vlax-vbObject (9) BC

vlax-vbBoolean (11) DE�

vlax-vbArray (8192) �F

GHI�7�,-)��� ���JKL��)��M$

N��7�� O!PQ����R� AutoCAD J�S5T�2

������������������

Page 294: AutoLisp Reference

294 | AutoLISP ��

���

var ����� ���������� var ��� ����� nil�

��

��� varint ����������

_$ (setq varint (vlax-make-variant 5))#<variant 3 5>

��� varintstr ������ varint !"���#�$����%&'�

_$ (setq varintStr (vlax-variant-change-type varint vlax-vbstring))#<variant 8 5>

() varintstr ���

_$ (vlax-variant-value varintStr)"5"

*+, varintstr -.!"%&'�

/�0 vlax-variant-type 1 vlax-variant-value 23�

vlax-variant-type

(vlax-variant-type var)

�3

var ���4�����

���

�� var !"������567389�

0 :;<= (vlax-vbEmpty)

1 �!">?3@ (vlax-vbNull)

2 73� (vlax-vbInteger)

3 A73� (vlax-vbLong)

4 BCDEF3 (vlax-vbSingle)

5 GCDEF3 (vlax-vbDouble)

-���3@ �

Page 295: AutoLisp Reference

vlax-variant-type | 295

8 ��� (vlax-vbString)

9 �� (vlax-vbObject)

11 ��� (vlax-vbBoolean)

8192 + n �� �� SafeArray (vlax-vbArray)�������� (vlax-vbDouble) �� 8197 (8192 + 5).

�� var ��������� !"#�

$%

&��'( nil�)*+,����� �-

_$ (setq varnil (vlax-make-variant nil))#<variant 0 >_$ (vlax-variant-type varnil)0

&��'(.��/&��+012(.�-

_$ (setq varint (vlax-make-variant 5 vlax-vbInteger))#<variant 2 5>_$ (vlax-variant-type varint)2

&��'(.��)*+,����� �-

_$ (setq varint (vlax-make-variant 5))#<variant 3 5>_$ (vlax-variant-type varint)3

345��6 vlax-make-variant 789+012�� �:;1.���� �&<12(=.��

&��'(����)*+,����� �-

_$ (setq varstr (vlax-make-variant "ghost"))#<variant 8 ghost>_$ (vlax-variant-type varstr)8

>?���� SafeArray�& SafeArray ;1(���)*+,����� �-

_$ (setq 4dubs (vlax-make-safearray vlax-vbDouble ’(0 . 3)))#<safearray...>_$ (setq var4dubs (vlax-make-variant 4dubs))#<variant 8197 ...>_$ (vlax-variant-type var4dubs)8197

Page 296: AutoLisp Reference

296 | AutoLISP ��

������ 8192���� ������� SafeArray������� �� 8192 ���� SafeArray ������� ! 8197-8192=5 (vlax-

vbDouble)�

"�#��$%&�'()* vlax-variant-type +,����-

$ (setq notvar 6.0)6.0_$ (vlax-variant-type notvar); *** ./-����./- variantp 6.0

01! ��./234%567 vlax-variant-type ��#8�����

9�: vlax-make-safearray;vlax-make-variant;vlax-variant-change-type < vlax-variant-value =��

vlax-variant-value

(vlax-variant-value var)

��

var �#>���������%���

���

�#���?@�#8����ABC./�

1!

_$ (vlax-variant-value varstr)"ghost"

_$ (vlax-variant-value varint)5

_$ (vlax-variant-value notvar); *** ./-����./-variantp 6.0

D(EF1!GH./23I4% notvar 8�����

9�: vlax-make-safearray < vlax-make-variant =��

������

Page 297: AutoLisp Reference

vlax-vla-object->ename | 297

vlax-vla-object->ename

(vlax-vla-object->ename obj)

��

obj VLA ���

���

AutoLISP ��ename � ����

��

_$ (vlax-vla-object->ename vlaobj)<�� 27e0540>

��� vlax-ename->vla-object ���

vlax-write-enabled-p

(vlax-write-enabled-p obj)

��

obj VLA ��� AutoLISP �� (ename)�

���

������ AutoCAD ���� T ����!"#�� ��� nil�

vlisp-compile

(vlisp-compile ’mode filename [out-filename])

$% &'() Visual LISP IDE �*+ vlisp-compile ",-./�

0 VLA ��123 AutoLISP ���

4567"8�� AutoCAD �

0 AutoLISP 9:;<=3 FAS >?

Page 298: AutoLisp Reference

298 | AutoLISP ��

��

mode ������� �����

st ������

lsm ��������

lsa �������

filename ���� AutoLISP !"#$%&!"#'( AutoCAD )*"#+,-./0123"#45678-.$%

&789:40;3<� .lsp$

out-filename ���� ��=>?@"#$%&AB23?@"#

vlisp-compile C3?@"#DE"FG4�F9:4HI� .fas$

JKL%&23M?@"#4�AB23 I/O "#>-.0 vlisp-compile F?@"#N( AutoCAD OPQR�$

STU

%&��VW0ST TX0ST nil$

YZ

;3 yinyang.lsp '( AutoCAD )*"#+,-./0�[>\]��^_`�

_$ (vlisp-compile ’st "yinyang.lsp")T

?@"#4� yinyang.fasD!"#'(G�QR$

�[>\]�� yinyang.lsp aF?@"#\4� GoodKarma.fas�

(vlisp-compile ’st "yinyang.lsp" "GoodKarma.fas")

JKLb�\]/>?@"#'( AutoCAD OPQR/��� yinyang.lsp c1>QR$�[>\]�� yinyang.lsp aF?@"#N( c:\my documents QR�

(vlisp-compile ’st "yinyang.lsp" "c:/my documents/GoodKarma")

Page 299: AutoLisp Reference

vlr-acdb-reactor | 299

���������� ������

(vlisp-compile ‘st "c:/program files/acad2000/Sample/yinyang.lsp")

��� �� yinyang.fas����� ������

!"# Visual LISP ��������$%&� '()*+

vlr-acdb-reactor

vlr-acdb-reactor ,-./-0123456

(vlr-acdb-reactor data callbacks)

"-

data 789�23456:;<� AutoLISP -0 =>?@-0A� nil

callbacks B�C�DEFGHI�J5�

(event-name . callback_function)

KLM�event-name NFB$-01234O +��PQR��callback_function �PQ�SBO TUV9WX�,- Y�ZW,-[\]=F^�"-�

reactor_object WXZW,-� VLR 56

obj �O :;<�-0156_AutoLISP `ab

./ AutoCAD -0123456�Kc`d-01�e�fghijk56V%l3X)*

-01234O

�m O

:vlr-objectAppended 56nopeq`d-01�

Page 300: AutoLisp Reference

300 | AutoLISP ��

vlr-add

(vlr-add obj)

��

obj VLR ������� ���

���

obj ���

��� vlr-added-p � vlr-remove ���

vlr-added-p

(vlr-added-p obj)

��

obj VLR �������� ���

:vlr-objectUnAppended ��������� !"#�$%� UNDO�

:vlr-objectReAppended &"#��'���� !��&()�$%� REDO�

:vlr-objectOpenedForModify ��*&+,�

:vlr-objectModified ���&+,�

:vlr-objectErased ���&-./0'12�

:vlr-objectUnErased ���12-.�&32�

4567�� ����

�� ��89 ( �� )

:; 89

��<=>?@�� ����

Page 301: AutoLisp Reference

vlr-beep-reaction | 301

���

������� ����� T����� ������� nil�

��� vlr-add ���

vlr-beep-reaction

(vlr-beep-reaction [args])

��

��������������� � !"�#$%&��' ���()�

*+,-./����)0�1�

vlr-command-reactor

(vlr-command-reactor data callbacks)

��

data 2345� �6789: AutoLISP �����;<���� nil�

callbacks =�>?@ABCDE F6G

(event-name . callback_function)

HIJ�event-name KB=LMN� �*+O? PQRS�callback_function �PQ�T=*+UVW4� ���XY����Z$%�B[Y��G

reactor_object ����� VLR 67

list @A\Y]^ =�_P`=aMNb

cVdefa ����

gh AutoCAD MN� ��6MN*+ijkl

Page 302: AutoLisp Reference

302 | AutoLISP ��

���

reactor_object ���

vlr-current-reaction-name

(vlr-current-reaction-name)

���

��� ��������

vlr-data

(vlr-data obj)

��

obj VLR ������������������

���

����������� !"#$���

%&�����

��' ��

:vlr-unknownCommand �() AutoCAD *+�%&�

:vlr-commandWillStart ,- . AutoCAD %&�

:vlr-commandEnded ,/0. AutoCAD %&�

:vlr-commandCancelled ,�1. AutoCAD %&�

:vlr-commandFailed 23/0. AutoCAD %&�

456����-7��- 87�9��:;���'<=�>

��?���@A�� !"#$��

Page 303: AutoLisp Reference

vlr-data-set | 303

��

�������� circleReactor VLR ��� ���

$ (vlr-data circleReactor)"Circle Reactor"

vlr-data-set

(vlr-data-set obj data)

��

obj VLR �������������

data �� AutoLISP ���

!"

data ���

��

!#$%�����&'()*��"�

$ (vlr-data circleReactor)"Circle Reactor"

+,&-./����0 ���

$ (vlr-data-set circleReactor "Circle Area Reactor")"Circle Area Reactor"

1234�

$ (vlr-data circleReactor)"Circle Area Reactor"

5� �678& vlr-data-set 9��:;<=>?@<�

����������&'()*��

Page 304: AutoLisp Reference

304 | AutoLISP ��

vlr-deepclone-reactor

(vlr-deepclone-reactor data callbacks)

��

data ������� ��� AutoLISP ����������� nil�

callbacks ������� !"�#�$

(event-name . callback_function)

%&'�event-name (��)DeepClone �*+,��-./0�callback_function �-.�1�*+234�56�7��89:57�;<=��>9��$

reactor_object 56:57�� VLR ��

list �?@*+ ����A��BC�D�E�?@*+�FGH�)DeepClone �:5��,�

I:J

reactor_object ���

KLMN����%23 deepclone *+4OPQR

DeepClone �*+

*+S TU

:vlr-beginDeepClone VW deepclone XY�

:vlr-beginDeepCloneXlation deepclone XYZ�>9[\�]^�_`89��abc���d���ef�g�� ID �hij�kl ID�D:57�23%>9[\/m�

:vlr-abortDeepClone �n deepclone XY�

:vlr-endDeepClone op deepclone XY�

Page 305: AutoLisp Reference

vlr-docmanager-reactor | 305

vlr-docmanager-reactor

(vlr-docmanager-reactor data callbacks)

��

data �������� �� AutoLISP ����������� nil�

callbacks �������� !�"#

(event-name . callback_function)

$%&�event-name '��(DocManager ��)*+��,-./�callback_function �,-�0�)*123�45�6��78946�:;<��=8��#

reactor_object 45946�� VLR �

list �>?)*� ���@��AB�C�D>?)*�EFG�(DocManager ��94��+�

DeepClone ��94��

HI �JK ��

:vlr-beginDeepClone:vlr-abortDeepClone:vlr-endDeepClone

0

:vlr-beginDeepCloneXlation 1 L�M���N9�OPQR���CSTU12VOP���W deepclone XY�

Z[����\]�^_`a� �)*

Page 306: AutoLisp Reference

306 | AutoLISP ��

���

reactor_object ���

DocManager ���

�� � ��

:vlr-documentCreated ��������������������� !"#$�

:vlr-documentToBeDestroyed ��%&'(�

:vlr-documentLockModeWillChange )*+%�,� -.��/01�2345�67�89��:;�

:vlr-documentLockModeChangeVetoed �<=> :vlr-documentLockModeChanged �?@�?$AB�

:vlr-documentLockModeChanged ��:;C&67�89�

:vlr-documentBecameCurrent DE��C&23�FGHIJK��LMN�4OP.QRSTUV423DE��LWX��X67$YZ[4W\]M���

:vlr-documentToBeActivated DE�^MN��__7`aMNbc4+%dPDE���

:vlr-documentToBeDeactivated efghi�� AutoCAD jk�lk�C&]M�

Page 307: AutoLisp Reference

vlr-dwg-reactor | 307

vlr-dwg-reactor

(vlr-dwg-reactor data callbacks)

DocManager �������

� �� �

:vlr-documentCreated:vlr-documentToBeDestroyed:vlr-documentBecameCurrent:vlr-documentToBeActivated:vlr-documentToBeDeactivated

1 ���������VLA ����

:vlr-documentLockModeChangeVetoed 2 ��� �����������VLA ������� ����� !"#$%&�'()()*+,-�./���0)1*,-234�5$%&678 # 9:�

:vlr-documentLockModeWillChange:vlr-documentLockModeChanged

5 ��� �����������VLA ������� ��;�5<=9�����>?�*+��@� ��;�5<A�(*+B6C(�*+DE��F� ��GHI>JKLMNO�PQ�*+DE��R� ����� !"#$%&�'()*+,-�./���0)1*,-234�5$%&678 # 9:�*+DESTUVWX�Y1 HZ[*+2 \*+4 ]^[8 _10 `a[

bc�����5defghi�.jklmnfg�i�

Page 308: AutoLisp Reference

308 | AutoLISP ��

��

data ������� ��� AutoLISP ����������� nil�

callbacks ������� !"�#�$

(event-name . callback_function)

%&'�event-name (��)DWG �*+,��-./0�callback_function �-.�1�*+234�56�7��89:57�;<=��>9��$

reactor_object 56:57�� VLR ��

list �?@*+ ����A��BC�D�E�?@*+�FGH�)DWG �:5��,�

I:J

reactor_object ���

DWG �*+

*+KL MN

:vlr-beginClose OP��QRS�T�

:vlr-databaseConstructed UVWXOP��Q�

:vlr-databaseToBeDestroyed RYFZ�[\OP��Q�FG�

vlr-beginDwgOpen AutoCAD R]^OP_+�

:vlr-endDwgOpen AutoCAD U`a]^bc�

:vlr-dwgFileOpened dOPUSefg AutoCAD OPhi�

vlr-beginSave AutoCAD RjZOP_+�

vlr-saveComplete AutoCAD URklOPjZgmn�

Page 309: AutoLisp Reference

vlr-dxf-reactor | 309

vlr-dxf-reactor

(vlr-dxf-reactor data callbacks)

��

data �������� �� AutoLISP ����������� nil�

callbacks �������� !�"#

(event-name . callback_function)

$%&�event-name '��(DXF ��)*+��,-./�callback_function �,-�0�)*123�45�6��78946�:;<��=8��#

reactor_object 45946�� VLR �

list �>?)*� ���@��AB�C�D>?)*�EFG�(DXF ��94��+�

DWG ��94��

HI �JK ��

:vlr-beginClose, :vlr-databaseConstructed, :vlr-databaseToBeDestroyed

0

:vlr-beginDwgOpen, :vlr-endDwgOpen,:vlr-dwgFileOpened

1 L,M��N�OP�Q*�

:vlr-beginSave 1 L,M������RSQ*�TUQ*H�C��VWXY5Z[\�

:vlr-saveComplete 1 L,M�����5]RS�^_�Q*H�

`abc����de�fg DXF Q*� �)*

Page 310: AutoLisp Reference

310 | AutoLISP ��

���

reactor_object ���

vlr-editor-reactor

(vlr-editor-reactor data callbacks)

��

data ��� ������� AutoLISP ����������� nil�

DXF � ���

���� !

:vlr-beginDxfIn DXF "��#$%&'()*+��,�

:vlr-abortDxfIn DXF -./01�

:vlr-dxfInComplete DXF -.01�

:vlr-beginDxfOut AutoCAD %2*+��,-3) DXF "��

:vlr-abortDxfOut DXF -34567�

:vlr-dxfOutComplete DXF -34501�

DXF � ��8��

�� 9:; ��

:vlr-beginDxfIn,:vlr-abortDxfIn,:vlr-dxfInComplete,:vlr-beginDxfOut, :vlr-abortDxfOut, :vlr-dxfOutComplete

0

<=>?�� ���

Page 311: AutoLisp Reference

vlr-editor-reactor | 311

callbacks ���������� �

(event-name . callback_function)

����event-name ��������������������callback_function ���!���"#$%&'�()*+,-&()./01�2,3)�

reactor_object &'-&()� VLR 4

list 567��89:��;)<=>*?�@ 67���ABC�D 312E��������-&)<�*

F-G

reactor_object 3)*

��������

��HI JK

:vlr-beginClose LM)<NOP9Q*

:vlr-beginDxfIn DXF R��ABPSTUVLM)<N*

:vlr-abortDxfIn DXF WXYZ[*

:vlr-dxfInComplete DXF WXZ[*

:vlr-beginDxfOut AutoCAD P%\LM)<NW]V DXF R�*

:vlr-abortDxfOut DXF W]^_`a*

:vlr-dxfOutComplete DXF W]^_Z[*

:vlr-databaseToBeDestroyed PbAc�deLM)<N�AB*

:vlr-unknownCommand "] AutoCAD Yfgh*

:vlr-commandWillStart i&' AutoCAD gh*

:vlr-commandEnded ijZ AutoCAD gh*

Page 312: AutoLisp Reference

312 | AutoLISP ��

:vlr-commandCancelled ��� AutoCAD ���

:vlr-commandFailed �� AutoCAD ���

:vlr-lispWillStart �� AutoLISP ��������

:vlr-lispEnded ���� AutoLISP �������

:vlr-lispCancelled ���� AutoLISP �������

:vlr-beginDwgOpen AutoCAD � �������

:vlr-endDwgOpen AutoCAD �� ��!"�

:vlr-dwgFileOpened #���$%&' AutoCAD ��()�

:vlr-beginSave AutoCAD � *+�����

:vlr-saveComplete AutoCAD � ,-��*+'./�

:vlr-sysVarWillChange AutoCAD � 012345���

:vlr-sysVarChanged �012345���

6789:8;<=>

?@ �AB �=

:vlr-lispEnded, :vlr-lispCancelled, :vlr-beginClose, :vlr-beginDxfIn,:vlr-abortDxfIn,:vlr-dxfInComplete,:vlr-beginDxfOut, :vlr-abortDxfOut, :vlr-dxfOutComplete,:vlr-databaseToBeDestroyed

0

6789:8C� ( �� )

C�?@ DE

Page 313: AutoLisp Reference

vlr-insert-reactor | 313

vlr-insert-reactor

(vlr-insert-reactor data callbacks)

��

data �������� �� AutoLISP ����������� nil�

callbacks �������� !�"#

(event-name . callback_function)

$%&�event-name '��(Insert ��)*+��,-./�callback_function �,-�0�)*123�45�6��78946�:;<��=8��#

:vlr-unknownCommand:vlr-commandWillStart:vlr-commandEnded :vlr-commandCancelled :vlr-commandFailed

1 ��>?@�A,B�

:vlr-lispWillStart 1 A,B������CD� AutoLISP �E!�F/G�

:vlr-beginDwgOpen, :vlr-endDwgOpen, :vlr-dwgFileOpened

1 A,B��H�IJ�K*�

:vlr-beginSave 1 A,B������LMK*�NOK*@�P��QRST5UVW�

:vlr-saveComplete 1 A,B�����LMXYZ5�[\K*@�

:vlr-sysVarWillChange 1 �H]^_`�A,B�

:vlr-sysVarChanged 2 F/8��'�H]^_`�A,B�

Fa8���b�c��HVW'defg1 = ef�0 = hij�

kl����mn�opq� �)*

rs��94�� ( �� )

@t �uv ��

Page 314: AutoLisp Reference

314 | AutoLISP ��

reactor_object ������� VLR

list �� ����������������� ��������Insert !"����#�

$�%

reactor_object ���

Insert !"��

��&' ()

:vlr-beginInsert *+,-./01��2�

:vlr-beginInsertM 345678+,-./01��2�

:vlr-otherInsert *978:-;<=01��2�>./?@A,BC=��2DEFID 5690�56GHDIFGJ�KL�

:vlr-endInsert MN�O>01��2P�./QR:STU�VWF>XYZ[\F56]^GHF9_`�*]^a<�bcdeBC�fghi01F>j= :vlr-commandEnded KLDIFgk>lmnAo�pq�

:vlr-abortInsert ./QR-ArF��2sigt uv�

Page 315: AutoLisp Reference

vlr-linker-reactor | 315

vlr-linker-reactor

(vlr-linker-reactor data callbacks)

��

data �������� �� AutoLISP ���

callbacks �������������

(event-name . callback_function)

�� �event-name !�"Linker ��#$%��&'()�callback_function *&'�+�#$,-.�/0�1��234/1�5678�93���

Insert ��4/��

:; �<= ��

:vlr-beginInsert 3 >)3��! VLA ��?@�ABC���D�>E3��!F&G��H�AB�C�

>I3��! VLA ���HC�J��D�

:vlr-beginInsertM 3 >)3��! VLA ��?@�ABIKLMNO���D�

>E3��!F&G��H�AB�IKLMNO�

>I3��! VLA ���HNO�J��D�

:vlr-otherInsert 2 >)3��! VLA ��?@�ABCPIKLMNO���D�

>E3��! VLA ���HCPNO�J��D�

:vlr-endInsert:vlr-abortInsert

1 ?@QR��D� VLA ��

ST�����2U�0VWXYPZY ObjectARX �0VW.[\�0VW

Page 316: AutoLisp Reference

316 | AutoLISP ��

reactor_object ������� VLR

list �� ��������� ObjectARX �����������

��

reactor_object ���

!"

_$ (vlr-linker-reactor nil ’((:vlr-rxAppLoaded . my-vlr-trace-reaction)))#<VLR-Linker-Reactor>

vlr-lisp-reactor

(vlr-lisp-reactor data callbacks)

��

data #$%&'()*+,� AutoLISP �-�./01�-23 nil�

callbacks �� ���4567�89

(event-name . callback_function)

:;<�event-name =4�>Lisp '()?@A���BCD�callback_function 3�B�E�?@FGH%������IJ����KLM.4NJ��9

Linker '()?@

�� ?@

:vlr-rxAppLoaded OPQL)RS��TU� ObjectARX ���V��RWXYZ[�

:vlr-rxAppUnLoaded OPQL)RS��T ObjectARX ���V��R\]�

^_`a)'()�bc LISP ?@

Page 317: AutoLisp Reference

vlr-miscellaneous-reactor | 317

reactor_object ������� VLR ��

list �� ����������������� ������Lisp �� ����!�

"�#

reactor_object $��

vlr-miscellaneous-reactor

(vlr-miscellaneous-reactor data callbacks)

Lisp �� �

� %& '(

:vlr-lispWillStart )*� AutoLISP �+,-./#�

:vlr-lispEnded 012� AutoLISP �+,�/#�

:vlr-lispCancelled 034� AutoLISP �+,�/#�

Lisp �� ����

%& �56 $�

:vlr-lispEnded, :vlr-lispCancelled

0

:vlr-lispWillStart 1 789:;<=/#� AutoLISP �+,�>?.�

@ABC �� ��:DEFGHI��BC �� JK

Page 318: AutoLisp Reference

318 | AutoLISP ��

��

data ������� ��� AutoLISP ����������� nil�

callbacks ������� !"�#�$

(event-name . callback_function)

%&'�event-name (��)Miscellaneous �*+,��-./0�callback_function �-.�1�*+234�56�7��89:57�;<=��>9��$

reactor_object 56:57�� VLR ��

list �?@*+ ����A��BC�D�E�?@*+�FGH�)Miscellaneous �:5��,�

I:J

reactor_object ���

Miscellaneous �*+

*+KL MN

:vlr-pickfirstModified OPQR�STUVWXYZ[�

:vlr-layoutSwitched \]XY^_�

Miscellaneous �:5��

KL �`a ��

:vlr-pickfirstModified 0

:vlr-layoutSwitched 1 b-c��d^_e�\]�

Page 319: AutoLisp Reference

vlr-mouse-reactor | 319

vlr-mouse-reactor

(vlr-mouse-reactor data callbacks)

��

data �������� �� AutoLISP ����������� nil�

callbacks �������� !�"#

(event-name . callback_function)

$%&�event-name '��(Mouse ��)*+��,-./�callback_function �,-�0�)*123�45�6��78946�:;<��=8��#

reactor_object 45946�� VLR �

list �>?)*� ���@��AB�C�D>?)*�EFG�(Mouse ��94��+�

H9I

reactor_object ���

JKLM����NOPQ)*R�STU

Mouse ��)*

)*VW XY

:vlr-beginDoubleClick 5Z[\ST�

:vlr-beginRightClick 5Z]T^_�

Page 320: AutoLisp Reference

320 | AutoLISP ��

vlr-notification

(vlr-notification reactor)

��

reactor VLR ���

��

�� � all-documents ����������������� �!"#$%

&'() active-document-only �*+������������ ,�-"#$%&'(�

vlr-object-reactor

%&'��./01234�56�789�:;%&'�

(vlr-object-reactor owners data callbacks)

��

owners VLA ��� AutoLISP <�=>?@A�34���

data BC?D%&'����� AutoLISP �5�EFG+�5H� nil�

Mouse %&'�I�5

�� <JK ��

:vlr-beginDoubleClick :vlr-beginRightClick

1 LMN<�OLPQ�RS�<(�TUNV,W=X�N�Y=�ZWCS [(

\]^%&'_�������9Z��� ,��#$%&'

`a��%&'��

Page 321: AutoLisp Reference

vlr-object-reactor | 321

callbacks ���������� �

(event-name . callback_function)

����event-name ��� 321���Object ����������callback_function ��������� !"#$�%&'()*#%&+,-.�/)0&�

owner 1$��� VLA 2�345

reactor_object #$*#%&� VLR 2

list 678��9:;��<&=>?'@�A 78���BCD�� 322���Object ��*#&=�'

E*F

reactor_object 0&'

Object ��

GH ��

:vlr-cancelled 2�IJKLMN'

:vlr-copied 2KOPQ'

:vlr-erased 2�RSTUKOVW'

:vlr-unerased 2�RSTUKOXW'

:vlr-goodbye YZ[B\�RS 2'

:vlr-openedForModify YZIJ 2'

:vlr-modified 2KOIJ'.]MNIJ�^Z_� :vlr-cancelled and :vlr-modifyUndone'

:vlr-subObjModified 2�`a>KOIJ'�IJbcdefg�!h�@���i0jk4�lmnoh�@��'

:vlr-modifyUndone 2�IJKOpq'

Page 322: AutoLisp Reference

322 | AutoLISP ��

��

������ ����� myCircle ������ ������������� (:vlr-modified)� !" print-radius #$���%&'( �)

(setq circleReactor (vlr-object-reactor (list myCircle) "Circle Reactor" ’((:vlr-modified . print-radius))))

:vlr-modifiedXData ���*+,-$.�����

:vlr-unappended �/,0$.1234���

:vlr-reappended ����56���,0$.1�

:vlr-objectClosed �������789�

Object %&:!$.

;< =>? �$

:vlr-cancelled :vlr-erased, :vlr-unerased :vlr-goodbye:vlr-openedForModify :vlr-modified :vlr-modifyUndone :vlr-modifiedXData :vlr-unappended :vlr-reappended :vlr-objectClosed

0

:vlr-copied 1 @ABCDEF��� (ename)�

:vlr-subObjModified 1 �����G�� (ename)�

Object %& ( �� )

;< %&

Page 323: AutoLisp Reference

vlr-owner-add | 323

vlr-owner-add

(vlr-owner-add reactor owner)

���������� ��������������

��

reactor VLR ���

owner ������������ VLA ���

!"

#��$�� VLA ���

%&

'(&�)*+ archie �,-��.���� circleReactor �������/

_$ (vlr-owner-add circleReactor archie)#<VLA-OBJECT IAcadArc 03ad0bcc>

0�1 vlr-owner-remove ���

vlr-owner-remove

(vlr-owner-remove reactor owner)

��

reactor VLR ���

owner ���������23� VLA ���

!"

23�4� VLA ���

���������������

�����������23��

Page 324: AutoLisp Reference

324 | AutoLISP ��

��

_$ (vlr-owner-remove circleReactor archie)#<VLA-OBJECT IAcadArc 03ad0bcc>

��� vlr-owner-add ��

vlr-owners

(vlr-owners reactor)

��

reactor VLR �

� �

����������������������� �!

��

_$ (vlr-owners circleReactor)(#<VLA-OBJECT IAcadCircle 01db98f4> #<VLA-OBJECT IAcadCircle 01db9724> #<VLA-OBJECT IAcadCircle 01db93d4> #<VLA-OBJECT IAcadCircle 01db9084>)

vlr-pers

(vlr-pers reactor)

��

reactor VLR �

� �

"# $%� �������&'%� nil

��

�(���)

� ��������*!

+��� ,-.���

Page 325: AutoLisp Reference

vlr-pers-list | 325

_$ (setq circleReactor (vlr-object-reactor (list myCircle) "Radius size" ’((:vlr-modified . print-radius))))#<VLR-Object-Reactor>

�����������

_$ (vlr-pers circleReactor)#<VLR-Object-Reactor>

vlr-pers-list

(vlr-pers-list [reactor])

reactor-type � ������������� reactor�vlr-pers-list ���������

���

��������� �

!"

_$ (vlr-pers-list)(#<VLR-Object-Reactor> #<VLR-Object-Reactor> (#<VLR-Object-Reactor>)

vlr-pers-p

(vlr-pers-p reactor)

reactor VLR ���

���

�������#������$����������������#%&����$�� nil�

!"

�����������

���'()*+,-��������

.����#/#�����

Page 326: AutoLisp Reference

326 | AutoLISP ��

_$ (vlr-pers circleReactor)#<VLR-Object-Reactor>

������������

_$ (vlr-pers-p circleReactor)#<VLR-Object-Reactor>

�������������

_$ (vlr-pers-release circleReactor)#<VLR-Object-Reactor>

��������������

_$ (vlr-pers-p circleReactor)nil

vlr-pers-release

(vlr-pers-release reactor)

��

reactor VLR ���

���

���� �������! �� nil�

vlr-reaction-names

(vlr-reaction-names reactor-type)

��

reactor-type "#$%&'�

:VLR-AcDb-Reactor:VLR-Command-Reactor:VLR-DeepClone-Reactor:VLR-DocManager-Reactor:VLR-DWG-Reactor:VLR-DXF-Reactor

(����������

��)*+,���-./0�1234�56

Page 327: AutoLisp Reference

vlr-reaction-set | 327

: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-reaction-names :VLR-Editor-Reactor)(:vlr-unknownCommand :vlr-commandWillStart :vlr-commandEnded....

vlr-reaction-set

(vlr-reaction-set reactor event function)

��

reactor VLR ���

event �������� �������� �

function �����!"#$%&� AutoLISP '��

���

()�

��

*+�,-. circleReactor reactor /01��23� print-area '�4

_$ (vlr-reaction-set circleReactor :vlr-modified ’print-area)PRINT-AREA

"#$%&�� 5� 6�3'�

Page 328: AutoLisp Reference

328 | AutoLISP ��

vlr-reactions

(vlr-reactions reactor)

��

reactor VLR ���

��

_$ (vlr-reactions circleReactor)((:vlr-modified . PRINT-RADIUS))

vlr-reactors

(vlr-reactors [reactor-type...])

��

reactor-type ���� �����

: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

�������� (event-name . callback_function) ����

������������

Page 329: AutoLisp Reference

vlr-remove | 329

����� reactor-type ���vlr-reactors ���� ������������ reactor-type�vlr-reactors ���������

���������������������� �� nil� !����

�"#$%&'!�(���� �)*�+,&�- !.� �����

/�

01

23456������7

_$ (vlr-reactors)((:VLR-Object-Reactor #<VLR-Object-Reactor>) (:VLR-Editor-Reactor #<VLR-Editor-Reactor>))

23���89���7

_$ (vlr-reactors :vlr-object-reactor)((:VLR-Object-Reactor #<VLR-Object-Reactor>))

vlr-reactors '!����������

23���:;���7

_$ (vlr-reactors :vlr-acdb-reactor)nil

���<�:;����

23�� DWG ���7

_$ (vlr-reactors :vlr-dwg-reactor)((:VLR-DWG-Reactor #<VLR-DWG-Reactor> #<VLR-DWG-Reactor>))

vlr-reactors � DWG ���������

vlr-remove

(vlr-remove reactor)

��

reactor VLR 89�

reactor �����=�>� nil�

?@���

Page 330: AutoLisp Reference

330 | AutoLISP ��

��

����� circleReactor � ��

_$ (vlr-remove circleReactor)#<VLR-Object-reactor>

��� vlr-remove-all ���

vlr-remove-all

(vlr-remove-all [reactor-type])

��

reactor-type �������

: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

����� reactor-type�vlr-remove-all � !� ��

���"#� !� �

Page 331: AutoLisp Reference

vlr-set-notification | 331

���

���������� ����������������������

������� !"#�����$%&�� nil

'(

)*�%&+�,��-!./����0

_$ (vlr-remove-all :vlr-editor-reactor)((:VLR-Editor-Reactor #<VLR-Editor-Reactor>))

)*�+�%&,��-!���0

$ (vlr-remove-all)((:VLR-Object-Reactor #<VLR-Object-Reactor> #<VLR-Object-Reactor>#<VLR-Object-Reactor>) (:VLR-Editor-Reactor #<VLR-Editor-Reactor>))

123 vlr-remove %&

vlr-set-notification

(vlr-set-notification reactor ’range)

2&

reactor VLR ��

’range range 2&456 all-documents 789���:;<"#=>?@A�BCD�+%&E�FG active-document-only 7HI���<"#=>?@JCD�+%&E

���

VLR ��

'(

KL����MNOMPQRSTUVW"#XYJ�ZCD[�+%&0

_$ (vlr-set-notification circleReactor ’all-documents)#<VLR-Object-Reactor>

\]I?@A�QRST^P"#XYJ:;CD����+%&

Page 332: AutoLisp Reference

332 | AutoLISP ��

vlr-sysvar-reactor

(vlr-sysvar-reactor data callbacks)

��

data ������� �� AutoLISP ����������� nil�

callbacks �������� !�"�#

(event-name . callback_function)

$%�event-name &�'SysVar �()*��+,-.�callback_function �+,�/�()012�34�5��67835�9:;��<7��#

reactor_object 34835�� VLR ��

list �=>()? ���@��AB�C�D�=>()�EFG�'SysVar �83��*�

H8I

reactor_object ���

JKLM����NOPQRST2UV4WX

SysVar �()

()YZ [\

:vlr-sysVarWillChange AutoCAD ]^OP_QRST�I�

:vlr-sysVarChanged QRST�I`aOP�

Page 333: AutoLisp Reference

vlr-toolbar-reactor | 333

vlr-toolbar-reactor

(vlr-toolbar-reactor data callbacks)

��

data �������� � AutoLISP ����������� nil�

callbacks ��������� �!"

(event-name . callback_function)

#$�event-name %�&Toolbar ��'()��*+,-�callback_function �*+�.�'(/01�23�4��56724�89:��;6��"

reactor_object 23724�� VLR �

list �<='(>� ��?��@A�B�C<='(�DEF�&Toolbar ��72��)�

SysVar ��72��

GH �IJ ��

:vlr-sysVarWillChange 1 �KLMNOGH�P*Q�

:vlr-sysVarChanged 2 R-6���P*Q��KLMNO�GH�

RS6���*+��KTU%VWX�(T=WX�nil=YZ[�

\]^_����`abc��deUN1fg�3hi

Page 334: AutoLisp Reference

334 | AutoLISP ��

���

reactor_object ���

vlr-trace-reaction

(vlr-trace-reaction)

���� �����������������

��

!"#���$%& vlr-trace-reaction ' ���(

_$ (VLR-Reaction-Set (VLR-Command-Reactor) :VLR-commandWillStart ’VLR-trace-reaction)VLR-trace-reaction

) AutoCAD "#*+,-./"#(

_.LINE

Toolbar ���01

0123 45

:vlr-toolbarBitmapSizeWillChange AutoCAD ��6789:;<&=>�

:vlr-toolbarBitmapSizeChanged AutoCAD ��6789:;�?=>�

Toolbar ������@

23 ABC ��

:vlr-toolbarBitmapSizeWillChange:vlr-toolbarBitmapSizeChanged

1 DE��6FG :78$H T�DE��6FG ;78$H nil�

I !���$)JKLMNOPQRSTUS����

Page 335: AutoLisp Reference

vlr-type | 335

���������� VLISP �������� ������� �������

; "Reaction": :VLR-commandWillStart; "argument list": (#<VLR-COMMAND-REACTOR> ("LINE"))

vlr-trace-reaction ��� !"#$�%�&'()*$�%()+"#$�%����

vlr-type

(vlr-type reactor)

,-

reactor VLR ./�

012

!�$�%()�34�5!6�7 vlr-type �801�()�

01 !$�%()�34

$�%()

$�%() 9:

:VLR-AcDb-Reactor -;<$�%�

:VLR-Command-Reactor =>��&'�?@%$�%�

:VLR-DeepClone-Reactor => deepclone &'�?@%$�%�

:VLR-DocManager-Reactor ABCD$�%�

:VLR-DWG-Reactor =>EF&'GH��IJKEFL�?@%$�%�

:VLR-DXF-Reactor => DXF A'MNOPQJ&'�?@%$�%�

:VLR-Editor-Reactor RS�?@%$�%�TUVWX�

Page 336: AutoLisp Reference

336 | AutoLISP ��

��

$ (vlr-type circleReactor):VLR-Object-Reactor

vlr-types

(vlr-types)

���

(:VLR-Linker-Reactor :VLR-Editor-Reactor :VLR-AcDb-Reactor ....)

:VLR-Insert-Reactor ��� �����������

:VLR-Linker-Reactor ������

:VLR-Lisp-Reactor � LISP ����������

:VLR-Miscellaneous-Reactor ��������� ��������

:VLR-Mouse-Reactor �!"��#$%&'��������

:VLR-Object-Reactor ()����

:VLR-SysVar-Reactor �*+,-,.��������

:VLR-Toolbar-Reactor �/0123,.��������

:VLR-Undo-Reactor �4567��������

:VLR-Wblock-Reactor �89 ��67��������

:VLR-Window-Reactor �:;<=4 AutoCAD >?����������

:VLR-XREF-Reactor �@AB<CDEF�G ������������

��HIJ���� KL�M

���� ( �� )

���� NO

Page 337: AutoLisp Reference

vlr-undo-reactor | 337

vlr-undo-reactor

(vlr-undo-reactor data callbacks)

��

data �������� � AutoLISP ����������� nil�

callbacks ��������� �!"

(event-name . callback_function)

#$�event-name %�&Undo ��'()��*+,-�callback_function �*+�.�'(/01�23�4��56724�89:��;6��"

reactor_object 23724�� VLR �

list �<='(>� ��?��@A�B�C<='(�DEF�&Undo ��72��)�

G7H

reactor_object ���

IJKLMNOP�QR���

Undo ��'(

'(ST UV

:vlr-undoSubcommandAuto UNDO WX�&YZ)[\]^_`�

:vlr-undoSubcommandControl UNDO WX�&ab)[\]^_`�

:vlr-undoSubcommandBegin UNDO WX�&cd)[\]^_`�&cd)efgh-iMN�-j�WX�cdkl�

:vlr-undoSubcommandEnd UNDO WX�&mn)[\]^_`�&mn)efgh-iMN�-j�WX�mnkl�

Page 338: AutoLisp Reference

338 | AutoLISP ��

:vlr-undoSubcommandMark UNDO �������� ��������������������������� !��"#$%&��'#����()*+,�

:vlr-undoSubcommandBack UNDO �������� ������-.��()*+�/ 0 12��3�����4���56�789)���:��()*+�

:vlr-undoSubcommandNumber &;��<=��>?� UNDO ��%UNDO ���@A*+,�

Undo BCDEF>G

HI JKL �>

:vlr-undoSubcommandAuto 2 M���>5JN�O�P>�!QRS5 4�JN���*+�T4UV�

MW��>5JN�XOYZ[\�]^�78�XOYZ_`�a!Q5 T�ba!Q5 nil�

:vlr-undoSubcommandControl 2 M���>5JN�O�P>�!QRS5 4�JN���*+�T4UV�

MW��>5JN�cd�e�P>�!�>��5�fQg� 0 - e�h� 1 - e���� 2 - e�ij

:vlr-undoSubcommandBegin:vlr-undoSubcommandEnd:vlr-undoSubcommandMark:vlr-undoSubcommandBack

1 Q5 0 �P>�JN���kl*+m.T4UV�

Undo BCDn� ( �� )

n�HI op

Page 339: AutoLisp Reference

vlr-wblock-reactor | 339

vlr-wblock-reactor

(vlr-wblock-reactor data callbacks)

��

data �������� � AutoLISP ����������� nil�

callbacks ��������� �!"

(event-name . callback_function)

#$�event-name %�&Wblock ��'()��*+,-�callback_function �*+�.�'(/01�23�4��56724�89:��;6��"

reactor_object 23724�� VLR �

list �<='(>� ��?��@A�B�C<='(�DEF�&Wblock ��72��)�

:vlr-undoSubcommandNumber 2 G-6����HIJ�K��BLMN� 0��HOPIQRSTU/VWX�

GY6���K���H�Z[�ST�\�

]^_`����O/0�ab>��'(1WX�3cd

Undo ��72�� ( �� )

ef �gh ��

Page 340: AutoLisp Reference

340 | AutoLISP ��

���

reactor_object ���

Wblock ���

�� � ��

:VLR-wblockNotice ���������

:VLR-beginWblockPt ������� !"�����

:VLR-beginWblockId #�$%�� !�����

:VLR-beginWblock #��&�'(� !������&�'()*+,-./0��12345�'(6789:;<=>�

:VLR-otherWblock #��?�'(� !�����������@A12345�'(6B8ID CD��67;<=>�EF8GH:12IJ.@AKLMNOPQ�RS-.@AT8EUNV beginDeepCloneXlation =>WX�

:VLR-abortWblock �����YZ67[-\�

:VLR-endWblock ����Z]YZ�

:VLR-beginWblockObjects ��^^YZ@A ID CD_`a.b�c�

Wblock ��d�'

� aef ��

:VLR-wblockNotice 1 �'(@AKVLA @AT8gh�'(-ij��

Page 341: AutoLisp Reference

vlr-window-reactor | 341

vlr-window-reactor

(vlr-window-reactor data callbacks)

��

data �������� � AutoLISP ����������� nil�

:VLR-beginWblockPt 3 �������������VLA ���� ����!�����VLA ��"#$%&�'()*���

�+����+,-.�WCS�"/0������1-�

:VLR-beginWblockId 3 �������������VLA ���� ����!�����VLA ��"#$%&�'()*���

�+�����(*� BlockTableRecord �� ID�

:VLR-beginWblock:VLR-otherWblock

2 �������������VLA ���� ����!�����VLA ��"#$%&�'()*���

:VLR-abortWblock:VLR-endWblock

1 �������VLA ���

:VLR-beginWblockObjects 2 ������!�����VLZA ��"#$%&�'()*���

� ���� ID 23�

4567���"89:�;<=>? AutoCAD @AB��CDEFG�/HI

Wblock ��JK�� ( �� )

LM .NO ��

Page 342: AutoLisp Reference

342 | AutoLISP ��

callbacks �������� ���

(event-name . callback_function)

���event-name ���Window ������� �����callback_function ���� ���!"#$%& '()*+,%'(-./01+�(�

reactor_object %&,%'( VLR �2

list 345��678 �9(:;<)=�>�45�� ?@A��Window ���,%(:�)

B,C

reactor_object �()

Window �����

��DE FG

:vlr-docFrameMovedOrResized HIJKL MDI MNOPQRNOS)

:vlr-mainFrameMovedOrResized HIJKL AutoCAD TNO)

Window ���,%(:

DE �UV �(

:vlr-docFrameMovedOrResized:vlr-mainFrameMovedOrResized

2 W�+�(���NO HWND X()WY+�(�ZNO�[\]HIJKL)0^NO\]HI�_=�(� T�0^NO\]KL�_=�(� nil)

Page 343: AutoLisp Reference

vlr-xref-reactor | 343

vlr-xref-reactor

(vlr-xref-reactor data callbacks)

��

data �������� � AutoLISP ����������� nil�

callbacks ��������� �!"

(event-name . callback_function)

#$�event-name %�&XREF ��'()��*+,-�callback_function �*+�.�'(/01�23�4��56724�89:��;6��"

reactor_object 23724�� VLR �

list �<='(>� ��?��@A�B�C<='(�DEF�&XREF ��72��)�

G7H

reactor_object ���

IJKL����M/0NOPQRST�U'(1VW�3XY

XREF ��'(

'(Z[ \]

:VLR-beginAttach ^_NOST�U�

:VLR-otherAttach `M_ST�Uabcde��f�Mgh�ijk�lm/0no0B'(�B724�Mpp/q beginDeepCloneXlation VWk/q�rsMST�UNOtX�/0�

:VLR-abortAttach ST�UNOuvwxij^y�z�

:VLR-endAttach ST�UNOuv{|ij�

Page 344: AutoLisp Reference

344 | AutoLISP ��

:VLR-redirected ��������� �� ID��������� �����

:VLR-comandeered ����� ID ������ �����

:VLR-beginRestore �!"#$ ���%&'��()*��� �+,-.

:VLR-abortRestore ��� /(01(23456��7�

:VLR-endRestore 89!"#$ ���%&'�)*��� �45�(+,-.�

:VLR-xrefSubcommandBindItem XREF :;< BIND 8�=>�0��?@89A� ����BCD BIND EFGH;<��I,JKLM�

:VLR-xrefSubcommandAttachItem XREF :;< ATTACH 8�=>�0��!"89A� ����BCD ATTACH EFGH;<��I,JKLM�

:VLR-xrefSubcommandOverlayItem XREF :;< OVERLAY 8�=>�0��!"89A� ����BCD OVERLAY EFGH;<��I,JKLM�

:VLR-xrefSubcommandDetachItem XREF :;< DETACH 8�=>�BCD DETACH EFGH;<��I,JKLM�

:VLR-xrefSubcommandPathItem XREF :;< PATH 8�=>�BCD PATH EFGH;<��I,JKLM�

:VLR-xrefSubcommandReloadItem XREF :;< RELOAD 8�=>�0��1(89A� ����BCD RELOAD EFGH;<��I,JKLM�

:VLR-xrefSubcommandUnloadItem XREF :;< UNLOAD 8�=>�0��/(89A� ����

XREF NOPLM ( �� )

LMQR ST

Page 345: AutoLisp Reference

vlr-xref-reactor | 345

XREF �������

� �� �

:VLR-beginAttach 3 ��� ������������ VLA ���

��� ���� !"#$%&'()�*+ ,�-.��

�/� �� VLA ��!��$%0()���������

:VLR-otherAttach 2 ��� ������������ VLA ���

��� �� VLA ��!��$%0()���������

:VLR-abortAttach 1 VLA ��!��$%0()���������

:VLR-endAttach 1 VLA ��!��$%0()���������

:VLR-redirected 2 ��� ��1�!$%02,���34��567 (STR) ��� ID���� ��1�!$% ,��#����� ID�

:VLR-comandeered 3 ������ VLA ��!��89*+ ,�����

������1�!$%0:;����� ID��/� �� VLA ��!��$%0()���������

:VLR-beginRestore 3 ������ VLA ��!��89*+ ,�����

�������� !$%*+ ,67���

�/� �� VLA ��!��$%0()���������

Page 346: AutoLisp Reference

346 | AutoLISP ��

:VLR-abortRestore:VLR-endRestore

1 �������� VLA ��

:VLR-xrefSubcommandBindItem 2 ��������� BIND ������������ !"� 0 BIND #$%&'(�� 2 ��)*�* � ID �+,�-�� 3 )*�* � ID �+,�-./01�� 4 BIND #$%201�� 5 BIND 34�01�* � ID �567897:;<=�

� 6 BIND 34�01�* � ID �5672>7:;<=�

� 7 ?@A XBind )*� XDep B�� 8 ?@CDEFGH"LayersILinetypesITextStyles J DimStyles��K����� LM)*�+,�-� � ID�NOP�(�QR�S 0�

:VLR-xrefSubcommandAttachItem 2 ��������� ATTACH ������������ !"� 0 BIND #$%&'(�� 2 ��)*�* � ID �+,�-�� 3 )*�* � ID �+,�-./01�� 4 BIND #$%201�� 5 BIND 34�01�* � ID �567897:;<=�

� 6 BIND 34�01�* � ID �5672>7:;<=�

�K����� LMTU�+,�-� � ID�NOP�(�QR�S nil�

XREF VWXY' ( �� )

Z[ �\] �

Page 347: AutoLisp Reference

vlr-xref-reactor | 347

:VLR-xrefSubcommandOverlayItem 2 ��������� OVERLAY �� ������������� 0 BIND �������� 2 ���� �!" ID �#$�%�� 3 �� �!" ID �#$�%&'()�� 4 BIND ���*()�� 5 BIND +,�() �!" ID �-./01/2345�

� 6 BIND +,�() �!" ID �-./*6/2345�

�7��������89:;�#$�%�!" ID�<=>���?@��A nil�

:VLR-xrefSubcommandDetachItem 2 ��������� DETACH �� ������������� 0 BIND �������� 2 ���� �!" ID �#$�%�� 3 �� �!" ID �#$�%&'()�� 4 BIND ���*()�� 5 BIND +,�() �!" ID �-./01/2345�

� 6 BIND +,�() �!" ID �-./*6/2345�

�7��������89BC�#$�%�!" ID�<=>���?@��A 0�

XREF DEFG��H ( �� )

IJ KL ��

Page 348: AutoLisp Reference

348 | AutoLISP ��

:VLR-xrefSubcommandPathItem 3 ��������� DETACH � �������������� 0 BIND �������� 2 � � ! "# ID �$%�&�� 3 � ! "# ID �$%�&'()*�� 4 BIND ���+)*�� 5 BIND ,- )*! "# ID �./01203456�

� 6 BIND ,- )*! "# ID �./0+703456�

�8�������9� :;�$%�&�"# ID<=>��?@��A 0��B����CDE�$%�&�FGHI<=>��?@��A nil�

:VLR-xrefSubcommandReloadItem 2 ��������� RELOAD � �������������� 0 BIND �������� 2 � � ! "# ID �$%�&�� 3 � ! "# ID �$%�&'()*�� 4 BIND ���+)*�� 5 BIND ,- )*! "# ID �./01203456�

� 6 BIND ,- )*! "# ID �./0+703456�

�8�������9JKL�$%�&�"# ID<=>��?@��A 0�

XREF MNOP��Q ( �� )

IR ST ��

Page 349: AutoLisp Reference

vports | 349

vports

(vports)

���

�������� ����������������������

� !

"# AutoCAD �$%&' TILEMODE ()* 1+,-./0�1��� ��23 AutoCAD � VPORTS 4567��8)!���9: 0.0 � 1.0 ;<�� =�: (0.0, 0.0) > =?=@A�BCDE�����: (1.0, 1.0) =���!"# TILEMODE ()* 0+FG./0�HI1��� ��23 AutoCAD � MVIEW 4567��JK!���9:CLM<� =!N TILEMODE *FG./O��P* 1 ��Q2CLM<!

:VLR-xrefSubcommandUnloadItem 2 R��ST2UT� = UNLOAD VWXY�YZ![\���]^� 0 BIND _45`a:!� 2 VWbcdcJK ID �efSg!� 3 bcdcJK ID �efSghijk!� 4 BIND _45ljk!� 5 BIND mnWjkdcJK ID �op�qr�s�tu!

� 6 BIND mnWjkdcJK ID �op�lv�s�tu!

Rw�ST2UT���xyz�efSg�JK ID�"#{[:�|�ST* 0!

�� =N}�8)����

XREF ~���aT� ( �� )

�� �� ST

Page 350: AutoLisp Reference

350 | AutoLISP ��

��

TILEMODE ������ �������vports �������

((1 (0.0 0.0) (1.0 1.0)))

TILEMODE ���������� !�"#� !�$%&' ���vports �������

((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)) )

()�� *+,-./01�� 2 �34�5�#�6�()�� ��

7� 55

wcmatch

(wcmatch string pattern)

��

string 89: ;,<59:.=>&'? �1@ABCDE�

&'?;,5

pattern FG;,<�HIJ string KLE� FG5pattern �@HI2M 351N OP�,Q61R P�,5�S�FGTUVWXY7 (,) >Z5��[9: string \ pattern ) 500 �;,]^�_�`a ;,bcde5

fg���h�@.ijk7klm ;,<�n�@.op5�@qXrs AutoLISP ���� op\tu� string \ pattern t5

bFG;,<Jvw ;,<KLE�9:

Page 351: AutoLisp Reference

wcmatch | 351

���

�� string � pattern ��wcmatch �� T� wcmatch �� nil�

�������� "Name" ���� N ���

��� (wcmatch "Name" "N*")T

���� !"#�$%����� !&'���()*+,!wcmatch �� T�-.�(��)��/����01 !��2���(�1�� m2��� ��� N �����345(67,!89� wcmatch �� T�

��� (wcmatch "Name" "???,~*m*,N*")T

:��

:�� ;<

# (=�> ) ��*?@!A���

@ (at �> ) ��*?@!�B��

. (CD ) ��*?@!E�BA���

* (F> ) ��*?��GH0IJ���KL�MN-*+OP0I��Q(R�STU

? (V> ) ��*?@!��

~ (WX> ) ��K�&'���)Y,!�����Z[���\])*?���

[...] ��I>()*?,!��

[~...] ��^-I>()*?@!��

– _`��a b-I>cdbefg@!��)h�ij

,_k>a lmn!&'���

`_@o>a pqr<��_s�<thuv)��a

Page 352: AutoLisp Reference

352 | AutoLISP ��

�������� ��� wcmatch �� T�

� wcmatch �������

��������� !��"���#�#$% (‘) &�������'(

)�#�#$%*���+,- !�./�0'123*45678��

9�:;������ Name �'<=>?%�"���9@3ABC

DEC (wcmatch "Name" "*‘,*")nil

FG C H AutoLISP IJKLMNO��PQR (\) -:������������ST��U�PQR (\\) VW3X�PQR�:;����� Name �'<=>�PQR�"���9@3ABC

DEC (wcmatch "Name" "*‘\\*")nil

�Y=>�Z% ([ . . . ]) ����O1��./���+S�������[Y9@�\C ]Y,^_`�� (~) +'Z%a�b���c9 [A~BC]deV1�

�./f<g-:�hij��./k�lmno wcmatch pqrs!)t�^_%uvw��c9 [~ABC]du\��Y���0x�� (-) g]Y,k'Z%��b���y����c9 [-ABC] y [ABC–]d�yzk)�{|�

^_%*e�V1��./�<g��Z%��x���G(}~�}���

/4��������G#�������STR[1–38] � STR1�STR2�STR3 H STR8 s!�0 [A-Z] ��m#�����s!�

9��Z% ("]") 'Z%������y)t�^_%uc9 [ ]ABC] y [~]ABC]d�kr�1��./�

�m FG AutoLISP �����"W���2�� !������������Yi��q4��������������k���� ¡�

Page 353: AutoLisp Reference

while | 353

while

(while testexpr [expr...])

while ��� testexpr � nil �����

��

testexpr ����������

expr � testexpr � nil ���������������

���

!� expr ��� "���

#$

%&'()*+ 10 , some-func ��-.�� test �/�0 1 1 10� !2�� 11-3�452 !6������7

(setq test 1)(while (<= test 10) (some-func test) (setq test (1+ test)))

write-char

(write-char num [file-desc])

��

num �89:;�<=> ASCII (�

file-desc ?@AB��B�CD;�

���

num ���

E�����=��-FG2�5 nil-HIJKLM����-NO4�PQ-R1��������SG� nil

T��:;U1VWX���?@A�B�M

Page 354: AutoLisp Reference

354 | AutoLISP ��

��

����� C �� �������� num ���

��� (write-char 67)C67

�� f ������� !��"�#������ C $%���

��� (write-char 67 f)67

&'( write-char )*� NULL ��+ASCII ,-. 0/$��0

&�1 23 ASCII -45�&�1�����0

write-line

(write-line string [file-desc])

��

string ��670

file-desc 8������� !�0

��9

:;<=>� string0?���6$��@ABCD<=>0

��

��E���

��� (setq f (open "c:\\my documents\\new.tst" "w"))#<file "c:\\my documents\\new.tst">

FG write-line �HI�J$���

��� (write-line "To boldly go where nomad has gone before." f)"To boldly go where nomad has gone before."

K2L��MN%I�J)BOPQ$���

��� (close f)nil

���6RSTUHV8�����@

Page 355: AutoLisp Reference

xdroom | 355

xdroom

(xdroom ename)

���������� ��������� ���� 16KB������ �!"#$%&��'()�����*+ AutoLISP ,-./�0��/1�!"#$2�+34�56�78 9:;()����<=>?@ xdsize 0�A"�xdsize 0�"�BC����D EF<

G�

ename H�H��IJ�<

BCK

L��DMN��"9: OP�<QRSTUV xdroom BC nil<

1W

XW4YZ[\]6� ^�-_" ����9:`

ab ̀(xdroom vpname)16162

cdWe�f; 16,383 OP ����9:6g 16,162 OP�-_"�h2�i�j>". 221 OP 9:<

xdsize

(xdsize lst)

G�

lst �k ����D�=lmnop�" regapp 0�qr ��!"#$H<sGtd0� u1Wvw�<

BC\]�-_" ���� (Xdata) 9:

BC��Dxy����Az{\]��'|*}" 9:EF�+OPDM�

Page 356: AutoLisp Reference

356 | AutoLISP ��

���

����� �������� xdsize �� nil�

������ 1002���� �!"� lst ��#$%&'()*+,-. ERRNO /012�&'3����45�6789:;<=�2>?@A(#BC�D&'EF�G/+,-. CMDECHO HIJKLM�N

1001 �7�2>?@A!"

OP

lst QR> -3 ���45�6ST�JU(V)W���XI45�67QY89Z[\]2>?@�EF(^R_7��`a�bc���

(-3 ("MYAPP" (1000 . "SUITOFARMOR") (1002 . "{") (1040 . 0.0) (1040 . 1.0) (1002 . "}") ))

Dde1f�Pg(Vh�i -3 ���j_ekdl]_ cdr �m�(Vno�e��`apbc��N

( ("MYAPP" (1000 . "SUITOFARMOR") (1002 . "{") (1040 . 0.0) (1040 . 1.0) (1002 . "}") ))

zerop

(zerop number)

��

number ���

���

�� number qIr��� T(s��� nil�

tua]���es0 0

Page 357: AutoLisp Reference

zerop | 357

��

��� (zerop 0)T

��� (zerop 0.0)T

��� (zerop 0.0001)nil

Page 358: AutoLisp Reference

358 | AutoLISP ��

Page 359: AutoLisp Reference

�������

359

���

� ObjectARX � AutoLISP ������ AutoCAD �

����� �AutoLISP ���������

�������� AutoLISP ����� !�"#�

�� $%&'(�)�*+,-./0*+ AutoLISP �

���12345�67�89�

:;���<=>?� �@ABC,DEF�����

� Render

� Geom3d

� GeomCal

� AcadPS

� Solidsl

Page 360: AutoLisp Reference

360 | ������

3dsin

(c:3dsin mode [multimat create] file)

��

mode ��� ������������ (mode = 1) ����� (mode = 0)�

multimat � ��������� !�"#�$% mode &'( 0 )*+��,-(�

0 (.� !/0123"#

1 451� !6783"#

create � ���9:3"#�;<�=>?@ .3ds ABC�D�"#�$% mode &'( 0 )*+��,-(�

0 (.2 3DS "#/012EF

1 (.� 3DS GH/012EF

2 (.� 3DS !/012EF

3 4D�3"#IJK12EFL

file MNO �+?@� .3ds AB�PQRS .3ds ABTUV�

<� 0 =>?@ .3ds ABC�D�"#�

WX

YZ 3D Studio AB globe.3ds ��?@[\]�^?@)_`a�bc�

(c:3dsin 1 "globe.3ds")

?@ shadow.3ds ABd2��-6ef]�gh�^?@i����jk6���� !�"#[4D�3"#JKl12EFL�

?@ 3D Studio (.3ds) ABi�����render ARX _�mnj

Page 361: AutoLisp Reference

3dsout | 361

��� (c:3dsin 0 0 3 "c:/my documents/cad drawings/shadow.3ds")����� Render...����� ... ������� B_Leg01���� SKIN���� B_Leg02���� Central_01���� Central_02���� F_Leg01���� F_Leg02���� M_Quad01���� ML_Feele01���� ML_Feele02���� Pre_Quad01���� Pre_Quad023D Studio ������1

3dsout

(c:3dsout sset omode div smooth weld file)

��

sset � !"#$%�&' AutoCAD ���

omode (�)0 * 1+",- AutoCAD �./01'�&23�45 omode 6�7 0 * 1 8"3dsout �&9:;<=�

div (�",->?@ AutoCAD ��AB7 3D Studio ���CDE7�

0 7FG AutoCAD HIJKLG��

1 7FM AutoCAD NOJKLG��

2 7FM AutoCAD ��PQJKLG��

smooth (�",-RSTU'VEW�>: smooth 6�7 –1"XYZ[RSTU�>:6�7 0–360"X4T\1]^_'W`abcE8"AutoCAD deTUD:�

weld f�",-<ghijk8'lmVE�>: weld 6�7ab 0 'E"Xnojk�>:6�7pb*qb 0 'E"X AutoCAD jk_labcE'hi�

file rst",-%JK' 3D Studio ��u�vw#x .3ds ��yzu�

�& 3D Studio ��){|-}�render ARX ~���+

Page 362: AutoLisp Reference

362 | ������

��

�� ��� �� ��� 3D Studio ������ 30 ������� 0.1 � !"#$

(c:3dsout (ssget "X") 0 0 30 0.1 "testav.3ds")

align

(align arg1 arg2 ...)

%&

arg1 arg2... AutoCAD �'���%&(align )&�%&�*+,&-�./0�12��345 ALIGN 678(

9:;<=>?�1�ENTER@A�BC� nil D<EFG ("")(

HI�

JK)&L3MN�OHI TPQOHI nil(

��

R�C�S�TU�-VU���WXYZ 2D [\$

(setq ss (ssget))(align ss s1 d1 s2 d2 "" "2d")

cal

(c:cal expression)

%&

expression ]^_`�EFG(ab�cdef�ghij�k%l�

���4� CAL(

HI�

def��(

�[�mn����op0Xq���'?����$geom3d ARX >�r+A

s�tu�vw �xyz�HIdef��?����$geomcal ARX >�r+A

Page 363: AutoLisp Reference

fog | 363

��

��� AutoLISP ���� trans ��� � cal�

(trans (c:cal "[1,2,3]+MID") 1 2)

fog

(c:fog enabled [color [near_dist [far_dist [near_percent [far_percent [background]]]]]])

��

enabled ��������������� !"#$%&'( ON%

color )*+,-./ AutoCAD 01%&'( (111)%

near_dist 2�-3���4+%&'( 0.0%

far_dist 2�-3���5+%&'( 1.0%

near_percent 2�-3��674+���89:%&'( 0.0%

far_percent 2�-3��675+���89:%&'( 1.0%

background ���,-;<��=>?@A!BC%&'( OFFD���BCE%

� FOG FGHIJKL�MNOPQRSTU�HV�WX%Y?Z[\]1H�^_`������Y?Z[\a1H�^_`�bcJd��%

efg��( Nil �&hij��<k���d�lmno�%

light

(c:light mode [options])

\`MNOPQRS�TUDpq-3�render ARX r�stE

uvwxyz{|}~z����Dpq-3�render ARX r�stE

Page 364: AutoLisp Reference

364 | ������

��

mode �� ��������mode ������

A ������ !"#

D $%&��!'

L ()*+,�-�!'�./0 �!'���

M 12&��!'

ND 345�6�!

NP 345�7!'

NS 345�8!9

R :�;&��!'

options options ������<�= mode�>?@ABCDEF()�

GH ?��IJKL*MNO,���

A—� !

��.��� !"#�

(c:light "A" [intensity [color ]])

��

intensity P���L 0.0 Q 1.0 RO�ST intensity UVW�XYZ� 1.0�

color [� � RGB \]��STVW�XYZ� (1.0 1.0 1.0)�

^_

S`��a� !"#��� 0.6�

��� (c:light "A" 0.6)1

VW intensity ��b��cd� !�"#�

��� (c:light "A")(0.6 (1.0 1.0 1.0))

/0�"#� 0.6�\]� 1.0 1.0 1.0�

Page 365: AutoLisp Reference

light | 365

D—����

��������

(c:light "D" name)

name �� �������������

��

�����������OLDLGT�����

(c:light "D" "OLDLGT")

L— !��

!"#$�%����&'(������)�

(c:light "L" [name])

name �� ���� !��������*+, name �- c:light !"#$�)�%����

��

��./ !01"#$�)�%����

./� (c:light "L")("BUDLIGHT" "LIGHT01")

��./ !���LIGHT01�����23�

./� (c:light "L" "LIGHT01")("P" <Entity name: 4cf3ae8> 1.0 (26.5609 43.423 48.6995) (0.0 0.0 0.0)(0.705882 0.705882 0.705882) 512 nil nil 3.0 "OFF" 0 nil)

M— 45��

45������

(c:light "M" name [intensity [from [to [color [shadowmapsize [hotspot [falloff [shadowsoftness[shadow [shadowobjects [month [day [hour [minute[daylight [latitude [longitude[attenuation]]]]]]]]]]]]]]]]]])

Page 366: AutoLisp Reference

366 | ������

��

�� ����������

LIGHT-M� ���

�� ���� �� ���

name STR ����� !

intensity REAL " 0.0 #��$%�&'�(�) *+, �-�

from LIST ��./ 012345

to LIST ��67 012385

color LIST RGB 9:� 1.0, 1.0, 1.0

shadowmapsize INT 0 # 4096 &'�;�<=>?@A�BCDE.FGHI

0

hotspot REAL JK��LMN<OP" 1–160 Q'RI)

44.0

falloff REAL �LSN+,Q�MN<OP" 1–160 Q'RT%UJK��LMNI

45.0

shadowsoftness REAL 0.0– 10.0 Q'R�(� 0.0

shadow STR =>VWDXY��off� –!=>on� –Z[=>

0.0

shadowobjects ENAME =>?@\L]^�_` 0.0

month INT 1 # 12 &'�;� 9

day INT 1 # 31 &'�;� 21

Page 367: AutoLisp Reference

light | 367

hotspot � falloff ��������� ����������� nil�

������������ !"#$%�&'()*+,�-��./01

2��3�4567*��89� nil���:;<="5>��?56@AB

CD��attenuation�&' attenuation � timezone�&' attenuationEtimezone � longitude...F�

GD

�HIJ7��KD1L"MN!�ONP

(c:light "M" "D1" nil nil nil ’(0.0 0.0 1.0))

ND—� ��

Q �"���

(c:light "ND" name [intensity [from [to [color [shadowmapsize [ nil [ nil [shadowsoftness [shadow [month [day [hour [minute [daylightsavings [latitude [longitude [timezone [attenuation [shadowobjects]]]]]]]]]]]]]]]]]]])

hour INT 0 R 24 ST"U� 15

minute INT 0 R 59 ST"U� 0

daylight STR VW�XY�Z[3PKoffL –\VW�KonL –VW�

"off"

latitude REAL 0–90 ]T^"_� 37.62

longitude REAL 0–180 ]T^"_� 122.37

timezone INT -12R 12ST"U��;`�a�Tbcdefgh�T iGMTj "�k�

8 (PST)

attenuation INT 0 = lmn1 = o,mn2 = �pmn

1

LIGHT-KMLqr�� ( �� )

�� �s$% tu vw3

Page 368: AutoLisp Reference

368 | ������

��

�� �������������

LIGHT-ND�����

�� ���� �� ���

name STR � ��!" #

intensity REAL 0.0 $��%&�'(�)� *+,��-�

from LIST �!./ 012345

to LIST �!67 012385

color LIST RGB 9:� 1.0, 1.0, 1.0

shadowmapsize INT 0 $ 4096 '(�;�<=>?5�@ABC

0

hotspot REAL DE��FGH<IJK 1–160 L(MC

44.0

falloff REAL �F+,L�GH<IJKN1–160NL(MO&PDE��FGHC

45.0

shadowsoftness REAL 0.0– 10.0 L(M�)� 0.0

shadow STR QRSTUVW��off� –#QRon� –XYQR

0.0

shadowobjects ENAME QRZ[\]�^_ 0.0

month INT 1 $ 12 '(�;� 9

day INT 1 $ 31 '(�;� 21

Page 369: AutoLisp Reference

light | 369

NP—�����

��������

(c:light "NP" name [intensity [from [nil [color[shadowmapsize [nil [nil [shadowsoftness [shadow[attenuation[shadowobjects ]]]]]]]]]]])

hour INT 0 24 ��� 15

minute INT 0 59 ��� 0

daylight STR �����������off� –�����on� –���

"off"

latitude REAL 0–90 ����� 37.62

longitude REAL 0–180 ����� 122.37

timezone INT -12 12 ��� ��� !��"#$%&'(�� )GMT* ��+

8 (PST)

LIGHT-�ND�,-. ( �� )

. /01 23 45�

Page 370: AutoLisp Reference

370 | ������

��

�� �������������

�����— to�� from �� !hotspot " falloff�� shadowmapsize �� —#$%&� �'�� �()*+,-./0 nil'

12

2�)��34�50 NEWPT1 �� �'

(c:light "NP" "NEWPT1")

NEWPT1 6�789:!;<=>./!78 �?/�;<@A� "78BC�DC '

EF � �9:�GH78IJK ��=>./L�'M=>()78GH

9:0 1.00NOP=>()78GH9:0QRGHSTU:�VWNXY=>()78GH9:0GHSTU:VW�XY'

LIGHT-NP�����

�� �Z[\ �� 78I

name STR ]^� �5 M

intensity REAL 0.0 _78GHI�`�a� J=>��L�

from LIST �?/ ;<bOc�

color LIST RGB BCI 1.0, 1.0, 1.0

shadowmapsize INT 0 _ 4096 �`�d��efgQh�ij)klm0n?

0

shadowsoftness REAL 0.0– 10.0 o`p�a� 0.0

shadow STR efqr)�sI�off� –Mefon� –tuef

0.0

attenuation INT 0 = M=>1 = OP=>2 = XY=>

1

shadowobjects ENAME efgQvw�xy 0.0

Page 371: AutoLisp Reference

light | 371

NS—�����

��������

(c:light "NS" name [intensity [from [to [color[shadowmapsize [hotspot [falloff [shadowsoftness[shadow [attenuation [shadowobjects]]]]]]]]]]])

������� ��������

LIGHT-�NS� �

��� �� ���

name STR ������ �

intensity REAL 0.0 ��!"�#$�% &'( �)*

from LIST ��+, -./012

to LIST ��34 -./052

color LIST RGB 67� 1.0, 1.0, 1.0

shadowmapsize INT 0 4096 #$�89:;<=>�?@ABCDEF+G

0

hotspot REAL HI��JKL9MNO 1–160 P$QG

44.0

falloff REAL �J'(P�KL9MNOR1–160 P$QS"THI��JKLG

45.0

shadowsoftness REAL 0.0–10.0 P$Q�% 0.0

shadow STR :;UVAWX���off� –�:;�on� –YZ:;

0.0

attenuation INT 0 = �'(1 = 0['(2 = \]'(

1

shadowobjects ENAME :;<=^_�`a 0.0

Page 372: AutoLisp Reference

372 | ������

��

�� ����GSPOT ������

��� (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 ���� 43.82������ !"�#��$%&� (12,6,24)�'(%&� (78,78,24)�)*+� 32 ����+� 30 ��

,- ������./�� 01�$�234&5��6237���./

��� 1.0089:237���./���;<./=>?��@A8BC237���./���./=>?�@A�BC�

R—D���$

D��EF��$�

(c:light "R" old_name new_name)

GH

old_name IJK�L�MD����$��N�

new_name IJK�L��$� �N�

��

OHPQR�$�GSPOT�D����HOTSPOT��

��� (c:light "R" "GSPOT" "HOTSPOT")1

lsedit

(c:lsedit mode [options])

ST<U� c:lsedit QVW�XYZ;<[�\]^_`��

(c:lsedit "LIST" object)

ST<U� c:lsedit abL�\]^_�c:�de�afghL�^_��Nij�i%&k^lCU�

(c:lsedit object height [position [alignment]])

ST<U� lsedit YZ\]^_�

W�XYZ\]^_!�����render ARX mQno#

Page 373: AutoLisp Reference

lslib | 373

��

LSEDIT ���������

��������� <ename> �������� AutoCAD �� (entsel)������� !"

(c:lsedit <ename> 35.0 ’(10.0 23.0) nil)

lslib

(c:lslib mode [options])

LSEDIT ��

�� �#$% �� &'(

object ENAME �����)* +

height REAL ���,-./012345"�6�7�89:( �!"

+

position LIST(of reals)

��;<.=5�3>"�6�7�89:( �!"

+

alignment INT ?@AB�CD01E�����0—2F<GH��1—2F<IGH��2—JK<IGH��3—JK<GH���6� nil�89:( �!"

+

LM��N.OP@Q�render ARX RSTU5

Page 374: AutoLisp Reference

374 | ������

��

mode mode ���� �

ADD ���������

DELETE ���������

MODIFY ��������

OPEN �����

SAVE � !"���

LIST #$!"������

options options ����%�& mode'()*+,-./0#$1

ADD

�!"��������1

(c:lslib "ADD" name texture-map opacity-map alignment)

��

name 234'5�������671

texture-map 234'5���89:;61

opacity-map 234'5���<=>89:;61

alignment ?�'5���@A8BC*DE.1�� �

0 /FGHIJ*D

1 /FGHKIJ*D

2 LMGHKIJ*D

3 LMGHIJ*D

NO��PQRS�1

TU

�!"������6 VMaple treeW���

(c:lslib "ADD" "Maple tree" "maple.tga" "mapleo.tga" 0)

Page 375: AutoLisp Reference

lslib | 375

DELETE

����������

(c:lslib "DELETE" name)

name ���������������

��

�����������Maple tree����

(c:lslib "delete" "Maple tree")

MODIFY

(c:lslib "MODIFY" name texture-map [opacity-map[alignment]])

�����������texture-map opacity-map ! alignment ��"#�$%�&'()*�

name ���������������

texture-map ��������+,-.��

opacity-map ��������)/0+,-.��

alignment 1������23+4!5678�9:&��

0 ;<=>?@56

1 ;<=>A?@56

2 BC=>A?@56

3 BC=>?@56

DE �FG9HI&�

��

J�Maple tree��5678��BC=>A?@56�

(c:lslib "MODIFY" "Maple tree" nil nil 2)

Page 376: AutoLisp Reference

376 | ������

OPEN

���� ���������� �

(c:lslib "OPEN" name)

��

name ����������� ���

!

�� TREES.LLI "#���������� $

(c:lslib "OPEN" "TREES.LLI")

SAVE

%���� &'���"#�

(c:lslib "SAVE" name)

��

name �������� "#���

!

"#('� TREES.LLI$

(c:lslib "SAVE" "TREES.LLI")

LIST

)*���� +,-./�0��12345���)678� ’("NAME" "TEX-MAP" "OP-MAP" ALIGN) 9:��;<�

(c:lslib "LIST")

!

LIST =;>* !?@$

(("Bush #1" "8bush02l.tga" "8bush02o.tga" 0) ("Cactus" "8plnt15l.tga" "8plnt15o.tga" 0) ("Dawn Redwood" "8tree39l.tga" "8tree39o.tga" 0))

Page 377: AutoLisp Reference

lsnew | 377

lsnew

(c:lsnew object-type height position alignment)

LSNEW ���������� �����

��

object-type ���������������

height ����� �� !"#��$%&'(�

position ��&��� �)*�%+�

alignment ,�������-.��/ 012�34567

0 $8&9:; 0

1 $8&9<:; 0

2 =>&9<:; 0

3 =>&9:; 0

?@��AB3CD5�

E�

�6FCactusG�H��� !6 25 I��$%�%+6 (0, 1, 3)�J3$8&9<:; 012�

��7 (c:lsnew "Cactus" 25.0 ’(0.0 1.0 3.0) 1)1

matlib

(c:matlib mode name [file])

�� �"KL�M7render ARX N�OP(

QRST�"KL�M7render ARX N�OP(

Page 378: AutoLisp Reference

378 | ������

��

mode �� ���������������

I ����� !���

E "���� #���

D �$%�&'���

C �$%�&'()*����

L +#���

name �� �, !- #.&'����/0�

file �� ����12�/0�file ��3456 .mli 1278/�

9:

�;< AutoCAD =>��� render.mli � !�� BRASS�

��� (c:matlib "I" "brass" "c:/acad2000/support/render.mli")1

?&'@AB�CDE file ���

(c:matlib "D" "steel")

mirror3d

(mirror3d arg1 arg2 ...)

��

mirror3d ������FG-�HIJKLEM����� ! MIRROR3D NOP�,QREMS ENTER TUC !VW��XDE nil .Y� ("")�

Z[�

\]��^�_`�aZ[ TbcaZ[ nil�

9:

d:Oefghi (0,0,5) � XY jklmn��eo�pq&'r�eo�

(setq ss (ssget))(mirror3d ss "XY" ’(0 0 5) "Y")

OefEM ��jkstn��eou�����geom3d ARX vEwGx

Page 379: AutoLisp Reference

psdrag | 379

psdrag

(c:psdrag mode)

��

mode ����� 0 � 1�PSDRAG �� � PSIN �������� PSDRAG � 1�� PSIN �������� !"# PostScript ����� PSDRAG � 0�� PSIN $"#%����&'�

()�

�� c:psdrag *�+�#,��() PSDRAG-�.�� c:psdrag +�/0��() nil�

12

�3456 PSDRAG 7� 1�893:;������� !�PSIN 6"# PostScript ���

(c:psdrag 1)

psfill

(c:psfill ent pattern [arguments] … )

��

ent <=>?@�

pattern ABC�DEFG�H?@�pattern ABCIJK� acad.psf LMNOPQRFG�H?@:S�

arguments TU PostScript FGVW���arguments �XYZ[\]� pattern^� acad.psf LMNOP_�`R���IJa���b��`R�Hcde 0 f 25 R�����*�g8��h��HOP���ijk3��l8�Hmn

��

op8 PSIN ��6 PostScript ����fqOrs!t��uv^uUOPwacadps ARX x8Wy_

8 PostScript FG�HFGz{<=>|}^uUOPwacadps ARX x8Wy_

Page 380: AutoLisp Reference

380 | ������

��

�� ���� c:psfill �� T��� ������ nil�

��

Grayscale ���������� !"#$%���&'()*+ Grayscale �� 50%,

(c:psfill ename "Grayscale")

�-.�!"/0� 10% 12�

(c:psfill ename "Grayscale" 10)

PostScript ��3456�789-�:;</�=>"?@AB AUTOCAD_POSTSCRIPT_FIGURE C=DE�

psin

(c:psin filename position scale)

��

filename FGH�IJ PostScript �K+AB�"LMN0� .eps ;<56A�

position O�0�PQARPostScript S+TUO�

scale V��0�W�XY�

��

�� ���� c:psin ��Z[\]^+AB��� ������ nil�

��

_`aUA4 sample.eps + PostScript ;<�TUO4 (24,19)�bcW�XY4 25,

(c:psin "sample" ’(24 19) 25)

PostScript �K3456�789-�:;</�=>"?@AB AUTOCAD_POSTSCRIPT_FIGURE C=DE�

aU PostScript ;<P����,acadps ARX >"?@R

Page 381: AutoLisp Reference

render | 381

render

(c:render [filename|point1 point2])

��

filename �������� ���

�� filename ������������������������ !"#�� filename ���$%�&'��()������

point1 *�+���,-./ 0123�

point1 *�+���,-./ 0423�

5&'6�78�9:6�; c:rpref <�6��=�>

(c:rpref "Toggle" "CropWindow" "On")

?@ ��&'AB���� Query for Selection CDEFG PICKFIRST ABHI�CD�J; c:render K��&'LMN��OPQRSTUR�VWX�LMNY Z[�

6�\���]L^

6�����

(c:rfileopt fileformat xres yres aratio colormode <mode-specific options>)

��

c:rfileopt �� _`�a+>

;bcdefghi+j,klmnopqrstu v*wxydz{|}�~>render ARX �;"#�

RFILEOPT ��

�� ���u _`

fileformat STR ���� ���>TGA— Targa ��PCX— Z-Soft��d��BMP— Microsoft Windows���PS— PostScriptTIFF—���dz����

Page 382: AutoLisp Reference

382 | ������

TGA

�� Targa �

(c:rfileopt "TGA" xres yres aratio colormode interlace compress bottomup)

xres INT �� �� X ������������ 1 � 4096�

yres INT �� �� Y ������������ 1 � 4096�

aratio REAL �� !"

colormode STR #$ ��%&'(��)*+MONO— ,-G8—256 -./C8—256 -C16—16 0-C24—24 0-C32—24 0-1 8 023

RFILEOPT 45 ( �� )

45 5678 9:

Page 383: AutoLisp Reference

render | 383

��

��

(C:RFILEOPT "TGA" 640 480 1.0 "C32" 1 "COMP" "UP")

PCX

�� Z-Soft ���

(c:rfileopt "PCX" xres yres aratio colormode)

TGA ��

�� �� � ��

colormode STR ����G8� C8� C24 � C32

interlace INT ����1—���2—2:1 ��4—4:1 ��

compress STR ������ ! ="COMP#$�COMP—��nil— ���

bottomup STR %&��� ! ="UP#$�UP—'&(%nil— '%(&

Page 384: AutoLisp Reference

384 | ������

��

(C:RFILEOPT "PCX" 640 480 1.0 "G8")

BMP

�� Microsoft Windows � ���

(c:rfileopt "BMP" xres yres aratio colormode)

��

(C:RFILEOPT "BMP" 640 480 1.0 "C8")

PS

�� PostScript ���

(c:rfileopt "PS" xres yres aratio colormode portraitimagesize [size])

PCX ����

�� ���� ��

colormode STR �����MONO� G8 � C8

BMP ����

�� ���� ��

colormode STR �����MONO� G8 � C8

Page 385: AutoLisp Reference

render | 385

��

��

(C:RFILEOPT "PS" 640 480 1.0 "C24" "P" "C" 640)

TIFF

������ ��

(c:rfileopt "TIFF" xres yres aratio colormode)

PS ���

�� ���� ��

colormode STR �����MONO� G8�C8���C24

portrait STR ������ !" =#L$%� P—��L— ��

imagesize STR ��� !" =#A$%�A— &'I— C—&�(

size INT )*

Page 386: AutoLisp Reference

386 | ������

��

(C:RFILEOPT "TIFF" 640 480 1.0 "C24")

renderupdate

(c:renderupdate [RU_value])

���� renderupdate ������������� en2face ���

��

RU_value ���� !"#$

ALWAYS %���&��' ()*+���

OFF ,-�.()*+ ��/012�

replay

(c:replay filename type [xoff yoff xsize ysize])

34 REPLAY ���5� AutoCAD ���67 BMP8TGA 9 TIFF ����:�� ;<=*>�?@ABCDE�67�

��

filename ����F�*>��G�

type ����F���HI� !"# BMP8TGA 9 TIFF�

xoff J��F�*> X ABKL>MN#OPQ�RS# 0�

yoff J��F�*> Y ABKL>MN#OPQ�RS# 0�

TIFF T2��

�� �UHI VW

colormode STR XY12$MONO8G88C88C24 9 C32

��������� en2face ��K����$render ARX Z�[\Q

67 BMP8TGA 9 TIFF *>K����$render ARX Z�[\Q

Page 387: AutoLisp Reference

rmat | 387

xsize ��� X �������� ����� X ���

ysize ��� Y �������� ����� Y ���

��

������� test.tga ���������� !���"#$%&�'( 500 ���)( 400 ��*

(c:replay "TEST" "TGA" 0 0 500 400)

rmat

(c:rmat mode options)

+,

mode -./���0*

A 1234

C 5634

D 7834

L 9:�;<�=#34�>?@AB34�BC

M DE34

N FGH34

options #I0JKLAB� mode�

A—1234

MAN�12 OPQ3412RSB�TU> ACI�AutoCAD VWXY 0Z�[\]^_`+, (layer-name)�abKB�

(c:rmat "A" name [aci | selection-set | layer-name])

FGcdec12f78gh34�ijBC*render ARX k�lm

Page 388: AutoLisp Reference

388 | ������

��

���� ����

��

��� PURPLE TIGER � ACI 1�����

(c:rmat "A" "PURPLE TIGER" 1)

����� !��"#$A%&'()*+ ,�-��

� ./����012-�3

� ./���� ACI -�3� *+./����45�6783

� !��9��:�();����

��� (c:rmat "a" "twood")<845… .=� 1 !(("first" "second")(135) <Selection set 12>))

��>?;@AB 1–255 C:D ACI ;"EF 255 �>?;�G AutoCAD HI��JDK ACI /��3

C—LM��

NOLM0PC.QR@���STUV��3

(c:rmat "C" cur_name new_name)

��

cur_name WXY"/�ZLM����2[3

new_name WXY"/�V���2[3

��

�� �\]^ �

name STR Z����2[

aci INT ACI_;"@AB 0_�_255_C

selection-set INT *+90`�678

layer-name STR 012

Page 389: AutoLisp Reference

rmat | 389

��

���������

(c:rmat "C" "RED" "RED2")

D— ���

�D�� ������������ACI�AutoCAD ����� !"#$ ���%&'()*+, (selection-set) �-./0

(c:rmat "D" name [aci | selection-set | layer-name])

Page 390: AutoLisp Reference

390 | ������

��

���� ����

��

������������ !��"#$%�

(c:rmat "D" (ssget))

L—&'$%

&'()*$%���+

(c:rmat "L" [name])

��

name ,-.�/�0&'�$%��+�1 name ��234�5 c:rmat &'()*�67$%+

��

&'()*�67$%+

���(c:rmat "L")("*GLOBAL*" "BLUE GLASS" "WHITE PLASTIC" "TWOOD" "BEIGE MATTE")

&�*�89!,-./�:;�<=$%>*<= *?�@A�B,-.�#C

DE�����$%9�FGH c:rmat�

���(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))

$%��*�&�IJ>KL?E>MN?OP*���QR+

��

�� �STU � :;V

name STR 0�$%�WX Y

aci INT ACIZV�[\]Z0Z^Z255Z* Y

selection-set INT _`2(a���b Y

layer-name STR (cW Y

Page 391: AutoLisp Reference

rmat | 391

M—����

�M������� ��N������� ���������� nil�

������ !"#$%&'��()�*+,-./0�

1�$�2345 BLUE MARBLE ��6789:;�<=>?�@9�

(c:rmat "M" "BLUE MARBLE" "marble" ’(0.5 0.5 1.0) ’(0.0 0.0 0.0))

N—����

�N�����A�����B���CDEFGHI$JKLEFGMA����NO�PQ+��RST?UVW?XY�Z7[\���]

^$_K`a���bc�����C��

��

�����de�2�R

fg$hijk���Zlm��nop�7q�rstu$v�wx 398y��jk����

Standard

��NOz{|�STANDARD�opA���bc���

(c:rmat "N" name "STANDARD" [color [color-weight [pattern[ambient [amb-weight [ref1 [ref1-weight [ref1-map[roughness [transparency [opacitymap [refraction[bumpmap]]]]]]]]]]]]])

����

�� �}NO de ~�0

name STR �A������� �

material-type STR ����NO�7�0�RSTANDARD—bcMARBLE—ST?GRANITE—VW?WOOD—Y�

description �Cp� �MA����NOFp��� �Cp�

selection-set INT �����k����] �

layer-name STR k�� �

Page 392: AutoLisp Reference

392 | ������

��

Standard ���� ��

Standard ��

�� ���� � ���

color LIST(�� )

RGB������������(-1.0 -1.0 -1.0)�� !"#�ACI���$%&�'

(-1.0 -1.0 -1.0)—( ACI

color-weight REAL )�*+$���'—%&��, 0.7

pattern LIST -. //01-�� 2

ambient LIST(�� )

RGB�������34$56'� (-1.0 -1.0 -1.0)—( ACI

amb-weight REAL )�*+$34�'—789&��, 0.1

refl LIST(�� )

RGB�������9&$789&'� (-1.0 -1.0 -1.0)—( ACI

Page 393: AutoLisp Reference

rmat | 393

��

�������� ���������

(c:rmat "N" "RED LACQUER" "STANDARD" ; �����’(1.0 0.0 0.0) (1.0) ; �������� �!"��'("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 ; #$�%&� ��'(��'(1.0 0.0 0.0) 1.0 ; )(��*��%&� nil ; +)(��0.2 ; ,-.�/�0.0 ; 01.�+�nil ; +201��0.0 ; 3(�+�nil ; +45��

������6�78���� MAPS�

(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.50.0'("hole.tga")1.0'("ridges.tga")

���������26�8��9: ;<�=>?@ABCDEF�#$�

�G=>?@HIJKDEFLMDEN;���)(HOHIPKQRS

(c:rmat "N" "SHINE" "STANDARD" nil nil nil nil nil nil nil '(nil nil 1))

refl-weight REAL � TU�)( �—VW)(��XY 0.2

refl-map LIST )( /#$��ZX +

roughness REAL ,-.—VW)(�[H��\] 0.5

transparency REAL ���01. 0.0

opacity-map LIST 201��ZX +

refraction REAL 3(^X 1.0

bumpmap LIST 45��ZX +

Standard ZX ( �� )

ZX X_�� `1 9:

Page 394: AutoLisp Reference

394 | ������

Marble

���� �MARBLE�������������

(c:rmat "N" name "MARBLE" [stone-color [vein-color[refl [refl-weight [refl-map [roughness [turbulence[sharpness [scale [bumpmap ]]]]]]]]]])

��

Marble ��������

!"

��#$��%&'()��*)+,)-�������

(c:rmat "N" "PINK MARBLE" "MARBLE" ’(1.0 0.34 0.79))

RMAT— Marble ��

�� �. �� /01

stone-color LIST(of reals)

RGB *)12��������*)

(–1.0 –1.0 –1.0)—3)

vein-color LIST(of reals)

RGB *)12������-�*)

(–1.0 –1.0 –1.0)—,)

refl LIST(of reals)

RGB4*)12�56789:67;)

(–1.0 –1.0 –1.0)— < ACI

refl-wgt REAL =1>?8671;—9:67)��@

0.2

refl-map LIST 67 /ABCD�� E

roughness REAL FGH—9:678IJ;��K 0.5

turbulence INT LM>?—-��NM 3

sharpness REAL OPH>?—QRS��@ 1.0

scale REAL TUV">? 0.16

bumpmap LIST WXCD�� E

Page 395: AutoLisp Reference

rmat | 395

Granite

��������GRANITE�� ��������

(c:rmat "N" name "GRANITE" [first-color [amount1[second-color [amount2 [third-color [amount3[fourth-color [amount 4 [refl [refl-weight [refl-map [roughness [sharpness [scale [bumpmap ]]]]]]]]]]]]]]])

��

Granite ���������

RMAT— Granite ��

�� ���� �� ���

first-color LIST(of reals)

RGB !� (–1.0 –1.0 –1.0)—"!

amount1 REAL #$% !�&�'() !�* 1.0

second-color LIST(of reals)

RGB !� (0.5 0.5 0.5)— +,!

amount2 REAL #-% !�&�'() !�* 1.0

third-color LIST(of reals)

RGB !� (0.0 0.0 0.0)—.!

amount3 REAL #/% !�&�'() !�* 1.0

fourth-color LIST(of reals)

RGB !� (0.7 0.7 0.7)—0,!

amount4 REAL #1% !�&�'() !�* 1.0

refl LIST(of reals)

RGB2 !�3�456)7856*!

(–1.0 –1.0 –1.0)9 Ê ACI

refl-weight REAL &�'()56�*—7856!��:

0.2

Page 396: AutoLisp Reference

396 | ������

��

�� ����������������������� !�"�#$

�%��&

(c:rmap "N" "YELLOW GRANITE" nil 0.5 nil 0.0 nil 0.85 ’(1.0 1.0 0.0) 0.6)

Wood

��'()*+,WOOD-.�/01���2

(c:rmat "N" name "WOOD" [light-color[dark-color [refl [refl-weight [refl-map [roughness[ratio [density [width [shape [bumpmap ]]]]]]]]]]])

refl-map LIST 34 /56789: ;

roughness REAL <=>—?@34ABCD0EF 0.5

sharpness REAL GH>IJ—KLM0:N 1.0

scale REAL OPQ�IJ 0.16

bumpmap LIST RS789: ;

RMAT— Granite 9: ( �� )

9: :T'( UV WXY

Page 397: AutoLisp Reference

rmat | 397

��

Wood ��������

RMAT— Wood ��

�� ��� �� ��

light-color LIST (of reals)

RGB������������� (0.6 0.4 0.3)

dark-color LIST(of reals)

RGB������������� (0.3 0.2 0.2)—��

refl LIST(of reals)

RGB������������ � (–1.0 –1.0 –1.0)—! ACI

refl-weight REAL "�#$���� —�������% 0.2

refl-map LIST �� /�&'(�� )

roughness REAL *+,—�����-. �/0 0.5

ratio REAL ���1����23 0.5

Page 398: AutoLisp Reference

398 | ������

��

�� ��������

(c:rmat "N" "CRYPTO" "WOOD" nil nil nil nil nil nil nil nil nil 0.56)

����

������������ !"#� $%& c:rmat '(!()* +,-./012345�6789&'( c:rmat :;<=>?@A

�B /CD

’(name [blend [repeat [scale [offset [reserved [map-style [auto-axis]]]]]]])

density REAL EFG 6.0

width REAL EHG 0.2

shape REAL E6I 0.2

scale REAL JKL�M* 0.16

bumpmap LIST NOP��� Q

RMAT— Wood �� ( �� )

�� �RST UV WX=

Page 399: AutoLisp Reference

rmat | 399

��

�� /��������

�� /��

’(name [blend [raytrace]])

�� /����

�� ���� � ���

name STR ������� �

blend REAL ��� �!"��# 1.0

repeat INT $%&'()*+�� 0—,)*(-.+1—)*(&'��+

0

scale LIST(of reals)

U / V 0123 (1.0 1.0)

offset LIST(of reals)

U / V 45 (0.0 0.0)

reserved REAL 67�8�9 �

map-style INT �:;< 0—=>011—?�@AB

0

auto-axis INT $%C�DEFGH 0—I�1—C�

1

Page 400: AutoLisp Reference

400 | ������

��

/���� ������

���

’(name [blend [repeat [scale [offset [reserved [map-style [auto-axis]]]]]]])

/����

�� ���� �� ���

name STR ���� ! "

blend REAL #$ %�&' �( 1.0

mirror REAL )*+,-.�0—�-.1—-./-.0+,12345/6720$��%�+,

0

Page 401: AutoLisp Reference

rmat | 401

��

����������

� ��

’(name [amplitude [repeat [scale [offset [reserved [map-style [auto-axis]]]]]]])

�����

�� ���� �� ���

name STR ������� �

blend REAL ��������� 1.0

repeat INT !"#$%&'(���0—�&'%)*(1—&'%#$�+(

0

scale LIST(of reals)

U , V -./0 (1.0 1.0)

offset LIST (of reals)

U , V 12 (0.0 0.0)

reserved REAL 34�5�6 �

map-style INT ��789�0—:;-.1—<�=>?

0

auto-axis INT !"@�ABCDE�0—F�1—@�

1

Page 402: AutoLisp Reference

402 | ������

���� ����

rotate3d

(rotate3d args ...)

args rotate3d ������������������ ! ROTATE3D "#$%&'()*+,������ ROTATE3D%

-.�/012��3ENTER456.�789*:;

� nil </=>? ("")%

@AB

�CD�EF*G rotate3d @A THIG@A nil%

��

J�� � KLB

name STR MNOP�QR S

amplitude REAL ��TU 1.0

repeat INT VIWX2YZ9MN�0—6YZ2[\91—YZ2WXN]9

0

scale LIST (of reals)

U � V ^_`a (1.0 1.0)

offset LIST (of reals)

U � V bc (0.0 0.0)

reserved REAL de�fM> S

map-style INT gNhij�0—k�^_1—3Nlmn

0

auto-axis INT VIo�pqrst�0—u�1—o�

1

v7wxysz{|}2�����geom3d ARX 1�T�9

Page 403: AutoLisp Reference

rpref | 403

��

��������� p1 p2 ������ 30 ��

(setq ss (ssget))(rotate3d ss p1 p2 30)

AutoLISP � rotate3d ��������� SAGET �����

rpref

(c:rpref mode option [setting])

c:rpref �� �!"#���$� %&�!"'(�

$�

mode )*+,-./01

DEST 2301456!"7589:�

ICON ;< =>?3@�ABC�

ROPT DE!"�F

SELECT GHIJ�K�

STYPE !"LM1NO!"6PQRS�T!"8PQR

;UVW!"

TOGGLE !"�F

option X Y mode�

setting X Y mode�

Z$[ \ 383]�^_`a!"b9:c�Fd�

DEST—23e`

�K#���fg_h�

(c:rpref "DEST" option)

_`!"ije`klm�n1render ARX o�pqr

Page 404: AutoLisp Reference

404 | ������

��

option �� �����������

FRAMEBUFFER �����

HARDCOPY �������

FILE �����

��

!"# �������

(c:rpref "DEST" "FILE")

ICON—$�%&

�$'()*+,-$�./01�

(c:rpref "ICON" option)

��

option 2�� �$�./01�34�� 1.00�

��

!5�"#6$�7�8� 50%�

(c:rpref "ICON" 0.5)

STYPE—��9:%&

�;<#/��9:�

(c:rpref "STYPE" option)

��

option �� ���9:������

ARENDER =>��

ASCAN ?@AB2C��

ARAY ?@A)DEF��

��

!GH �!=I��9:�=> AutoCAD ���

(c:rpref "STYPE" "ARENDER")

Page 405: AutoLisp Reference

rpref | 405

SELECT—����

������ ������

(c:rpref "SELECT" option)

��

option �������� �������

ALL ����

ASK �����

!"

#$%&'���� �&(�����

(c:rpref "SELECT" "ASK")

TOGGLE— )*��

+,-./��0�

(c:rpref "TOGGLE" option setting)

��

option �������� �������

CACHE �12345�6789:/;<89=>8?

@A�2345BCD&EFG/��HCDIJKLM

NOPQ/OR�

SHADOW STU��

SMOOTH VWXY��

MERGE '��Z[ \]�

FINISH ^&_`�

SKIPRDLG -a�b�c�de�

setting ������)*/fg�setting /����bONch

bOFFc�

!"

#$%&*i\]�0]j)TU�0�

(c:rpref "TOGGLE" "MERGE" "OFF")(c:rpref "TOGGLE" "SMOOTH" "ON")

Page 406: AutoLisp Reference

406 | ������

saveimg

(c:saveimg filename type [portion] [xoff yoff xsize ysize] [compression])

� AutoCAD ��� ������portion ������������� !"#$%�&' TGA # TIFF ()�*����+,-.�

��

saveimg ��/01234

56

26�() test.tif 789: TIFF ���;()�+,4

(c:saveimg "TEST" "TIF" "NONE")

<� �=78> BMP?TGA @ TIFF A. ()BC����4render ARX D�EFG

SAVEIMG H���

�� �IJK /0 LMN

filename STR ��() OP Q

type STR ()JK4BMP?TGAR@RTIFF Q

portion STR S78 :TUV4A— WX��D—Y�UVF—9:

Z[ \��]^�_`�ab'cdefg hijk�lmn�

"A"

xoff INT X $%C��op�qrG 0

yoff INT Y $%C��op�qrG 0

xsize INT X stC��op�qrG uv X st

ysize INT Y stC��op�qrG uv Y st

compression STR +,w4NONEC�+,GPACKCxy�'RTIFFR()GRLECxy�'RTGAR()G

Q

Page 407: AutoLisp Reference

scene | 407

scene

(c:scene mode [options])

��

mode �������

D � �����

L ���������������������

M �������

N !"��

R #$%�����

S &'()��

options ��*+,��� mode-

D—� ��

� �����-

(c:scene "D" name)

��

name ������.� ����%/-

01� ���2()���34*5 *678()��-

9:

(c:scene "D" "PLANVIEW")

L— ����

���������������������-

(c:scene "L" [name])

��

name ������.������%/-01 name ��;<=�3 c:scene ������������-

>?@A,�BCDE !"������� �����>FG���render ARX HAIJE

Page 408: AutoLisp Reference

408 | ������

��

� name ��c:scene ��� �����

��

������������ ����

��� (c:scene "L") ("" "SCENE1" "SCENE2" "SCENE3")

� !" ("") #$%& �'*( *)�* �+,-./0�

��1234��� �����

��� (c:scene "L" "SCENE2")(T T) ("VIEW1" nil)("VIEW2" ("LIGHT1" "LIGHT2"))

M—/0 �

/056� ��

(c:scene "M" name [view [lights]])

'/0)78�9:;'<=)78�9:>?�@A'/0)78��BCD

E2 view FGH nil�IJK/0LM�

NO PQK�RSLM�TUVW lights E2FGH�#�

�����34/0�H SCENE1 � ��QXQ4��Y� FRONT Z����[6LM�

(c:scene "M" "SCENE1" "FRONT" (C:LIGHT "L"))

��34/0 � SCENE1�QXQ4��Y� BACK C\LM P1 Z P2�

(c:scene "M" "SCENE1" "BACK" ’("P1" "P2"))

N—<= �

]=< ��

(c:scene "N" name [view [lights]])

E2

name !"��< �����

view !"�� AutoCAD ��Y�^_!` T��'*ab*)Y��

Page 409: AutoLisp Reference

scene | 409

lights lights ��������

� �� �����������

� � T��������*� *!���� Nil���"���������

#$

�%&'() DEFAULT��*���*+, *!-�.�*� *!���/��

012�3��

(c:scene "N" "DEFAULT")

�%&'() DULL��*���*+, *!-�.45���6789!�/��

013��

(c:scene "N" "DULL" T nil)

�%&'() SPECIAL��*��:�-� MY_VIEW ;<�� SUN=LAMP . SPOT�/��012�3��

(c:scene "N" "SPECIAL" "MY_VIEW" ’("SUN" "LAMP "SPOT"))

R—>:�()

>:�?��()�

(c:scene "R" old_name new_name)

��

old_name ����@()��A�

new_name ����()�'�A�

#$

B()��AC�SPECIAL!D��BRIGHT!�

(c:scene "R" "SPECIAL" "BRIGHT")

S—EF()

EF+,()�

(c:scene "S" [name])

��

old_name �����F�+,�()��A�

GH�

0IJK name ���L c:scene GH+,M�()��A�

Page 410: AutoLisp Reference

410 | ������

��

�� �������

��� (c:scene "S")"PLAN"

���������� c:scene ������ ("")

!" SCENE3 #$�����%&'�()*+'�

(c:scene "S" "SCENE3")

setuv

(c:setuv mode options)

SETUV ��',- �./0�123456

7*

mode �89$�

A - :;0� UV 34

D < :;=> UV34

options �89?,0�� mode

A—0�

@AAB0�CDE',0�34�56

- �./0�123456�F)*�GHDE�I���7*0�B�����render ARX J'KLC

Page 411: AutoLisp Reference

setuv | 411

��

���������� ������� ���� ���� ����

�����

SETUV— �A���� ����

�� ���� �� � !

ssname PICKSET "#$%&� '(� )�*+, -

mapping type STR ��� ����P—./��D—01/��F—2/��

-

pt1, pt2, pt3 LIST &3� 45 6�78�./��—9�:;<�:=9>:01/��—?/0@;A/0@=BCDE2/��—2@;FG=BCDE

-

rep INT HI.J�0—K.JLMNO1—.JLPQ RO

1

scale LIST (of reals)

U = V STUV (1.0 1.0)

offset LIST (of reals)

U = V WX (0.0 0.0)

Page 412: AutoLisp Reference

412 | ������

���� �������������� ������ UVW ���� !"#�����$%&'()

*

&'+�,���-�.��/��012���� 34�56789:�;

<� =>?)

(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—@A

BDCD@AEFGH�.IJ��/K@A UV ��#LM�/N4�9:����� OP��Q�����RS#

��

ssname �.I T�U@A������/

*

&',�VW�-��U@A������X)

(c:setuv "D" (ssget))

showmat

(c:showmat arg1)

SETUV— BAC��FG��

�� �YZ[ $% 9:\

ssname PICKSET T]U��������X��.I ^

mapping type STR R— ^

pt1 LIST _��� ^

pt1 LIST ��`U`a����� ^

pt1 LIST ��`V`a����� ^

pt1 LIST ��`W`a����� ^

bc���/�deZ[=fg�hD����)render ARX i�jkE

Page 413: AutoLisp Reference

solprof | 413

����������� arg1 �������

��

arg1 ��������� ACI ���� ���!��"#$�

solprof

(c:solprof args ...)

��

args ���%&��'�()*+,-./ SOLPROF 012�34567�8����-� SOLPROF�

stats

(c:stats [filename |nil])

STATS *+9:;<=>%?@�AB56�

��

filename | nil "#$CD�9:EF?@56�GH�I nilC��JE

FAB56�KLMNGH�CO c:stats P�QAB56RSTU�

VW

KX*+Y=>%?@�56Z/ figures.txt GH[

(c:stats "figures.txt")

KLGH\]F^COAB56_�`aGHbc�

KX*+Y=>%?@�1d56EFa stats.txt GH-CeYfg�?@�1d56EFa�GH[

(c:stats "stats.txt")

KX*+JEFAB56[

(c:stats nil)

hijklm�no�pqrs�t[solids ARX u9v&w

P�=>%?@�AB56qrs�t[render ARX u9v&w

Page 414: AutoLisp Reference

414 | ������