Hello All,
I have a simple code that creates blocks by selecting from a popup list and set it scale the same way before its inserted. The program then loops back to it main page for another selection. The problem is the selection always returns to the top of the list rather then remembering the last selection. I have tried with radio buttons, toggles, and edit boxes and have had success with those, But never could figure out how to do this with the popup list. I would appreciate any help with this that anyone can offer.
Thanks in advance and hope someone can shed some light on this.
The Buzzard
DCL CODE
Code:
///////////////////////////////////////////////////////////////////////////////////////
sl : dialog {
label = "Symbols Library";
: boxed_column {
label = "Symbol Image";
: image {
key = "im1";
height = 7.66;
fixed_height = true;
width = 27.92;
fixed_width = true;
alignment = centered;
color = 0;
}
: spacer {
height = 0;
}
}
: boxed_column {
label = "Symbols List";
: popup_list {
key = "pl1";
value = 0;
}
: spacer {
height = 0;
}
}
: boxed_column {
label = "Drawing Scale";
: popup_list {
key = "ds1";
value = 13;
}
: spacer {
height = 0;
}
}
: boxed_column {
label = "Control Buttons";
: button {
label = "Insert";
key = "accept";
mnemonic = "I";
is_default = true;
}
: button {
label = "Cancel";
key = "cancel";
mnemonic = "C";
is_cancel = true;
}
: spacer {
height = 0;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////
LSP CODE
Code:
;;;////////////////////////////////////////////////////////////////////////////////////
;;; 01 - Start-Up Function - Program Start.
(defun C:SL ()
(SL_SS)
(princ)
)
(princ "\nSymbols Library Lisp, SL.lsp Loaded....")
(princ "\nType SL to start program.")
;;;/////////////////////////////////////////////////////////////////
;;; 02 - Font Function - Font Style.
(defun SL_FS ()
(command "_.STYLE" "Romans" "romans.shx" "0.0" "1.0" "0" "N" "N" "N")
)
;;;/////////////////////////////////////////////////////////////////
;;; 03 - Layer Function - Create Layer.
(defun SL_CL (NLAY CLR LT / LAY FRZ)
(setq LAY (tblsearch "layer" NLAY))
(if (not LAY)
(command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "")
(progn
(setq FRZ (cdr (assoc 70 LAY)))
(if (= FRZ 65)
(progn
(command "_.layer" "t" NLAY "")
(command "_.layer" "s" NLAY ""))
(command "_.layer" "s" NLAY ""))))
)
;;;/////////////////////////////////////////////////////////////////
;;; 04 - Layer Function - Layer Set.
(defun SL_LS ()
(SL_CL "TEXT" "2" "")
(progn
(cond
((= SYM "TRI")(SL_CL "TRIANGLE" "1" ""))
((= SYM "SQR")(SL_CL "SQUARE" "1" ""))
((= SYM "CIR")(SL_CL "CIRCLE" "1" ""))))
)
;;;/////////////////////////////////////////////////////////////////
;;; 05 - Image Function - Show Image.
(defun SL_SI ()
(setq w (dimx_tile "im1")
h (dimy_tile "im1"))
(start_image "im1")
(fill_image 0 0 w h -15)
(cond
((= IMG "0")
(mapcar 'vector_image
(list 80 23 136 80)
(list 1 99 99 1)
(list 23 136 80 80)
(list 99 99 1 1)
(list 1 1 1 1)
))
((= IMG "1")
(mapcar 'vector_image
(list 30 30 127 127 30)
(list 1 98 98 1 1)
(list 30 127 127 30 30)
(list 98 98 1 1 1)
(list 1 1 1 1 1)
))
((= IMG "2")
(mapcar 'vector_image
(list 129 129 129 128 128 127 125 124 122 121
119 117 114 112 109 106 103 101 97 94
91 88 85 81 78 75 72 68 65 62
59 56 54 51 49 46 44 42 40 39
37 36 35 34 34 33 33 33 34 34
35 36 37 39 40 42 44 46 49 51
54 56 59 62 65 68 72 75 78 81
85 88 91 94 97 101 103 106 109 112
114 117 119 121 122 124 125 127 128 128
129 129 129)
(list 49 46 43 40 36 33 30 27 24 22
19 17 14 12 10 8 7 5 4 3
2 2 1 1 1 2 2 3 4 5
7 8 10 12 14 17 19 22 24 27
30 33 36 40 43 46 49 53 56 59
62 66 69 72 74 77 80 82 85 87
89 90 92 94 95 96 96 97 97 98
97 97 96 96 95 94 92 90 89 87
85 82 80 77 74 72 69 66 62 59
56 53 49)
(list 129 129 128 128 127 125 124 122 121 119
117 114 112 109 106 103 101 97 94 91
88 85 81 78 75 72 68 65 62 59
56 54 51 49 46 44 42 40 39 37
36 35 34 34 33 33 33 34 34 35
36 37 39 40 42 44 46 49 51 54
56 59 62 65 68 72 75 78 81 85
88 91 94 97 101 103 106 109 112 114
117 119 121 122 124 125 127 128 128 129
129 129 129)
(list 46 43 40 36 33 30 27 24 22 19
17 14 12 10 8 7 5 4 3 2
2 1 1 1 2 2 3 4 5 7
8 10 12 14 17 19 22 24 27 30
33 36 40 43 46 49 53 56 59 62
66 69 72 74 77 80 82 85 87 89
90 92 94 95 96 96 97 97 98 97
97 96 96 95 94 92 90 89 87 85
82 80 77 74 72 69 66 62 59 56
53 49 49)
(list 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1)
))
)
(end_image)
)
;;;/////////////////////////////////////////////////////////////////
;;; 06 - Scale Function - Drawing Scale.
(defun SL_DS ()
(progn
(setq DSF (fix DSF))
(setq DSF (nth DSF ds_list))
(cond
((= DSF "1/32\" = 1'") (setq DSF 384))
((= DSF "1/16\" = 1'") (setq DSF 192))
((= DSF "3/32\" = 1'") (setq DSF 128))
((= DSF "1/8\" = 1'") (setq DSF 96))
((= DSF "3/16\" = 1'") (setq DSF 64))
((= DSF "1/4\" = 1'") (setq DSF 48))
((= DSF "3/8\" = 1'") (setq DSF 32))
((= DSF "1/2\" = 1'") (setq DSF 24))
((= DSF "3/4\" = 1'") (setq DSF 16))
((= DSF "1\" = 1'") (setq DSF 12))
((= DSF "1-1/2\" = 1'")(setq DSF 8))
((= DSF "3\" = 1'") (setq DSF 4))
((= DSF "6\" = 1'") (setq DSF 2))
((= DSF "1' = 1'") (setq DSF 1))
((= DSF "1\" = 10'") (setq DSF 120))
((= DSF "1\" = 20'") (setq DSF 240))
((= DSF "1\" = 30'") (setq DSF 360))
((= DSF "1\" = 40'") (setq DSF 480))
((= DSF "1\" = 50'") (setq DSF 600))
((= DSF "1\" = 60'") (setq DSF 720))
((= DSF "1\" = 70'") (setq DSF 840))
((= DSF "1\" = 80'") (setq DSF 960))
((= DSF "1\" = 90'") (setq DSF 1080))
((= DSF "1\" = 100'") (setq DSF 1200))))
)
;;;/////////////////////////////////////////////////////////////////
;;; 07 - Main Function - Symbol Select.
(defun SL_SS ()
(setq IMG "0")
(setq DSF 1)
(setq sl_list '("Triangle" "Square" "Circle"))
(setq ds_list '("1/32\" = 1'" "1/16\" = 1'" "3/32\" = 1'" "1/8\" = 1'" "3/16\" = 1'" "1/4\" = 1'"
"3/8\" = 1'" "1/2\" = 1'" "3/4\" = 1'" "1\" = 1'" "1-1/2\" = 1'" "3\" = 1'"
"6\" = 1'" "1' = 1'" "1\" = 10'" "1\" = 20'" "1\" = 30'" "1\" = 40'"
"1\" = 50'" "1\" = 60'" "1\" = 70'" "1\" = 80'" "1\" = 90'" "1\" = 100'"))
(setq dcl_id (load_dialog "sl.dcl"))
(if (not (new_dialog "sl" dcl_id))
(exit))
(start_list "pl1")
(mapcar 'add_list sl_list)
(end_list)
(start_list "ds1")
(mapcar 'add_list ds_list)
(end_list)
(SL_SI)
(action_tile "pl1" "(setq IMG $value)(itoa 0)(SL_SI)")
(action_tile "cancel" "(done_dialog)(setq button nil)")
(action_tile "accept"
(strcat
"(progn
(setq SYM (atof (get_tile \"pl1\")))"
"(setq DSF (atof (get_tile \"ds1\")))"
"(done_dialog)(setq button T))"))
(start_dialog)
(unload_dialog dcl_id)
(if button
(progn
(setq SYM (fix SYM))
(setq SYM (nth SYM sl_list))
(cond
((= SYM "Triangle")(setq SYM "TRI")(SL_IS))
((= SYM "Square") (setq SYM "SQR")(SL_IS))
((= SYM "Circle") (setq SYM "CIR")(SL_IS)))))
(princ)
)
;;;/////////////////////////////////////////////////////////////////
;;; 08 - Output Function - Insert Symbol.
(defun SL_IS ()
(SL_FS)
(SL_LS)
(SL_DS)
(if (null (tblsearch "block" SYM))
(cond
((= SYM "TRI")(SL_TRI))
((= SYM "SQR")(SL_SQR))
((= SYM "CIR")(SL_CIR))))
(setq inpt (getpoint "\nInsertion point:"))
(command "_.insert" SYM inpt DSF DSF pause)
(SL_SS)
)
;;;/////////////////////////////////////////////////////////////////
;;; 09 - Block Reference Function - Triangle Block Reference.
(defun SL_TRI ()
(entmake '((0 . "block")(2 . "TRI")(10 0.0 0.0 0.0)(70 . 2)))
(entmake '((0 . "ATTDEF")(5 . "307")(100 . "AcDbEntity")(67 . 0)(410 . "Model")(8 . "TEXT")(100 . "AcDbText")
(10 -0.158482 0.548598 0.0)(40 . 0.09375)(1 . "TEXT")(50 . 0.0)(41 . 1.0)(51 . 0.0)(7 . "Romans")
(71 . 0)(72 . 1)(11 0.0 0.517348 0.0)(210 0.0 0.0 1.0)(100 . "AcDbAttributeDefinition")(3 . "Text:")
(2 . "TEXT")(70 . 8)(73 . 0)(74 . 1)))
(entmake '((0 . "LWPOLYLINE")(5 . "289")(100 . "AcDbEntity")(67 . 0)(410 . "Model")(8 . "0")(100 . "AcDbPolyline")
(90 . 3)(70 . 1)(43 . 0.0)(38 . 0.0)(39 . 0.0)(10 8.68009e-017 0.431864)(40 . 0.0)(41 . 0.0)(42 . 0.0)
(10 -0.249337 1.11022e-016)(40 . 0.0)(41 . 0.0)(42 . 0.0)(10 0.249337 -1.11022e-016)(40 . 0.0)(41 . 0.0)
(42 . 0.0)(210 0.0 0.0 1.0)))
(entmake '((0 . "endblk")))
)
;;;/////////////////////////////////////////////////////////////////
;;; 10 - Block Reference Function - Square Block Reference.
(defun SL_SQR ()
(entmake '((0 . "block")(2 . "SQR")(10 0.0 0.0 0.0)(70 . 2)))
(entmake '((0 . "ATTDEF")(5 . "307")(100 . "AcDbEntity")(67 . 0)(410 . "Model")(8 . "TEXT")(100 . "AcDbText")
(10 -0.158482 0.548598 0.0)(40 . 0.09375)(1 . "TEXT")(50 . 0.0)(41 . 1.0)(51 . 0.0)(7 . "Romans")
(71 . 0)(72 . 1)(11 0.0 0.517348 0.0)(210 0.0 0.0 1.0)(100 . "AcDbAttributeDefinition")(3 . "Text:")
(2 . "TEXT")(70 . 8)(73 . 0)(74 . 1)))
(entmake '((0 . "LWPOLYLINE")(5 . "28A")(100 . "AcDbEntity")(67 . 0)(410 . "Model")(8 . "0")(100 . "AcDbPolyline")
(90 . 4)(70 . 1)(43 . 0.0)(38 . 0.0)(39 . 0.0)(10 -0.25 0.5)(40 . 0.0)(41 . 0.0)(42 . 0.0)
(10 -0.25 2.77556e-017)(40 . 0.0)(41 . 0.0)(42 . 0.0)(10 0.25 -5.55112e-017)(40 . 0.0)(41 . 0.0)
(42 . 0.0)(10 0.25 0.5)(40 . 0.0)(41 . 0.0)(42 . 0.0)(210 0.0 0.0 1.0)))
(entmake '((0 . "endblk")))
)
;;;/////////////////////////////////////////////////////////////////
;;; 11 - Block Reference Function - Circle Block Reference.
(defun SL_CIR ()
(entmake '((0 . "block")(2 . "CIR")(10 0.0 0.0 0.0)(70 . 2)))
(entmake '((0 . "ATTDEF")(5 . "307")(100 . "AcDbEntity")(67 . 0)(410 . "Model")(8 . "TEXT")(100 . "AcDbText")
(10 -0.158482 0.548598 0.0)(40 . 0.09375)(1 . "TEXT")(50 . 0.0)(41 . 1.0)(51 . 0.0)(7 . "Romans")
(71 . 0)(72 . 1)(11 0.0 0.517348 0.0)(210 0.0 0.0 1.0)(100 . "AcDbAttributeDefinition")(3 . "Text:")
(2 . "TEXT")(70 . 8)(73 . 0)(74 . 1)))
(entmake '((0 . "CIRCLE")(5 . "2E9")(100 . "AcDbEntity")(67 . 0)(410 . "Model")(8 . "0")(100 . "AcDbCircle")
(10 0.0 -1.38778e-017 0.0)(40 . 0.25)(210 0.0 0.0 1.0)))
(entmake '((0 . "endblk")))
)
;;;/////////////////////////////////////////////////////////////////
Bookmarks