明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1093|回复: 3

[基础] 求高手帮忙

[复制链接]
发表于 2009-10-19 19:43 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2009-10-19 20:38:31 编辑

(defun c:two()
  (setvar "cmdecho" 0)
  (setq wei1_list '("白炽灯" "荧光灯(单管)" "荧光灯(双管)" "荧光灯(多管)" "高强气体放电灯" "卤钨灯"))
  (setq wei2_list '("清洁" "一般" "污染"))
  (setq li1_list '("0.5" "0.6" "0.7" "0.8" "0.9" "1.0" "1.1" "1.25" "1.5" "1.75" "2.0" "2.25" "2.5" "3.0" "3.5" "4.0" "5.0"))
  (setq li2_list '("30,10" "30,30" "50,10" "50,30" "50;50" "70,10" "70,30" "70,50" "70,70" "30,10,10" "30,30,10" "50,30,10" "50,30,30" "50,50,10" "50,50,30" "70,30,10" "70,30,30" "70,50,10" "70,50,30"))
  (dcl_1st)
  (prin1)
)
(defun dcl_1st()
   (setq dcl_id(load_dialog "two"))
   (new_dialog "two" dcl_id)
   (show_list "wei1" wei1_list)
   (show_list "wei2" wei2_list)
   (show_list "li1" li1_list)
   (show_list "li2" li2_list)
   (setq wei1 (get_tile "wei1")
         wei2 (get_tile "wei2")
         whxs (get_tile "whxs")
         li1 (get_tile "li1")
         li2 (get_tile "li2"))
   (action_tile "wei1" "(setq wei1 $value)(sub_wei)")
   (action_tile "wei2" "(setq wei2 $value)(sub_wei)")
   (action_tile "whxs" "(setq whxs $value)(sub_wei)")
   (action_tile "li1" "(setq li1 $value)(sub_li)")
   (action_tile "li2" "(setq li2 $value)(sub_li)")
   (action_tile "accept" "(ok_1st)(done_dialog)")
   (start_dialog)
)
(defun ok_1st()
  (setq lyxs(get_tile "lyxs"))
)
(defun show_list(key newlist)
       (start_list key)
       (mapcar 'add_list newlist)
       (end_list)
)
(defun sub_wei()
      (cond
      ((and (= wei1 "0") (= wei2 "0")) (set_tile "whxs" "0.75"))
      ((and (= wei1 "0") (= wei2 "1")) (set_tile "whxs" "0.70"))
      ((and (= wei1 "0") (= wei2 "2")) (set_tile "whxs" "0.65"))
      ((and (= wei1 "1") (= wei2 "0")) (set_tile "whxs" "0.75"))
      ((and (= wei1 "1") (= wei2 "1")) (set_tile "whxs" "0.70"))
      ((and (= wei1 "1") (= wei2 "2")) (set_tile "whxs" "0.65"))
      ((and (= wei1 "2") (= wei2 "0")) (set_tile "whxs" "0.75"))
      ((and (= wei1 "2") (= wei2 "1")) (set_tile "whxs" "0.70"))
      ((and (= wei1 "2") (= wei2 "2")) (set_tile "whxs" "0.65"))
      ((and (= wei1 "3") (= wei2 "0")) (set_tile "whxs" "0.75"))
      ((and (= wei1 "3") (= wei2 "1")) (set_tile "whxs" "0.70"))
      ((and (= wei1 "3") (= wei2 "2")) (set_tile "whxs" "0.65"))
      ((and (= wei1 "4") (= wei2 "0")) (set_tile "whxs" "0.75"))
      ((and (= wei1 "4") (= wei2 "1")) (set_tile "whxs" "0.70"))
      ((and (= wei1 "4") (= wei2 "2")) (set_tile "whxs" "0.65"))
      ((and (= wei1 "5") (= wei2 "0")) (set_tile "whxs" "0.85"))
      ((and (= wei1 "5") (= wei2 "1")) (set_tile "whxs" "0.75"))
      ((and (= wei1 "5") (= wei2 "2")) (set_tile "whxs" "0.70"))
    )
)
(defun sub_li()
          (if(= wei1 "0") (setq  "li1" '("0.6" "0.7" "0.8" "0.9" "1.0" "1.1" "1.25" "1.5" "1.75" "2.0" "2.25" "2.5" "3.0" "3.5" "4.0" "5.0")
                         "li2" '("50,30,10" "50,30,30" "50,50,10" "50,50,30" "70,30,10" "70,30,30" "70,50,10" "70,50,30"))
          (cond    
          ((and(= li1 "0") (= li2 "0")) (set_tile "lyxs" "0.13"))
                     ((and(= li1 "0") (= li2 "1")) (set_tile "lyxs" "0.14"))
                     ((and(= li1 "0") (= li2 "2")) (set_tile "lyxs" "0.16"))
                     ((and(= li1 "0") (= li2 "3")) (set_tile "lyxs" "0.17"))
          ((and(= li1 "0") (= li2 "4")) (set_tile "lyxs" "0.14"))
                     ((and(= li1 "0") (= li2 "5")) (set_tile "lyxs" "0.15"))
                     ((and(= li1 "0") (= li2 "6")) (set_tile "lyxs" "0.18"))
                     ((and(= li1 "0") (= li2 "7")) (set_tile "lyxs" "0.19"))
          ((and(= li1 "1") (= li2 "0")) (set_tile "lyxs" "0.16"))
                     ((and(= li1 "1") (= li2 "1")) (set_tile "lyxs" "0.17"))
                     ((and(= li1 "1") (= li2 "2")) (set_tile "lyxs" "0.20"))
                     ((and(= li1 "1") (= li2 "3")) (set_tile "lyxs" "0.20"))
          ((and(= li1 "1") (= li2 "4")) (set_tile "lyxs" "0.18"))
                     ((and(= li1 "1") (= li2 "5")) (set_tile "lyxs" "0.19"))
                     ((and(= li1 "1") (= li2 "6")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "1") (= li2 "7")) (set_tile "lyxs" "0.23"))
          ((and(= li1 "2") (= li2 "0")) (set_tile "lyxs" "0.18"))
                     ((and(= li1 "2") (= li2 "1")) (set_tile "lyxs" "0.19"))
                     ((and(= li1 "2") (= li2 "2")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "2") (= li2 "3")) (set_tile "lyxs" "0.22"))
          ((and(= li1 "2") (= li2 "4")) (set_tile "lyxs" "0.21"))
                     ((and(= li1 "2") (= li2 "5")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "2") (= li2 "6")) (set_tile "lyxs" "0.24"))
                     ((and(= li1 "2") (= li2 "7")) (set_tile "lyxs" "0.25"))
          ((and(= li1 "3") (= li2 "0")) (set_tile "lyxs" "0.20"))
                     ((and(= li1 "3") (= li2 "1")) (set_tile "lyxs" "0.21"))
                     ((and(= li1 "3") (= li2 "2")) (set_tile "lyxs" "0.24"))
                     ((and(= li1 "3") (= li2 "3")) (set_tile "lyxs" "0.24"))
          ((and(= li1 "3") (= li2 "4")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "3") (= li2 "5")) (set_tile "lyxs" "0.23"))
                     ((and(= li1 "3") (= li2 "6")) (set_tile "lyxs" "0.26"))
                     ((and(= li1 "3") (= li2 "7")) (set_tile "lyxs" "0.28"))
               )
             )           
             (if(= wei1 "1") (setq "li1" '("0.6" "0.7" "0.8" "0.9" "1.0" "1.1" "1.25" "1.5" "1.75" "2.0" "2.25" "2.5" "3.0" "3.5" "4.0" "5.0")
                                "li2" '("50,30,10" "50,30,30" "50,50,10" "50,50,30" "70,30,10" "70,30,30" "70,50,10" "70,50,30"))
          (cond    
          ((and(= li1 "0") (= li2 "0")) (set_tile "lyxs" "0.13"))
                     ((and(= li1 "0") (= li2 "1")) (set_tile "lyxs" "0.14"))
                     ((and(= li1 "0") (= li2 "2")) (set_tile "lyxs" "0.16"))
                     ((and(= li1 "0") (= li2 "3")) (set_tile "lyxs" "0.17"))
          ((and(= li1 "0") (= li2 "4")) (set_tile "lyxs" "0.14"))
                     ((and(= li1 "0") (= li2 "5")) (set_tile "lyxs" "0.15"))
                     ((and(= li1 "0") (= li2 "6")) (set_tile "lyxs" "0.18"))
                     ((and(= li1 "0") (= li2 "7")) (set_tile "lyxs" "0.19"))
          ((and(= li1 "1") (= li2 "0")) (set_tile "lyxs" "0.16"))
                     ((and(= li1 "1") (= li2 "1")) (set_tile "lyxs" "0.17"))
                     ((and(= li1 "1") (= li2 "2")) (set_tile "lyxs" "0.20"))
                     ((and(= li1 "1") (= li2 "3")) (set_tile "lyxs" "0.20"))
          ((and(= li1 "1") (= li2 "4")) (set_tile "lyxs" "0.18"))
                     ((and(= li1 "1") (= li2 "5")) (set_tile "lyxs" "0.19"))
                     ((and(= li1 "1") (= li2 "6")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "1") (= li2 "7")) (set_tile "lyxs" "0.23"))
          ((and(= li1 "2") (= li2 "0")) (set_tile "lyxs" "0.18"))
                     ((and(= li1 "2") (= li2 "1")) (set_tile "lyxs" "0.19"))
                     ((and(= li1 "2") (= li2 "2")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "2") (= li2 "3")) (set_tile "lyxs" "0.22"))
          ((and(= li1 "2") (= li2 "4")) (set_tile "lyxs" "0.21"))
                     ((and(= li1 "2") (= li2 "5")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "2") (= li2 "6")) (set_tile "lyxs" "0.24"))
                     ((and(= li1 "2") (= li2 "7")) (set_tile "lyxs" "0.25"))
          ((and(= li1 "3") (= li2 "0")) (set_tile "lyxs" "0.20"))
                     ((and(= li1 "3") (= li2 "1")) (set_tile "lyxs" "0.21"))
                     ((and(= li1 "3") (= li2 "2")) (set_tile "lyxs" "0.24"))
                     ((and(= li1 "3") (= li2 "3")) (set_tile "lyxs" "0.24"))
          ((and(= li1 "3") (= li2 "4")) (set_tile "lyxs" "0.22"))
                     ((and(= li1 "3") (= li2 "5")) (set_tile "lyxs" "0.23"))
                     ((and(= li1 "3") (= li2 "6")) (set_tile "lyxs" "0.26"))
                     ((and(= li1 "3") (= li2 "7")) (set_tile "lyxs" "0.28"))
               )
             )
)

