明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1504|回复: 9

[提问] 求主界面跳转子界面的方法

[复制链接]
发表于 2017-8-27 23:17:38 | 显示全部楼层 |阅读模式
小弟是做门窗设计的,学了一个多月的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)
        )

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2017-8-29 09:21:17 | 显示全部楼层
与楼主遇到类似问题,院长跟我说,嵌套调用,要用image_buttion院长就指点这么多

我从网上搜到的例子,参考学习了,基本能实现楼主的要求

[url=][url=][/url]http://www.afralisp.net/archive/lispa/lisp48n.htm[/url]
Syntax:  

  : image_button {
          action alignment allow_accept aspect_ratio
          color fixed_height fixed_width height
          is_enabled is_tab_stop  key 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

  (setq  width  (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

  (setq  width  (dimx_tile "im1")
  height (dimy_tile "im1")
  ) ;_ end of setq
  (start_image "im1")
  (fill_image 0 0 width height 30)
  (end_image)

  (setq  width  (dimx_tile "im2")
  height (dimy_tile "im2")
  ) ;_ end of setq
  (start_image "im2")
  (fill_image 0 0 width height 2)
  (end_image)

  (setq  width  (dimx_tile "im3")
  height (dimy_tile "im3")
  ) ;_ end of setq
  (start_image "im3")
  (fill_image 0 0 width height 3)
  (end_image)

  (setq  width  (dimx_tile "im4")
  height (dimy_tile "im4")
  ) ;_ end of setq
  (start_image "im4")
  (fill_image 0 0 width height 4)
  (end_image)

  (setq  width  (dimx_tile "im5")
  height (dimy_tile "im5")
  ) ;_ end of setq
  (start_image "im5")
  (fill_image 0 0 width height 5)
  (end_image)

  (setq  width  (dimx_tile "im6")
  height (dimy_tile "im6")
  ) ;_ end of setq
  (start_image "im6")
  (fill_image 0 0 width height 6)
  (end_image)

  (setq  width  (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)


 楼主| 发表于 2017-8-29 09:26:28 | 显示全部楼层
Kye 发表于 2017-8-29 09:21
与楼主遇到类似问题,院长跟我说,嵌套调用,要用image_buttion院长就指点这么多

我从网上搜到的例子, ...

新手看不懂。能帮调下吗?
发表于 2017-8-29 09:27:26 | 显示全部楼层
找到当时实现的,还以为没保存呢,蓝色部分就是院长说的嵌套

分成两个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)
)
 楼主| 发表于 2017-8-29 09:34:13 | 显示全部楼层
Kye 发表于 2017-8-29 09:27
找到当时实现的,还以为没保存呢,蓝色部分就是院长说的嵌套

分成两个DCL文件

要好好分析下,谢谢了。
 楼主| 发表于 2017-8-29 11:02:52 | 显示全部楼层
Kye 发表于 2017-8-29 09:27
找到当时实现的,还以为没保存呢,蓝色部分就是院长说的嵌套

分成两个DCL文件

可以帮调整下我那代码吗?还是搞不得。

点评

Kye
你还是找找Z版吧,Z版大牛,心肠好,我看DCL就很头疼,能不用尽量不用  发表于 2017-8-29 11:17
发表于 2017-8-29 18:21:15 | 显示全部楼层
  1. (defun c:test ( / formfile dd ddtype)
  2.   
  3.   (defun showform (ziform / formname )

  4.     (cond
  5.       ((= ziform 1) (setq formname "qaz1"))
  6.       ((= ziform 2) (setq formname "qaz2"))
  7.     )
  8.     (if        (not (new_dialog formname formfile))
  9.       (exit)
  10.     )
  11.     (setq fh (start_dialog))
  12.     (if        (= fh 1)
  13.       (draw_qaz)
  14.     )
  15.   )

  16.   (setvar "cmdecho" 0)
  17.   (setq formfile (load_dialog "qaz.dcl"))
  18.   
  19.   (if (not (new_dialog "qaz" formfile))
  20.     (exit)
  21.   )

  22.   (action_tile "an_1" "(setq ddtype 1)")
  23.   (action_tile "an_2" "(setq ddtype 2)")

  24.   (setq dd (start_dialog))
  25.   (if (= dd 1)
  26.     (showform ddtype)
  27.   )
  28.   (prin1)

  29. )


dcl并到一起
  1. qaz:dialog{
  2. label="窗型";
  3. spacer_1;
  4.         :row{
  5.                 :image_button{//图像按钮1-1
  6.                 color=-2;
  7.                 width=40;
  8.                 aspect_ratio=1;
  9.                 key="an_1";}

  10.                 :image_button{//图像按钮1-2
  11.                 color=-2;
  12.                 width=40;
  13.                 aspect_ratio=1;
  14.                 key="an_2";}
  15.                 ok_cancel;
  16.                 }}

  17. qaz1:dialog{
  18. label="窗型";
  19. spacer_1;
  20.        
  21.                 :image_button{
  22.                 color=-2;
  23.                 width=40;
  24.                 aspect_ratio=1;
  25.                 key="an_4";}

  26.                 ok_cancel;
  27.                 }

  28. qaz2:dialog{
  29. label="窗型";
  30. spacer_1;
  31.        
  32.                 :image_button{
  33.                 color=-2;
  34.                 width=40;
  35.                 aspect_ratio=1;
  36.                 key="an_3";}

  37.                 ok_cancel;
  38.                 }
 楼主| 发表于 2017-8-30 09:52:56 | 显示全部楼层

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

本版积分规则

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

GMT+8, 2025-5-20 02:28 , Processed in 0.156267 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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