求主界面跳转子界面的方法
小弟是做门窗设计的,学了一个多月的LISP,会照葫芦画瓢的写自已门窗的代码了。现在要汇总了,不懂怎么把主界面和子界面连接在一起,书上也没例子。:'(比如我要选图1后点确定,就自动跳转到子界面qaz1.dcl为了方便大侠帮分析,我简化了如下:主程序qaz.lsp 主界面qaz.dcl 子界面qaz1.dcl qaz2.dcl主程序代码:(defun c:qaz()
(setvar "cmdecho" 0)
(dcl_qaz) ;调用对话框子程序
(prin1)
)
(defun dcl_qaz()
(setq dcl_id (load_dialog "qaz"))
(new_dialog "qaz" dcl_id)
;;;以下连接DCL
(action_tile "an_1" "(setq ddtype 1)")
(action_tile "an_2" "(setq ddtype 2)")
(action_tile "accept" "(ok_qaz)(done_dialog 1)")
(setq dd(start_dialog))
(if (= dd 1)
(draw_qaz)
))
(defun draw_qaz()
(cond (= ddtype 1)(qaz1)
(= ddtype 2)(qaz2)))
(defun c:qaz1();子界面调用1
(setq dcl_id (load_dialog "qaz1"))
(new_dialog "qaz1" dcl_id)
)
(defun c:qaz2();子界面调用2
(setq dcl_id (load_dialog "qaz2"))
(new_dialog "qaz2" dcl_id)
)
自已顶下 与楼主遇到类似问题,院长跟我说,嵌套调用,要用image_buttion院长就指点这么多
我从网上搜到的例子,参考学习了,基本能实现楼主的要求
http://www.afralisp.net/archive/lispa/lisp48n.htm
Syntax:
: image_button {
action alignment allow_accept aspect_ratio
color fixed_height fixed_width height
is_enabled is_tab_stopkey label mnemonic
width
}
--------------------------------------------------------------------------------
DCL Coding:
lisp48n : dialog { //dialog name
label = "image_button" ; //give it a label
: boxed_row { //define a boxed row
label = "Choose a Colour";//gie it a label
: image_button { //define image button
key = "im0" ; //give it a name
height = 1.0 ; //define height
width = 2.0 ; //define width
fixed_width = true; //fix the width
allow_accept = true ; //allow double-click
}
: image_button {
key = "im1" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im2" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im3" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im4" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im5" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im6" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
: image_button {
key = "im7" ;
height = 1.0 ;
width = 2.0 ;
fixed_width = true;
allow_accept = true ;
}
} //end boxed row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
--------------------------------------------------------------------------------
AutoLisp Coding:
(defun C:lisp48n ()
;define function
(setq dcl_id (load_dialog "lisp48n.dcl"))
;load dialog
(if (not (new_dialog "lisp48n" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(setqwidth(dimx_tile "im0")
;get the image width
height (dimy_tile "im0")
;get the image height
) ;_ end of setq
(start_image "im0")
;start the image
(fill_image 0 0 width height 1)
;fill it with the relevant colour
(end_image)
;end the image
(setqwidth(dimx_tile "im1")
height (dimy_tile "im1")
) ;_ end of setq
(start_image "im1")
(fill_image 0 0 width height 30)
(end_image)
(setqwidth(dimx_tile "im2")
height (dimy_tile "im2")
) ;_ end of setq
(start_image "im2")
(fill_image 0 0 width height 2)
(end_image)
(setqwidth(dimx_tile "im3")
height (dimy_tile "im3")
) ;_ end of setq
(start_image "im3")
(fill_image 0 0 width height 3)
(end_image)
(setqwidth(dimx_tile "im4")
height (dimy_tile "im4")
) ;_ end of setq
(start_image "im4")
(fill_image 0 0 width height 4)
(end_image)
(setqwidth(dimx_tile "im5")
height (dimy_tile "im5")
) ;_ end of setq
(start_image "im5")
(fill_image 0 0 width height 5)
(end_image)
(setqwidth(dimx_tile "im6")
height (dimy_tile "im6")
) ;_ end of setq
(start_image "im6")
(fill_image 0 0 width height 6)
(end_image)
(setqwidth(dimx_tile "im7")
height (dimy_tile "im7")
) ;_ end of setq
(start_image "im7")
(fill_image 0 0 width height 7)
(end_image)
(action_tile "im0" "(setq la \"0\")")
'get the name of the colour selected
(action_tile "im1" "(setq la \"1\")")
(action_tile "im2" "(setq la \"2\")")
(action_tile "im3" "(setq la \"3\")")
(action_tile "im4" "(setq la \"4\")")
(action_tile "im5" "(setq la \"5\")")
(action_tile "im6" "(setq la \"6\")")
(action_tile "im7" "(setq la \"7\")")
(action_tile
"accept"
;if O.K. pressed
"(done_dialog)(setq userclick T)"
;close dialog, set flag
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog
(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(alert (strcat "You Selected Colour: " la))
;display the colour selected.
);if userclick
(princ)
);defun
(princ)
Kye 发表于 2017-8-29 09:21
与楼主遇到类似问题,院长跟我说,嵌套调用,要用image_buttion院长就指点这么多
我从网上搜到的例子, ...
新手看不懂:'(。能帮调下吗? 找到当时实现的,还以为没保存呢,蓝色部分就是院长说的嵌套
分成两个DCL文件
1. lisp48n.dcl
lisp48n : dialog { //dialog name
label = "image_button" ;//give it a label
: boxed_row { //define a boxed row
label = "Choose a Colour"; //gie it a label
: image_button {
key = "style_image" ;
height = 12 ;
width = 36 ;
fixed_width = true;
allow_accept = true ;
}
} //end boxed row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
2. SubView.dcl
SubView : dialog { //dialog name
key = "Title";
label = "";//Title$ from lsp file
// label = "image_button" ;//give it a label
//
//: boxed_row { //define a boxed row
// label = "Choose a Colour"; //gie it a label
: image_button {
key = "style_image" ;
height = 24;
width = 72 ;
fixed_width = true;
allow_accept = true ;
}
//} //end boxed row
ok_cancel ; //predefined OK/Cancel button
} //end dialog
lisp 文件
==============================================================
(defun C:lisp48n ()
;define function
(setq fsld "E:\\FirstCad\\Data\\CUSTOMER\\P-0010-PC.sld")
(setq dcl_id (load_dialog "lisp48n.dcl"))
;load dialog
(if (not (new_dialog "lisp48n" dcl_id)
;test for dialog
);not
(exit)
;exit if no dialog
);if
(setq width(dimx_tile "style_image")
height (dimy_tile "style_image")
) ;_ end of setq
(start_image "style_image")
(fill_image 0 0 width height 30)
(Slide_Image 0 0 width height fsld)
(end_image)
;;;'get the name of the colour selected
(action_tile "style_image" "(show_sld\"style_image\" fsld)")
(action_tile
"accept"
;if O.K. pressed
"(done_dialog)(setq userclick T)"
;close dialog, set flag
);action tile
(action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog
);action_tile
(start_dialog)
;start dialog
(unload_dialog dcl_id)
;unload
(if userclick
;check O.K. was selected
(alert (strcat "You Selected Colour: " la))
;display the colour selected.
);if userclick
(princ)
);defun
(princ)
(Defun show_sld (fkey fsld / dcl_id1 Title)
(setq dcl_id1 (load_dialog "SubView.dcl"))
(if (not (new_dialog "SubView" dcl_id1))
(exit) ;_exit if no dialog
)
(setq Title fsld)
(set_tile "Title" Title)
(setq x (dimx_tile fkey)
y (dimy_tile fkey)
)
(start_Image fkey)
(fill_image 0 0 x y 0) ;_-15白色
(Slide_Image 0 0 x y fsld)
(End_Image)
(start_dialog) ;_start dialog
(unload_dialog dcl_id1)
) Kye 发表于 2017-8-29 09:27
找到当时实现的,还以为没保存呢,蓝色部分就是院长说的嵌套
分成两个DCL文件
要好好分析下,谢谢了。
Kye 发表于 2017-8-29 09:27
找到当时实现的,还以为没保存呢,蓝色部分就是院长说的嵌套
分成两个DCL文件
可以帮调整下我那代码吗?还是搞不得。
(defun c:test ( / formfile dd ddtype)
(defun showform (ziform / formname )
(cond
((= ziform 1) (setq formname "qaz1"))
((= ziform 2) (setq formname "qaz2"))
)
(if (not (new_dialog formname formfile))
(exit)
)
(setq fh (start_dialog))
(if (= fh 1)
(draw_qaz)
)
)
(setvar "cmdecho" 0)
(setq formfile (load_dialog "qaz.dcl"))
(if (not (new_dialog "qaz" formfile))
(exit)
)
(action_tile "an_1" "(setq ddtype 1)")
(action_tile "an_2" "(setq ddtype 2)")
(setq dd (start_dialog))
(if (= dd 1)
(showform ddtype)
)
(prin1)
)
dcl并到一起
qaz:dialog{
label="窗型";
spacer_1;
:row{
:image_button{//图像按钮1-1
color=-2;
width=40;
aspect_ratio=1;
key="an_1";}
:image_button{//图像按钮1-2
color=-2;
width=40;
aspect_ratio=1;
key="an_2";}
ok_cancel;
}}
qaz1:dialog{
label="窗型";
spacer_1;
:image_button{
color=-2;
width=40;
aspect_ratio=1;
key="an_4";}
ok_cancel;
}
qaz2:dialog{
label="窗型";
spacer_1;
:image_button{
color=-2;
width=40;
aspect_ratio=1;
key="an_3";}
ok_cancel;
} zlg258369 发表于 2017-8-29 18:21
dcl并到一起
感谢。。。。。。
页:
[1]