明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2693|回复: 8

看了cad帮助文件就大胆想来试试,可是…………

[复制链接]
发表于 2003-1-6 11:55 | 显示全部楼层 |阅读模式
请赐教,不胜感激。看了cad帮助文件就大胆想写来试试,可是不知怎么给两个按钮分配动作来分别交替显示两幅幻灯片。

(defun c:sw ( / dcl_id )
    (setq dcl_id (load_dialog "sw"))
    (if (not (new_dialog "sw" dcl_id))(exit))
    (setq x (dimx_tile "show tit")
          y (dimy_tile "show tit"))
    (start_image "show tit")
    (slide_image 0 0 x y "a2")
    (end_image)
    (start_dialog)
    (unload_dialog dcl_id)
    (princ)
)
// =========show_htit.lsp===选择htit单选钮的作========
(defun show_htit ( / dcl_id )
    (setq x (dimx_tile "show tit")
          y (dimy_tile "show tit"))
    (start_image "show tit")
    (slide_image 0 0 x y "a2")
    (end_image)
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
)
// =========show_vtit.lsp===选择vtit单选钮的作=========
(defun show_vtit ( / dcl_id )
    (setq x (dimx_tile "show tit")
          y (dimy_tile "show tit"))
    (start_image "show tit")
    (slide_image 0 0 x y "b2")
    (end_image)
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
)



// =========sw.dcl=对话框================================
sw : dialog {
    label = "横竖图框";
    : boxed_column {
        label = "图框";
        : image {
                key = "show tit";
                height = 12;
                width = 10;
                color = -2;   
        }
        : radio_row {
                key = "htit_vtit";
                : radio_button {
                     label = "横图&H";
                     key = "htit";
                     value = "1";
                }     
                : radio_button {
                     label = "竖图&V";
                     key = "vtit" ;
                     value = "0";
        }}
    ok_cancel_help;
    }
}
发表于 2003-1-9 19:06 | 显示全部楼层

这样如何。。。

(defun c:sw ( / dcl_id x y hv)
    (setq dcl_id (load_dialog "sw"))
    (if (not (new_dialog "sw" dcl_id))(exit))
    (set_tile "htit_vtit" "htit")
    (show_tit "htit")
    (action_tile "htit_vtit" "(show_tit $value)")
    (start_dialog)
    (unload_dialog dcl_id)
    (princ)
)

(defun show_tit(hv)
    (setq x (dimx_tile "show tit")
          y (dimy_tile "show tit"))
    (start_image "show tit")
    (fill_image 0 0 x y -2)
    (cond ((= hv "htit")
           (slide_image 0 0 x y "a2"))
          ((= hv "vtit")
           (slide_image 0 0 x y "b2"))
          (T
           (slide_image 0 0 x y "a2"))
    )
    (end_image)
)
// =========sw.dcl=对话框================================
sw : dialog {
    label = "横竖图框";
    : boxed_column {
        label = "图框";
: image {
key = "show tit";
height = 12;
width = 10;
color = -2;     
        }
: radio_row {
key = "htit_vtit";
: radio_button {
   label = "横图&H";
   key = "htit";

}
: radio_button {
   label = "竖图&V";
   key = "vtit" ;
}}
  ok_cancel_help;
   }
}
 楼主| 发表于 2003-1-9 23:20 | 显示全部楼层

多谢了

发表于 2003-1-10 08:43 | 显示全部楼层

那樣又如何...

(defun C:SW (/ DCL_ID X Y)
  (setq DCL_ID (load_dialog "sw"))
  (if (not (new_dialog "sw" DCL_ID))
    (exit)
  )
  (start_image "show tit")
  (setq        X (dimx_tile "show tit")
        Y (dimy_tile "show tit")
  )
  (fill_image 0 0 X Y 0)
  (slide_image 0 0 X Y "a2")
  (end_image)
  (action_tile "htit" "(show \"a2\")")
  (action_tile "vtit" "(show \"b2\")")
  (start_dialog)
  (unload_dialog DCL_ID)
  (princ)
)

