3 A u t o C A D L AY E R L I N E T Y P E O S N A P S T Y L E X R E F - AutoLISP Object ARX A u t o C A D D C L A u t o C A D A u t o d e s k P D B D C L P D B D C L D C L 3.1 Wi n d o w s A u t o C A D 3-1 D C L 3-1 A u t o L I S P 3-3-1 2 3-1 // Filename: AP-03-01.dcl hello: dialog { label = "Hello, World"; : text { label = "Hello, World."; o k _ o n l y ; 3-2 ;;; Filename: AP-03-02.lsp (defun c:hello (/ dcl_id (setq dcl_id (load_dialog "ap-03-01.dcl" (if (not (new_dialog "hello" dcl_id (exit ; DCL
3 41 ( s t a r t _ d i a l o g ( p r i n c 3-2 3-2 O K h e l l o 3-3 3-3 ;;; Filename: AP-03-03.lsp (defun c:hello (/ dcl_id (setq dcl_id (ap-load-dialog "ap-03-01.dcl" ; DCL (if (not (ap-new-dialog "hello" dcl_id (exit (action_tile "accept" "(ap-done-dialog 1" ( s t a r t _ d i a l o g ( p r i n c
42 Visual LISP a p - l o a d - d i a l o g A P - A P I l o a d - d i a l o g D C L a p - n e w - d i a l o g a p - d o n e - d i a l o g d c l _ i d a p - n e w - d i a l o g n e w - d i a l o g a p - d o n e - d i a l o g d o n e - d i a l o g S h i f t 3.2 3-3 A P - A P I 3-4 3-3 D C L A u t o L I S P 3-5 // Filename: AP-03-04.dcl commit: dialog { label = "You Should be Commited"; : edit_box { label = "&First"; key = "first"; edit_width = 20; : edit_box { label = "&Second"; key = "second"; edit_width = 20; o k _ c a n c e l ; 3-4
3 43 ;;; Filename: AP-03-05.lsp 3-5 (defun c:commit (/ dcl_id defaults params saved_params what_next (setq defaults '((first. "" (second. "" (setq params (mapcar 'car defaults (setq dcl_id (ap-load-dialog "ap-03-04.dcl" (ap-init-vars defaults (setq saved_params (ap-save-vars params (if (not (ap-new-dialog "commit" dcl_id ( e x i t (ap-set-tiles params (ap-action-tiles params "callback_" (action_tile "accept" "(ap-done-dialog 1" (setq what_next (start_dialog (cond ((= 0 what_next (ap-reset-vars saved_params (princ "Cancelled" ; DCL ; a c c e p t ; C a n c e l ((= 1 what_next ; O K (princ "Parameters saved" ( p r i n c (defun callback_first (key value (set (read key value (defun callback_second (key value (set (read key value callback_first c a l l b a c k _ s e c o n d f i r s t s e c o n d p a r a m s A u t o L I S P a p - i n i t - v a r s A P - A P I n u l l a p - s a v e - v a r s a p - s e t - t i l e s A P - A P I A u t o L I S P f i r s t s e c o n d f i r s t s e c o n d AP-API AutoLISP a p - a c t i o n - t i l e s f i r s t c a l l b a c k _ f i r s t second callback_ second a p - r e s e t - v a r s a p - s a v e - p a r a m s
44 Visual LISP a p - a c t i o n - t i l e s 3.3 3-6 3-4 D C L A u t o L I S P 3-7 3-4 3-6 // Filename: AP-03-06.dcl nested : dialog { label = "Nested Dialog Boxes"; : row { : button { label = "&First"; key = "nested_1"; width = 15; : text { label = ""; key = "first"; width = 20; : row { : button { label = "&Second"; key = "nested_2"; width = 15; : text { label = ""; key = "second"; width = 20; o k _ c a n c e l ; nested_1 : dialog { label = "Nested Dialog Boxes"; : edit_box { label = "&First"; key = "first"; edit_width = 20; o k _ c a n c e l ; nested_2 : dialog { label = "Nested Dialog Boxes"; : edit_box { label = "&Second"; key = "second"; edit_width = 20; o k _ c a n c e l ;
3 45 3-7 ;;; Filename: AP-03-07.lsp (defun c:nested (/ dcl_id what_next nest_buttons defaults params (setq dcl_id (ap-load-dialog "ap-03-06.dcl" (setq defaults '((first. "" (second. "" (setq params (mapcar 'car defaults (setq nest_buttons '("nested_1" "nested_2" (ap-init-vars defaults (setq what_next (nest "nested" dcl_id params nest_buttons (if (= what_next 1 (princ "\nbingo!" ( p r i n c (defun callback_first (key value (set (read key value (defun callback_second (key value (set (read key value (defun nest (dcl_name dcl_id params nest_buttons / what_next s a v e d _ p a r a m s (setq saved_params (ap-save-vars params (if (not (ap-new-dialog dcl_name dcl_id ( e x i t (ap-set-tiles params (ap-action-tiles params "callback_" (nesting-buttons nest_buttons (action_tile "accept" "(ap-done-dialog 1" ; O K (setq what_next (start_dialog (if (= 0 what_next ; C a n c e l (ap-reset-vars saved_params w h a t _ n e x t (defun nesting-buttons (buttons (foreach button buttons ( a c t i o n _ t i l e b u t t o n (strcat "(nest $key dcl_id params nest_buttons" "(ap-set-tiles params"
46 Visual LISP D C L A u t o L I S P 3.4 A u t o C A D A u t o C A D A P - A P I 3-8 3-5 D C L A u t o L I S P 3-9 3-8 // Filename: AP-03-08.dcl hidebox: dialog { label = "Nowhere to Hide"; : row { : button {key = "select"; label = "< &Select"; : text { key = "selected"; width = 10; o k _ o n l y ; 3-5 3-9 ;;; Filename: AP-03-09.lsp (defun c:hidebox (/ dcl_id what_next ss1 (setq dcl_id (ap-load-dialog "ap-03-08.dcl" ; D C L (setq what_next 999 (while (> what_next 1 (if (not (ap-new-dialog "hidebox" dcl_id (exit (set_tile "selected" (strcat (itoa (ap-sslength ss1 " selected." (action_tile "accept" "(ap-done-dialog 1" (action_tile "select" "(ap-done-dialog 2" (setq what_next (start_dialog (cond ((= 2 what_next (setq ss1 nil (setq ss1 (ssget ; S e l e c t
3 47 ((= 1 what_next ; O K (princ "\nbingo!" ( p r i n c w h i l e S e l e c t s t a r t - d i a l o g 2 cond s t a r t - d i a l o g w h i l e O K C a n c e l B i n g o * e r r o r * E S C ; e r r o r Function cancel : 3.5 A P 3-10 3-6 D C L A u t o L I S P 3-11 3-6 // Filename: AP-03-10.dcl vslide: dialog { 3-10
48 Visual LISP label = "A Room with a View"; : image { key = "room"; aspect_ratio = 0.63; width = 50; border = 2; border_color = -18; background = 0; o k _ o n l y ; 3-11 ;;; Filename: AP-03-11.lsp (defun c:viewslide (/ dcl_id (setq dcl_id (ap-load-dialog "ap-03-10.dcl" (if (not (ap-new-dialog "vslide" dcl_id ( e x i t (action_tile "accept" "(ap-done-dialog 1" (ap-vslide "room" "acad(escher" ; D C L ( s t a r t _ d i a l o g ( p r i n c a p - v s i d e A P - A P I r o o m a c a d e s c h e r A r t f u l D C L ( 3-6 border border _color b a c k g r o u n d b o r d e r b o r d e r = 0 border _color b a c k g r o u n d A u t o C A D A u t o C A D A C I 3-1 3-1 0 A u t o C A D V S I L D E - 1 5-1 6-1 8 D C L D C
3 49 A u t C A D 2000, Index s l i d e l i b 3.6 A r t f u l A r t f u l A u t o C A D A u t o C A D A r t f u l / N U L L / 3-7 A r t f u l A P - A P I 3-12 3-7 D C L A u t o L I S P 3-13 // Filename: AP-03-12.dcl getstrings : dialog { label = "What s Your Name?"; : spacer { height = 0.5; : edit_box { label = "&First"; key = "first_name"; edit_width = 20; tag = "First Name"; trim = true; : edit_box { label = "&Middle"; key = "middle_name"; edit_width = 20; tag = "Middle Name"; trim = true; null_ok = true; : edit_box { label = "&Last"; key = "last_name"; edit_width = 20; tag = "Last Name"; trim = true; spaces_ok = true; 3-12
50 Visual LISP : spacer { height = 0.5; o k _ c a n c e l _ e r r ; ;;; Filename: AP-03-13.lsp 3-13 (defun c:getstrings (/ dcl_id defaults params saved_params what_next ( s e t q defaults '((first_name. "" (middle_name. "" (last_name. "" (setq params (mapcar 'car defaults (setq dcl_id (ap-load-dialog "ap-03-12.dcl" (ap-init-vars defaults (setq saved_params (ap-save-vars params (if (not (ap-new-dialog "getstrings" dcl_id ( e x i t (ap-set-tiles params (ap-action-tiles params "callback_" ( a c t i o n _ t i l e " a c c e p t " "(ap-done-dialog-conditional \"callback_\" params 1" ; D C L ; a c c e p t (setq what_next (start_dialog (cond ((= 0 what_next (ap-reset-vars saved_params ; C a n c e l ((= 1 what_next ; O K (princ "\nbingo!" ( p r i n c (defun callback_first_name (key value (ap-callback-string key value (defun callback_middle_name (key value (ap-callback-string key value (defun callback_last_name (key value (ap-callback-string key value 3-7 first _ name, middle_ name, last_name
3 51 O K a p - d o n e - d i a l o g - c o n d i t i o n a l A P - A P I a p - a c t i o n - t i l e s n i l a p - d o n e - d i a l o g - c o n d i t i o n a l a p - d o n e - d i a l o g - c o n d i t i o n a l a p - d o n e - d i a l o g a p - d o n e - d i a l o g - c o n d i t i o n a l O K n i l n i nil a p - c a l l b a c k - s t r i n g A P - A P I a p - c a l l b a c k - s t r i n g 3-2 3-2 t a g t r i m n u l l _ o k s p a c e s _ o k 3-12 D C L a p - c a l l b a c k - s t r i n g 3-3 3-3 first _ name middle_ name l a s t _ n a m e ap-callback-string a p - c a l l b a c k - s t r i n g n i l a p - c a l l b a c k - s t r i n g
52 Visual LISP d e f a u l t s D C L 3.7 A r t f u l A r t f u l / N U L L / / A P - A P I 3-14 3-8 D C L A u t o L I S P 3-15 3-8 // Filename: AP-03-14.dcl getints : dialog { width = 45; label = "What s Your Integer?"; : spacer { height = 0.5; : edit_box { label = "&First"; key = "int1"; edit_width = 20; tag = "First Number"; : edit_box { label = "&Second"; key = "int2"; 3-14
3 53 edit_width = 20; tag = "Second Number"; null_ok = true; minus_ok = true; : edit_box { label = "&Third"; key = "int3"; edit_width = 20; tag = "Third Number"; zero_ok = true; : spacer { height = 0.5; o k _ c a n c e l _ e r r ; 3-15 ;;; Filename: AP-03-15.lsp (defun c:getints (/ dcl_id defaults params saved_params what_next (setq defaults '((int1 (int2. 0 (int3. -1 (setq params (mapcar 'car defaults (setq dcl_id (ap-load-dialog "ap-03-14.dcl" ; D C L (ap-init-vars defaults (setq saved_params (ap-save-vars params (if (not (ap-new-dialog "getints" dcl_id ( e x i t (ap-set-tiles params (ap-action-tiles params "callback_" ( a c t i o n _ t i l e ; a c c e p t " a c c e p t " "(ap-done-dialog-conditional \"callback_\" params 1" (setq what_next (start_dialog (cond ((= 0 what_next ; C a n c e l (ap-reset-vars saved_params ((= 1 what_next ; O K (princ "\nbingo!" ( p r i n c (defun callback_int1 (key value (ap-callback-int key value (defun callback_int2 (key value (ap-callback-int key value
54 Visual LISP (defun callback_int3 (key value (ap-callback-int key value 3-8 i n t 1 i n t 2 i n t 3 O K a p - s e t - t i l e s A P - A P I a p - c a l l b a c k - i n t A P - A P I 3-4 3-4 a p - c a l l b a c k - i n t t a g n u l l _ o k m i n u s _ o k z e r o _ o k 3-12 D C L a p - c a l l b a c k - i n t 3-5 3-5 i n t 1 i n t 2 i n t 3 ap-callback-string a p - c a l l b a c k - i n t n i l a p - c a l l b a c k - i n t n i l d e f a u l t s D C L
3 55 3.8 A r t f u l / N U L L / / A u t o L I S P A P - A P I 3-16 3-9 D C L A u t o L I S P 3-17 3-9 // Filename: AP-03-16.dcl getreals : dialog { width = 50; label = "What s Your Number?"; : spacer { height = 0.5; : edit_box { label = "&Real"; key = "real1"; edit_width = 20; tag = "Real"; units = 2; prec = 4; : edit_box { label = "&Distance"; key = "real2"; edit_width = 20; tag = "Distance"; 3-16
56 Visual LISP : edit_box { label = "&Angle"; key = "real3"; edit_width = 20; tag = "Angle"; is_angle = true; minus_ok = true; zero_ok = true; : spacer { height = 0.5; o k _ c a n c e l _ e r r ; 3-17 ;;; Filename: AP-03-17.lsp (defun c:getreals (/ dcl_id defaults params saved_params what_next (setq defaults '((real1. 0.0 (real2. 12.375 (real3. 0.523599 (setq params (mapcar 'car defaults (setq dcl_id (ap-load-dialog "ap-03-16.dcl" ; D C L (ap-init-vars defaults (setq saved_params (ap-save-vars params (if (not (ap-new-dialog "getreals" dcl_id ( e x i t (ap-set-tiles params (ap-action-tiles params "callback_" ( a c t i o n _ t i l e ; a c c e p t " a c c e p t " "(ap-done-dialog-conditional \"callback_\" params 1" (setq what_next (start_dialog (cond ((= 0 what_next ; C a n c e l (ap-reset-vars saved_params ((= 1 what_next ; O K (princ "\nbingo!" ( p r i n c (defun callback_real1 (key value (ap-callback-real key value (defun callback_real2 (key value (ap-callback-real key value (defun callback_real3 (key value (ap-callback-real key value
3 57 3-9 r e a l 1 r e a l 2 r e a l 3 O K ap-callback- real1 A P - A P I 3-6 a p - s e t - t i l e s is_angle u n i t s p r e c 3-6 ap-callback- real t a g n u l l _ o k m i n u s _ o k z e r o _ o k i s _ a n g l e u n i t s p r e c LUNITS A U N I T S L U P R E C A U P R E C 3-16 ap-callback- real r e a l 1 r e a l 2 r e a l 3 a p - c a l l b a c k - r e a l n i l d e f a u l t s D C L 3.9 A P - A P I 3-18 3-10 D C L A u t o L I S P 3-19 3-10
58 Visual LISP 3-18 // Filename: AP-03-18.dcl toggles : dialog { label = "Pick Your Seat"; : spacer { height = 0.5; : toggle { label = "&Enable Seat Picking"; key = "toggle1"; : boxed_radio_row { label = "Seat"; key = "radio1"; buttons = "orchestra loge balcony"; : radio_button { key = "radio1_orchestra"; label = "&Orchestra"; : radio_button { key = "radio1_loge"; label = "&Loge"; : radio_button { key = "radio1_balcony"; label = "&Balcony"; : spacer { height = 0.5; o k _ c a n c e l ; 3-19 ;;; Filename: AP-03-19.lsp (defun c:toggles (/ dcl_id defaults params saved_params what_next (setq defaults '((toggle1. "1" (radio1 (setq params (mapcar 'car defaults (setq dcl_id (ap-load-dialog "ap-03-18.dcl" ; D C L (ap-init-vars defaults (setq saved_params (ap-save-vars params (if (not (ap-new-dialog "toggles" dcl_id ( e x i t (ap-set-tiles params ( e n a b l e _ r a d i o 1 (ap-action-tiles params "callback_" ( a c t i o n _ t i l e ; a c c e p t " a c c e p t "
3 59 "(ap-done-dialog-conditional \"callback_\" params 1" (setq what_next (start_dialog (cond ((= 0 what_next ; C a n c e l (ap-reset-vars saved_params ((= 1 what_next ; O K (princ "\nbingo!" ( p r i n c (defun callback_toggle1 (key value (ap-callback-toggle key value ( e n a b l e _ r a d i o 1 (defun callback_radio1 (key value (ap-callback-radio key value (defun enable_radio1 ( (mode_tile "radio1" (- 1 (atoi toggle1 t o g g l e 1 3-10 t o g g l e 1 r a d i o 1 a p - c a l l b a c k - r a d i o A P - A P I 3-7 3-7 a p - c a l l b a c k - r a d i o b u t t o n k e y "v a l u e 1 v a l u e 2 v a l u e 3" v a r n a m e _ v a l u e varname v a l u e v a r n a m e a p - c a l l b a c k - t o g g l e A P - A P I 1 0 a p - s e t - t i l e s A P - A P I To g g l e 1 1 a p - c a l l b a c k - r a d i o A P - A P I a p - s e t - t i l e s r a d i o 1 n i l a p - s e t - t i l e s
60 Visual LISP 3-18 D C L ap- callback -radio radio1_orchestra radio1 o r c h e s t r a radio1_loge radio1 l o g e radio1_ balcony radio1 b a l c o n y c a l l b a c k - t o g g l e 1 r a d i o / a p - d o n e - d i a l o g - c o n d t i o n a l n i l d e f a u l t s D C L 3.10 A P - A P I 3-20 3-11 D C L A u t o L I S P 3-21 3-11 // Filename: AP-03-20.dcl lists : dialog { label = "Pick Your List"; : spacer { height = 0.5; : popup_list { key = "list1"; label = "&Length Units"; is_list = true; : row { 3-20
3 61 width = 35; : list_box { key = "list2"; label = "L&anguage"; height = 6; is_list = true; sort = true; : list_box { key = "list3"; label = "&Shopping"; height = 6; is_list = true; multiple_select = true; : spacer { height = 0.5; o k _ c a n c e l ; 3-21 ;;; Filename: AP-03-21.lsp (defun c:lists (/ dcl_id defaults params saved_params what_next (setq defaults '((list1 (list2 (list3 (setq params (mapcar 'car defaults (setq list1_values '((1. "Scientific" (2. "Decimal" (3. "Engineering" (4. "Architectural" (5. "Fractional" (setq list2_values '("APL" "FORTRAN" "BASIC" "AutoLISP" "C++" (setq list3_values '("Fruits" "Vegetables" "Cereals" "Breads" "Cookies" "Potato Chips" (setq dcl_id (ap-load-dialog "ap-03-20.dcl" ; D C L (ap-init-vars defaults (setq list1 (list (getvar "lunits" ; l i s t 1 (setq saved_params (ap-save-vars params (if (not (ap-new-dialog "lists" dcl_id ( e x i t (ap-set-tiles params
62 Visual LISP (ap-action-tiles params "callback_" ( a c t i o n _ t i l e ; a c c e p t " a c c e p t " "(ap-done-dialog-conditional \"callback_\" params 1" (setq what_next (start_dialog (cond ((= 0 what_next ; C a n c e l (ap-reset-vars saved_params ((= 1 what_next ; O K (princ "\nbingo!" (setvar "lunits" (car list1 ; lunits ( p r i n c (defun callback_list1 (key value (ap-callback-list key value (defun callback_list2 (key value (ap-callback-list key value (defun callback_list3 (key value (ap-callback-list key value 3-11 l i s t 1 list 2 list 3 C a r C d r l i s t 1 _ v a l u e l i s t 1 l i s t 2 _ v a l u e l i s t 2 l i s t 3 _ v a l u e l i s t 3 l i s t 1 1-5 l i s t 1 _ v a l u e C a r (setq list1 (list (getvar "lunits" l i s t 1 L U N I T S a p - s e t - t i l e l i s t 3-8
3 63 3-8 ap-callback- list t a g i s _ l i s t s o r t m u l t i p l e _ s e l e c t 3-20 a p - s e t - t i l e l i s t 2 ap-callback- list (setvar "lunits" (car list1 L U N I T S l i s t 1 d e f a u l t s D C L A P - A P I A u t o L I S P O K