TWO.DCL程序

two:dialog{
            label="电气计算软件系列—照度计算";    
            :boxed_column{
                        label="维护系数:";
                        :row{
                        :popup_list{
                                 label="灯具类型:";
                 key="wei1";                
                                 width=24;
                                 height=10;
                         }
                        :popup_list{
                                 label="污染特性:";
                 key="wei2";
                                 width=24;
                                 height=10;
                         }
                        :edit_box{
                                 label="维护系数:";
                 key="whxs";
                                 width=24;
                         }
                    }
                 }      
                 :boxed_column{
                        label="利用系数:";
                        :row{
                        :popup_list{
                                 label="室内指数:";
                 key="li1";
                                 width=24;
                                 height=10;
                         }
                        :popup_list{
                                 label="反射系数:";
                 key="li2";
                                 width=24;
                                 height=10;
                         }
                        :edit_box{
                                 label="利用系数:";
                 key="lyxs";
                                 width=24;
                         }
                    }
                 }
               ok_cancel;
}

我想实现 wei1 选第一个的时候 li1表不是显示全部li_list表里的信息,当li1选择 li2 也同样不是显示全部li2_list,有筛选功能的,能帮看看sub_li子程序这么写对吗,或者别的什么地方有问题 sub_li子程序还未写完,因为数据比较多,所以先请高手帮忙看看。