(defun SHOW (NAME / DCL_ID X Y)
  (start_image "show tit")
  (setq        X (dimx_tile "show tit")
        Y (dimy_tile "show tit")
  )
  (fill_image 0 0 X Y 0)
  (slide_image 0 0 X Y NAME)
  (end_image)
  (princ)
)
// =========sw.dcl=对话框================================
sw : dialog {
    label = "横竖图框";
    : boxed_column {
        label = "图框";
: image {
key = "show tit";
height = 12;
width = 10;
color = -2;     
        }
: radio_row {
key = "htit_vtit";
: radio_button {
                     label = "横图&H";
     key = "htit";
     value = "1";
}     
         : radio_button {
                     label = "竖图&V";
     key = "vtit" ;
     value = "0";
}}
    ok_cancel_help;
    }
}
发表于 2003-1-10 09:02 | 显示全部楼层

thanks

 楼主| 发表于 2003-1-13 00:45 | 显示全部楼层

二位大侠:我又加了几个按钮,为什么不执行…………

// =========aw.dcl=对话框================================
aw : dialog {
    label = "横竖图框";
    : boxed_column {
        label = "图框";
        : image {
           key = "show tit";
           height = 12;
           width = 10;
           color = -2;     
        }
        : radio_row {
           key = "htit_vtit";
        : radio_button {
           label = "横图&H";
           key = "htit";
        }
        : radio_button {
           label = "竖图&V";
           key = "vtit" ;
        }}
    :boxed_radio_row{
        label="选择合适的图号";
        key="nm_0_4";
      :radio_button{
          label="&0号";
          key="n_m0";
      }
      :radio_button{
          label="&1号";
          key="n_m1";
      }
      :radio_button{
          label="&2号";
          key="n_m2";
      }
      :radio_button{
          label="&3号";
          key="n_m3";
          value="1";
      }
      :radio_button{
          label="&4号";
          key="n_m4";
     }
    }
        ok_cancel_help;
   }
}

