Hey guys,
I posted this a while back but I got no response. I have come up with this bit of code that I need a little help with. I originally started this code from a sample from Afralisp to generate what I currently have. The problem I am experiencing is when the user selects the "Accept" button I need it to run a sub-function, the (InsDoor) which inserts doors based on the dialog selection and if the "Cancel" is pressed then exit the dialog and do nothing. Any help would be great.
(defun C:InsertDoor () ;define function
(setq DoorType "LH")
(setq DoorSize "3-0")
(setq dcl_id (load_dialog "samp.dcl")) ;load dialog
(if (not (new_dialog "samp" dcl_id) ;test for dialog
);not
(exit) ;exit if no dialog
);if
(setq w (dimx_tile "im") ;get image tile width
h (dimy_tile "im") ;get image tile height
);setq
(start_image "im") ;start the image
(fill_image 0 0 w h 5) ;fill it with blue
(end_image) ;end image
;added
(mode_tile "rb1" 0)
(mode_tile "rb2" 0)
(mode_tile "rb3" 0)
(mode_tile "rb4" 1)
(mode_tile "rb5" 1)
(mode_tile "rb6" 1)
(mode_tile "selections" 0)
(drsizes)
;added
(action_tile "rb1" "(setq DoorType \"LH\")(drsizes)")
(action_tile "rb2" "(setq DoorType \"RH\")(drsizes)")
(action_tile "rb3" "(setq DoorType \"DB\")(ddrsizes)")
(action_tile "rb4" "(setq DoorType \"BFD\")(drsizes)")
(action_tile "rb5" "(setq DoorType \"PD\")(drsizes)")
;(action_tile "rb6" "(setq DoorType \"VD\")(Vdrsizes)")
(action_tile "selections" "(setq Doorsize (nth (atoi $value) sizes))")
(action_tile
"accept" ;if O.K. pressed
" (done_dialog)(setq userclick T)" ;close dialog
);action tile
(action_tile
"cancel" ;if cancel button pressed
"(done_dialog)(setq userclick nil)" ;close dialog
);action_tile
(start_dialog) ;start dialog
(unload_dialog dcl_id) ;unload
(if (= userclick T)
(InsDoor)
(command)
)
(princ)
);defun C:InsertDoor
(defun InsDoor ()
(if (= T (wcmatch doorsize "V*"))
(progn
(setq drft (substr doorsize 2 1)
drin (substr doorsize 4 2))
(setq cnt (strlen doorsize))
(setq zmath1 (* (atoi drft) 12))
(setq zmath2 (+ (atoi drin) zmath1))
(setq drsz (rtos zmath2 2 0))
(setq doorsize (strcat "08" (strcase DoorType) drsz "VD"))
(setvar "orthomode" 1)
(command ".-Insert" doorsize pause "" "")
)
(progn
(setq drft (substr doorsize 1 1)
drin (substr doorsize 3 2))
(setq cnt (strlen doorsize))
(setq zmath1 (* (atoi drft) 12))
(setq zmath2 (+ (atoi drin) zmath1))
(setq drsz (rtos zmath2 2 0))
(setq doorsize (strcat "08" (strcase DoorType) drsz "EX"))
(setvar "orthomode" 1)
(command ".-Insert" doorsize pause "" "")
)
)
(princ)
)
(defun drsizes ()
(setq sizes '("1-6" "2-0" "2-2" "2-4" "2-6" "2-8" "2-10" "3-0" "3-2" "3-4" "3-6" "3-8" "3-10" "4-0" "V3-0" "V4-0")
dcl:option "1")
(start_list "selections")
(mapcar 'add_list sizes)
(end_list)
)
(defun ddrsizes ()
(setq sizes '("4-0" "5-0" "5-4" "6-0" "7-0" "8-0")
dcl:option "2")
(start_list "selections")
(mapcar 'add_list sizes)
(end_list)
)
samp : dialog { //dialog name
label = "Insert Door, version 1.0" ; //give it a label
: row { //define row
:boxed_radio_column{
label = "Door Type" ;
: radio_button {
key = "rb1" ;
label = "Left Hand Door" ;
is_enabled = false;
value = "1" ;
}
: radio_button {
key = "rb2" ;
label = "Right Hand Door" ;
is_enabled = false;
}
: radio_button {
key = "rb3" ;
label = "Double Door" ;
is_enabled = false;
}
: radio_button {
key = "rb4" ;
label = "Bifold" ;
is_enabled = false;
}
: radio_button {
key = "rb5" ;
label = "Pocket" ;
is_enabled = false;
}
}
: boxed_column {
label = "&Size";
: popup_list {
key = "selections";
is_enabled = false;
// value = "1" ;
}
}
} //end row
:spacer{
width=4;
}
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 1.0 ; //and a height
width = 1.0 ; //and now a width
} //end image
: paragraph { //define paragraph
: text_part { //define text
label = "Designed and Created"; //give it some text
} //end text
: text_part { //define more text
label = "by DV"; //some more text
} //end text
} //end paragraph
} //end row
} //end dialog
Any suggestions would be great.
Thanks,