看了cad帮助文件就大胆想来试试,可是…………
请赐教,不胜感激。看了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;
}
}
这样如何。。。
(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;
}
}
多谢了
那樣又如何...
(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;
}
}
thanks
二位大侠:我又加了几个按钮,为什么不执行…………
// =========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" "")
)
I suggest you spend more time on reading a reference book...
anyway, it is the best way to learn :)多看點書吧!附修正...
;;=========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;
}
}
在看在看,多谢指点
页:
[1]