发表于 2009-10-19 21:59 | 显示全部楼层
  1. (defun sub_li()
  2.           (if(= wei1 "0") (setq  "li1" '("0.6" "0.7" "0.8" "0.9" "1.0" "1.1" "1.25" "1.5" "1.75" "2.0" "2.25" "2.5" "3.0" "3.5" "4.0" "5.0")
  3.                          "li2" '("50,30,10" "50,30,30" "50,50,10" "50,50,30" "70,30,10" "70,30,30" "70,50,10" "70,50,30"))
  4. (if(= wei1 "1") (setq "li1" '("0.6" "0.7" "0.8" "0.9" "1.0" "1.1" "1.25" "1.5" "1.75" "2.0" "2.25" "2.5" "3.0" "3.5" "4.0" "5.0")
  5.                                 "li2" '("50,30,10" "50,30,30" "50,50,10" "50,50,30" "70,30,10" "70,30,30" "70,50,10" "70,50,30"))
setq后多了几个引号,应该是
  1. (defun sub_li()
  2.           (if(= wei1 "0") (setq  li1 '("0.6" "0.7" "0.8" "0.9" "1.0" "1.1" "1.25" "1.5" "1.75" "2.0" "2.25" "2.5" "3.0" "3.5" "4.0" "5.0")
  3.                          li2 '("50,30,10" "50,30,30" "50,50,10" "50,50,30" "70,30,10" "70,30,30" "70,50,10" "70,50,30"))
  4. (if(= wei1 "1") (setq li1 '("0.6" "0.7" "0.8" "0.9" "1.0" "1.1" "1.25" "1.5" "1.75" "2.0" "2.25" "2.5" "3.0" "3.5" "4.0" "5.0")
  5.                                 li2 '("50,30,10" "50,30,30" "50,50,10" "50,50,30" "70,30,10" "70,30,30" "70,50,10" "70,50,30"))


 楼主| 发表于 2009-10-20 08:42 | 显示全部楼层

li1 li2 不带引号也不对 ,我试过了

 楼主| 发表于 2009-10-20 08:43 | 显示全部楼层
如果重新定义li1 li2 cond里的函数是按新定义的顺序 还是按照原来的顺序啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-9 11:57 , Processed in 0.168742 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表