When I run the code below I get the following error :
"AutoCad Message : List Operation not supported : 4"
The code is an example of how to use drop-down-list taken totally from
http://www.jefferypsanders.com/autolisp_DCL_Part4.htmlWhat is wrong here ?
(defun saveVars()
;;;--- Get the selected item from the first list
(setq sStr1(get_tile "mylist1"))
;;;--- Make sure something was selected...
(if(= sStr1 "")
(setq myItem1 "Nothing")
(setq myItem1 (nth (atoi sStr1) myList1))
)
;;;--- Get the selected item from the second list
(setq sStr2(get_tile "mylist2"))
;;;--- Make sure something was selected...
(if(= sStr2 "")
(setq myItem2 "Nothing")
(setq myItem2 (nth (atoi sStr2) myList2))
)
)
(defun C:SAMPLE4()
(setq myList1(list "Electrical" "Structural" "Plumbing" "Foundation"))
(setq myList2(list "Plastic" "Steel" "Aluminum" "Concrete"))
;;;--- Load the dcl file
(setq dcl_id (load_dialog "SAMPLE4.dcl"))
;;;--- Load the dialog definition if it is not already loaded
(if (not (new_dialog "SAMPLE4" dcl_id))
(progn
(alert "The SAMPLE4.DCL file could not be loaded!")
(exit)
)
)
(start_list "mylist1" 4)
(mapcar 'add_list myList1)
(end_list)
(start_list "mylist2" 4)
(mapcar 'add_list myList2)
(end_list)
;;;--- If an action event occurs, do this function
(action_tile "accept" "(setq ddiag 2)(saveVars)(done_dialog)")
(action_tile "cancel" "(setq ddiag 1)(done_dialog)")
;;;--- Display the dialog box
(start_dialog)
;;;--- Unload the dialog box
(unload_dialog dcl_id)
;;;--- If the user pressed the Cancel button
(if(= ddiag 1)
(princ "\n Sample4 cancelled!")
)
;;;--- If the user pressed the Okay button
(if(= ddiag 2)
(progn
;;;--- Inform the user of his selection from the first list
(princ (strcat "\n You chose " myItem1 " from the first popup list box."))
;;;--- Inform the user of his selections from the second list
(princ (strcat "\n You chose " myItem2 " from the second popup list box."))
)
)
;;;--- Suppress the last echo for a clean exit
(princ)
)
DCL file
SAMPLE4 : dialog {
label = "Sample Dialog Box Routine - Part 4";
: column {
: boxed_row {
: popup_list {
key = "mylist1";
label = "Select Item";
fixed_width_font = true;
width = 30;
value = "";
}
: popup_list {
key = "mylist2";
label = "Select Item";
fixed_width_font = true;
width = 30;
value = "";
}
}
: boxed_row {
: button {
key = "accept";
label = " Okay ";
is_default = true;
}
: button {
key = "cancel";
label = " Cancel ";
is_default = false;
is_cancel = true;
}
}
}
}