// =========sw.lsp=====================================
(defun c:aw ( / dcl_id x y hv)
    (setq dcl_id (load_dialog "aw"))
    (if (not (new_dialog "aw" dcl_id))(exit))           ;查找对话框文件
    (action_tile "accept" "(done_dialog)")
    (set_tile "htit_vtit" "htit")
    (show_tit "htit")
    (action_tile "htit_vtit" "(show_tit $value)")
    (set_tile "n_0_4" "n_m3")
   
    (start_dialog)
    (unload_dialog dcl_id)
    (command "_layer" "m" "图框" "t" "图框" "c" "251" '"" "")
    (command "_zoom" "e" "")
    (action_tile "n_m0" "a0")
    (action_tile "n_m1" "a1")
    (action_tile "n_m2" "a2")
    (action_tile "n_m3" "a3")
    (action_tile "n_m4" "a4")
    (princ)
)
;;===============================================================
(defun show_tit(hv)
    (setq x (dimx_tile "show tit")
          y (dimy_tile "show tit"))
    (start_image "show tit")
    (fill_image 0 0 x y -2)
    (cond ((= hv "htit")
   (slide_image 0 0 x y "a2"))
  ((= hv "vtit")
   (slide_image 0 0 x y "b2"))
  (T
   (slide_image 0 0 x y "a2"))
    )
    (end_image)
)

;;=======================a0===============================
(defun a0 ( / PT0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8)
  (setq PT0 '(0 0) pt1 '(15 5) pt2 '(1204 5)
        pt3 '(1204 846) pt4 '(15 846) pt5 '(1034 5)
        pt6 '(1034 41) pt7 '(1204 41))
     (command "_.LINE" "0,5" "0,0" "5,0" "")
     (command "_.LINE" "1204,0" "1209,0" "1209,5" "")
     (command "_.LINE" "1209,846" "1209,851" "1204,851" "")
     (command "_.LINE" "5,851" "0,851" "0,846" "")
     (command "_pline" pt1 "W" "0.5" "0.5" pt2 pt3 pt4 "c" "")
     (command "_pline" pt5 "W" "0.5" "0.5" pt6 pt7"" "")
  (setq pt8 '(912 0))
   (command "_insert" "tm" "non" pt8 "" "" "")
   (command "_zoom" "e" "")
)
发表于 2003-1-14 10:46 | 显示全部楼层

I suggest you spend more time on reading a reference book...

anyway, it is the best way to learn :)
发表于 2003-1-14 16:42 | 显示全部楼层

多看點書吧!附修正...

;;=========aw.lsp=====================================
(defun C:AW (/ DCL_ID WHAT SEL KEY)

  ;;=======================a0===============================
  (defun A0 (/ HOLDOSMODE CMDECHO PT0 PT1 PT2 PT3 PT4 PT5 PT6 PT7 PT8)
    (setq HOLDOSMODE (getvar "OSMODE"))
    (setq HOLDECHO (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setvar "OSMODE" 0)
    (setq PT0 '(0 0)
          PT1 '(15 5)
          PT2 '(1204 5)
          PT3 '(1204 846)
          PT4 '(15 846)
          PT5 '(1034 5)
          PT6 '(1034 41)
          PT7 '(1204 41)
    )
    (command "_.LINE" "0,5" "0,0" "5,0" "")
    (command "_.LINE" "1204,0" "1209,0" "1209,5" "")
    (command "_.LINE" "1209,846" "1209,851" "1204,851" "")
    (command "_.LINE" "5,851" "0,851" "0,846" "")
    (command "_.pline" PT1 "W" "0.5" "0.5" PT2 PT3 PT4 "c")
    (command "_.pline" PT5 "W" "0.5" "0.5" PT6 PT7 "")
    (setq PT8 '(912 0))
    (command "_.insert" "tm" "non" PT8 "" "" "")
    (command "_.zoom" "e")
    (setvar "OSMODE" HOLDOSMODE)
    (setvar "CMDECHO" HOLDECHO)
  )
  ;;=======================a0===============================

  (defun SHOW (NAME / X Y)
    (start_image "show tit")
    (setq X (dimx_tile "show tit")
          Y (dimy_tile "show tit")
    )
    (fill_image 0 0 X Y 0)
    (slide_image 0 0 X Y NAME)
    (end_image)
    (princ)
  )

  (setq DCL_ID (load_dialog "aw"))
  (if (not (new_dialog "aw" DCL_ID))
    (exit)
  )
  (action_tile "accept" "(done_dialog)")
  (set_tile "htit_vtit" "htit")
  (set_tile "nm_0_4" "n_m0")
  (setq SEL "A0")
  (setq KEY "H")
  (SHOW "a2")
  (action_tile "htit" "(setq key \"H\")(show \"a2\")")
  (action_tile "vtit" "(setq key \"V\")(show \"b2\")")
  (action_tile "n_m0" "(setq sel \"A0\")")
  (action_tile "n_m1" "(setq sel \"A1\")")
  (action_tile "n_m2" "(setq sel \"A2\")")
  (action_tile "n_m3" "(setq sel \"A3\")")
  (action_tile "n_m4" "(setq sel \"A4\")")
  (action_tile "accept" "(done_dialog 1)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq WHAT (start_dialog))
  (unload_dialog DCL_ID)
  (if (= WHAT 1)
    (progn
      (if (not (tblsearch "LAYER" "图框"))
        (command "_layer" "m" "图框" "c" "251" "")
      )
      (if (= KEY "H")
        (cond
          ((= SEL "A0") (A0))
          ((= SEL "A1") (A1))
          ((= SEL "A2") (A2))
          ((= SEL "A3") (A3))
          ((= SEL "A4") (A4))
        )
        (cond
          ((= SEL "A0") (AV0))
          ((= SEL "A1") (AV1))
          ((= SEL "A2") (AV2))
          ((= SEL "A3") (AV3))
          ((= SEL "A4") (AV4))
        )
      )
    )
  )
  (princ)
)


// =========aw.dcl=对话框================================
aw : dialog {
        label = "横竖图框";
        : boxed_column {
                label = "图框";
                : image {
                        key = "show tit";
                        height = 12;
                        width = 10;
                        color = -2;     
                        }
                : radio_row {
                        key = "htit_vtit";
                        : radio_button {
                                label = "横图&H";
                                key = "htit";
                                }     
                        : radio_button {
                                label = "竖图&V";
                                key = "vtit" ;
                                }}
                :boxed_radio_row{
                        label="选择合适的图号";
                        key="nm_0_4";
                        :radio_button{
                                label="&0号";
                                key="n_m0";
                                }
                        :radio_button{
                                label="&1号";
                                key="n_m1";
                                }
                        :radio_button{
                                label="&2号";
                                key="n_m2";
                                }
                        :radio_button{
                                label="&3号";
                                key="n_m3";
                                }
                        :radio_button{
                                label="&4号";
                                key="n_m4";
                                }
                        }
                ok_cancel_help;
                }
        }
 楼主| 发表于 2003-1-14 17:56 | 显示全部楼层

在看在看,多谢指点

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-19 21:06 , Processed in 0.491177 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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