Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Dialog woes
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Dialog woes (Read 1576 times)
0 Members and 1 Guest are viewing this topic.
CincyJeff
Newt
Posts: 89
Dialog woes
«
on:
October 13, 2015, 10:27:49 AM »
I'm trying to create a routine that will scan the drawing for blocks on a certain layer that have visibility states. It will then display the name of each block with the current visibility state in a pop-up list. The user will then be able to change the visibility state for each block using the available options in each pop-up list. Since I don't know how many blocks there may be I create the dialog on the fly. I've taken the basic code shown below from Lee Mac's MASK routine. Thanks Lee. The temporary dialog file is created and loads fine. It also allows me to change the pop-up list for each block. However, I cannot get the value of each pop-up list on close. I've even stopped the program before the dialog is unloaded and before the temporary file is deleted and I still cannot use get_tile to retrieve the pop-up list values. If the dialog closes with OK, dlgval will be 1 so the if statement in the code will run to create symbols line1, line2, etc... for each block. The symbol arglst is a list of visibility states for each block, e.g. ((vis1 vis2) (vis1 vis2 vis3) ...). The commented out action_tile code also does not work. Any ideas?
Code - Auto/Visual Lisp:
[Select]
(
defun
DSET:RUNDIALOG
(
/
cntr dlgid dlgval file filename
)
(
cond
(
(
null
(
and
(
setq
filename
(
vl-filename-mktemp
nil
nil
".dcl"
)
)
(
setq
file
(
open
filename
"w"
)
)
(
progn
(
foreach
line
(
append
'
(
"MainDetailSet : dialog {"
"label =
\"
Detail Set
\"
;"
)
(
DSET:DLGLINES
)
'
(
"ok_cancel;"
"}"
)
)
;_ end of append
(
write-line
line file
)
)
;_ end of foreach
(
setq
file
(
close
file
)
)
(
<
0
(
setq
dlgid
(
load_dialog
filename
)
)
)
)
;_ end of progn
)
;_ end of and
)
;_ end of null
(
princ
"
\n
Unable to Load Dialog."
)
)
(
t
(
while
(
not
(
member
dlgval '
(
0
1
)
)
)
(
cond
(
(
null
(
new_dialog
"MainDetailSet"
dlgid
)
)
(
princ
"
\n
Cannot find Detail Set Dialog Definition."
)
(
setq
dlgval
0
)
)
(
t
(
setq
cntr
1
)
(
foreach
item arglst
(
set
(
read
(
strcat
"t:lst"
(
itoa
cntr
)
)
)
(
nth
(
1-
cntr
)
arglst
)
)
;_ end of set
(
start_list
(
strcat
"t:line"
(
itoa
cntr
)
)
3
)
(
mapcar
'
add_list
(
vl-symbol-value
(
read
(
strcat
"t:lst"
(
itoa
cntr
)
)
)
)
)
;_ end of mapcar
(
end_list
)
(
set_tile
(
strcat
"t:line"
(
itoa
cntr
)
)
(
car
(
nth
(
1-
cntr
)
arglst
)
)
)
;_ end of set_tile
;;; (action_tile
;;; (strcat "t:line" (itoa cntr))
;;; "(set (read (strcat \"line\" (itoa cntr)))
;;; (get_tile (strcat \"t:line\" (itoa cntr)))
;;; )" ;_ end of set
;;; ) ;_ end of action_tile
(
setq
cntr
(
1+
cntr
)
)
)
;_ end of foreach
(
setq
dlgval
(
start_dialog
)
)
)
)
;_ end of cond
)
;_ end of while
)
)
;_ end of cond
(
if
(
=
1
dlgval
)
(
progn
(
setq
cntr
1
)
(
while
(
<=
cntr
(
length
arglst
)
)
(
set
(
read
(
strcat
"line"
(
itoa
cntr
)
)
)
(
get_tile
(
strcat
"t:line"
(
itoa
cntr
)
)
)
)
;_ end of set
(
setq
cntr
(
1+
cntr
)
)
)
;_ end of while
(
setq
dlgid
(
unload_dialog
dlgid
)
)
)
;_ end of progn
)
;_ end of if
(
if
(
<
0
dlgid
)
(
setq
dlgid
(
unload_dialog
dlgid
)
)
)
;_ end of if
(
if
(
and
filename
(
findfile
filename
)
)
(
vl-file-delete
filename
)
)
;_ end of if
(
UTIL:RESETDEBUG
)
)
;_ end of defun - DSET:RUNDIALOG
(
defun
DSET:DLGLINES
(
/
cntr dlgline
)
(
setq
cntr
1
)
(
foreach
item blklst
(
setq
dlgline
(
append
dlgline
(
list
": row {"
": text {"
(
strcat
"label =
\"
"
(
car
item
)
"
\"
;"
)
"fixed_width = true;"
"width = 50;"
"}"
": popup_list {"
(
strcat
"key =
\"
t:line"
(
itoa
cntr
)
"
\"
;"
)
"fixed_width = true;"
"width = 50;"
"}"
"}"
)
;_ end of list
)
;_ end of append
)
;_ end of setq
(
setq
arglst
(
append
arglst
(
cddr
item
)
)
)
(
setq
cntr
(
1+
cntr
)
)
)
;_ end of foreach
dlgline
)
;_ end of defun - DSET:DLGLINES
Logged
roy_043
Water Moccasin
Posts: 1895
BricsCAD 18
Re: Dialog woes
«
Reply #1 on:
October 13, 2015, 12:36:11 PM »
You are trying to read values from a dialog that is already closed.
Create an action for the "accept" button that reads and stores the values. I would store them in a list instead of creating lots of unlocalised variable names on the fly.
Logged
roy_043
Water Moccasin
Posts: 1895
BricsCAD 18
Re: Dialog woes
«
Reply #2 on:
October 13, 2015, 12:53:32 PM »
The code you have commented out should be (untested):
Code - Auto/Visual Lisp:
[Select]
(
action_tile
(
strcat
"t:line"
(
itoa
cntr
)
)
(
strcat
"(setq line"
(
itoa
cntr
)
" (get_tile
\"
t:line"
(
itoa
cntr
)
"
\"
))"
)
)
Logged
CincyJeff
Newt
Posts: 89
Re: Dialog woes
«
Reply #3 on:
October 13, 2015, 01:46:35 PM »
Thanks roy_043, the action_tile code did the trick. I'll look into the list idea as it does make more sense. Thanks again.
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Dialog woes