我的DCL的Lisp
大家好,我最近学习了一些DCL。我买了一些书,在网上读了一些东西。我使对话框看起来很容易,我的大问题是写LISP使其工作。我的对话框附在下面。我想发生的是,当我在第一个popup_列表框中选择一个项目时,第二个列表将可用。该列表将取决于第一个popup\u列表框的选择。同样,第三个popup_列表框中将显示一个列表。该列表将取决于在第二个弹出框中选择的内容。
最后,当我按下插入按钮时,它将在第三个popup\u列表中插入该项目
这可能吗?我还附上了我的DCL和LSP文件。
检验。DCL
检验。LSP 这可能有助于您解决第一个问题:
;routine to fill values from a list to a pop-up list tile
(defun FillPopUpList( theTile theList / )
(start_list theTile) ;start pop-up tile fill operation
(mapcar 'add_list theList) ;load items from list to pop-up tile
(end_list)
)
;routine to fill a pop-up list tile based on selection on another
(defun ActionOnMy1stList( / theUserSelection )
(setq theUserSelection (get_tile "My1stList")) ;read which entry user selected
;fill second pop-up list with a content related to current selection in first one
(cond
((= theUserSelection "1") (FillPopUpList "My2ndList" '("a" "b" "c")))
((= theUserSelection "2") (FillPopUpList "My2ndList" '("A" "B" "C")))
((= theUserSelection "3") (FillPopUpList "My2ndList" '("X" "Y" "Z")))
)
)
(FillPopUpList "My1stList" '("1" "2" "3")) ;prepare first pop-up list
(action_tile "My1stList" "(ActionOnMy1stList)") ;define associated action on pop-up tile
请记住,互动程序的每个动作都应作为字符串提供。 第二个问题:要从第三个弹出互动程序中获得选择,请注意互动程序将以字符串形式返回所选项目的索引:
(setq The3rdSelection (nth (atoi (get_tile "My3rdList")) the3rdListContent))
其中第三个listcontent变量存储当前加载到互动程序中的列表。 哇,你是个聪明人。我真的很感激。现在给我时间试着理解它。再次感谢! Msasu-不需要get_tile,只需使用$value:wink: 另一种方式:
(defun mk_lst (key lst)
(start_list key)
(mapcar 'add_list lst)
(end_list))
(defun get_lst (key code)
(cond ((eq key "lvl1")
(cond ((eq code 0) '("A" "B" "C" "D"))
((eq code 1) '("E" "F" "G" "H"))))
((eq key "lvl2")
(cond ((eq code 0) '("I" "J" "K" "L"))
((eq code 1) '("M" "N" "O" "P"))))))
(action_tile "lvl1" (vl-prin1-to-string (quote (progn (mk_lst "lvl2" (get_lst "lvl1" $value))))))
(action_tile "lvl2" (vl-prin1-to-string (quote (progn (mk_lst "lvl2" (get_lst "lvl2" $value))))))
这看起来我走对了吗?我缩写了一些变量
到目前为止,我唯一的问题是,在选择第四个框后,如果我返回并更改框1中的选项,其他框将不会重置。 列表已重置–唯一的问题是在此之后没有默认选择。为了在填充互动程序后选择的弹出列表中获取条目,需要使用所需条目的索引(作为字符串)调用set\u互动程序:
(set_tile "lvl#" "0")
同样,当重新设置第二个列表时,最好清除第三个列表,因为第三个列表的内容已过时-只需调用start\u list/end\u list而不填充:
(defun ActL1( / theUserSelection ) ;;;ActL1 is Action on List #1
(setq US1 (get_tile "lvl1")) ;;;read which entry user selected.US1 is User Selection for pop_up lst #1
;;;fill second pop-up list with a content related to current selection in first one
(cond
((= US1 "1") (FillPopUpList "lvl2" '("" "2.1A" "2.1B" "2.1C")))
((= US1 "2") (FillPopUpList "lvl2" '("" "2.2A" "2.2B" "2.2C")))
((= US1 "3") (FillPopUpList "lvl2" '("" "2.3A" "2.3B" "2.3C")))
((= US1 "4") (FillPopUplist "lvl2" '("" "2.4A" "2.4B" "2.4c")))
((= US1 "5") (FillPopUplist "lvl2" '("" "2.5A" "2.5B" "2.5C")))
) ;;;close condition
(set_tile "lvl2" "0")
(foreach TempTile '("lvl3" "lvl4") (start_list TempTile) (end_list))
) ;;;close ActionOnMy1stList function
另一个建议是为done\u对话框操作使用参数–使用1表示确定(在您的案例中插入),0表示取消:
6
该值将存储在“DIASTAT”系统变量中;使用它来测试结束对话框并相应执行操作的方式:继续处理或退出例程。 那么,msasu,你是在哪里学会Lisp程序的?书籍、课程还是试错?我的意思是,您使用的函数在AutoCAD帮助主题中甚至找不到。
页:
[1]
2