明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2069|回复: 8

能人快帮忙呀!AUTOLISP问题-->mccad转移

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

我的问题是在窗体中选择一个单选按钮后再点击确定后怎么完成确定后的工作
/////////////现在有一个窗体文件DCL
guanjian_radio : boxed_radio_column {
    label = "请选择其中的一个标高类型:";
//    fixed_height = true;
    : radio_button {
        key = "yiban";
        label = "一般标高";
        value="1";
    }
    : radio_button {
        key = "guanxin";
        label = "管心标高";
    }
    : radio_button {
        key = "guandi";
        label = "管底标高";
    }
    : radio_button {
        key = "guanding";
        label = "管顶标高";
    }
}
guanjian : dialog {
    label = "管件类:--标高";
    guanjian_radio;
//    ok_cancel;
    :row{
        :spacer        {width=1;}
        :button{
        label="确定";
        is_default = true;
        key="accept";
        width=8;
        fixed_width = true;
        }
        :button{
        label="取消";
        is_cancel = true;
        key="cancel";
        width=8;
        fixed_width = true;
        }
        :spacer {width=1;}
    }
}
//////////////////////////////////////////////////////////////////////////
/////////////////////////下面是调用的LSP文件(这里有问题,如何修改)///
(defun C:guanjian( / dcl_id )
(setq dcl_id (load_dialog "guanjian.dcl")) ; Load the DCL file.
  (if (not (new_dialog "guanjian" dcl_id))   ; Initialize the dialog.
    (exit)                                ; Exit if this doesn't
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (action_tile
   "yiban"
   "(setq sle \"(OG12 3)\")"
  )
  (action_tile
   "guanxin"
   "(setq sle \"(OG12 4)\")"
  )
  (action_tile
   "guandi"
   "(setq sle \"(OG12 5)\")"
  )
  (action_tile
   "guanding"
   "(setq sle \"(OG12 5)\")"
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (start_dialog)                          ; Display the dialog
    (action_tile "accept"            //关键在这里怎么继续实现下去
      (strcat("(done_dialog)"))
      )
  (action_tile "cancle" "(done_dialog 0)");退出按钮
    (unload_dialog dcl_id)   ; Unload the DCL file.
  (princ)
)
发表于 2002-11-19 11:51 | 显示全部楼层

1.dialog应在DCL的最外层, 2.按srart_dialog的返回值(即done_dialog n)来控制

 楼主| 发表于 2002-11-19 12:03 | 显示全部楼层

再帮我个忙!

本帖最后由 作者 于 2002-11-19 12:03:55 编辑

忘了告诉你我是特别笨的!!能不能在那段代码上改一下,再发上来,都怪我是刚学,你说的还是无法做对!谢谢了
发表于 2002-11-19 12:24 | 显示全部楼层

Re:

调用get_attr或get_tile函数完成对话框与CAD的数据交换并执行AutoCAD指令。
顺利说一下,本站有二次开发论坛,你这样的问题可以在LISP版块或源码分析版块提问,可能会得到更快回复。
发表于 2002-11-19 13:31 | 显示全部楼层

请看修改后的代码

//你的主对话框guanjian可简化如下:
guanjian : dialog {
    label = "管件类:--标高";
    guanjian_radio;
    ok_cancel;
}

(defun C:guanjian( / dcl_id )
        (setq dcl_id (load_dialog "guanjian.dcl")) ; Load the DCL file.
  (if (not (new_dialog "guanjian" dcl_id))   ; Initialize the dialog.
    (exit)                                ; Exit if this doesn't
  )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;****************************************
;;以下是否是设置当radio_button选中时的响应
;;****************************************
       
  (action_tile  "yiban"  "(setq sle \"(OG12 3)\")")
  (action_tile "guanxin" "(setq sle \"(OG12 4)\")")
  (action_tile "guandi" "(setq sle \"(OG12 5)\")")
  (action_tile "guanding" "(setq sle \"(OG12 5)\")" )
       
;;************************************
;;以下是修改的内容:
;;************************************
       
;对话框响应设置action_tile , 应在(start_dialog)的前面
        (action_tile "accept" "(done_dialog 1)") ;选中时将退出对话框,返回1
        ;<done_dialog 1>一般应为一个自定义函数(其中包含done_dialog 1),以提取
        ;当前对话框中的控件值,并执行其它你需要的操作.
        ;提取控件值应在(done_dialog 1)前, 因为对(done_dialog 1)求值后将关闭
        ;对话框,不能再用(get_tile)函数提取控件值.
  (action_tile "cancel" "(done_dialog 0)") ;选中时将退出对话框,返回0
       
  (setq wd_ret (start_dialog)) ; Display the dialog
  ;用wd_ret变量的值(数值型)来确定你要做什么作,该值即done_dialog后的
  数值

        (if (= wd_ret 1)
                (你的处理函数)
        )
       
  (unload_dialog dcl_id)   ; Unload the DCL file.       
  (princ)
)
 楼主| 发表于 2002-11-19 13:43 | 显示全部楼层

多谢提醒,再问?

(og12 3)/(og12 4)/(og12 5)是其他LSP文件中的函数调用,我不明白在下面
(if (= wd_ret 1)
(你的处理函数)
)
中处理什么内容?
我打算是选择yiban 时就执行(og12 3)函数,其他按钮也执行相同功能。
请给解释,谢谢
发表于 2002-11-19 13:49 | 显示全部楼层

回复:

(if (= wd_ret 1)
(你的处理函数)
)
表示若用户单击确定钮后执行的函数。
你的要求可以这样:
(if (= wd_ret 1)
  if (= sle "(og12 3)")
    ; to do something
  )
)
更简单地是在action_tile()中指定:
(action_tile "yiban" "(og12 3)")
......
 楼主| 发表于 2002-11-19 14:03 | 显示全部楼层

老哥,是我没做对!

我改了,还是没反映,我再描述一下,你给我分析一下:
我想做到:当选择了yiban单选按钮后(对应执行的函数是(og12 3)),再点击OK按钮就可以在上面化图了。
发表于 2002-11-19 14:57 | 显示全部楼层

这样做

(defun guanjian( /sle)
  ........
  (action_tile "yiban" "(setq sle 3)")
  (action_tile "guanxin" "(setq sle 4)")
    ......
  (start_dialog)
  (og12 sle)
  (unload_dialog dcl_id)
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-18 16:14 , Processed in 0.148311 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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