• AutoLISP对话框DCL按钮Button设计实例


    AutoLISP对话框DCL按钮设计实例,绘制三种形式的图形,DCL对话框设计代码如下。

    dia5b:dialog {
        label = "按钮测试" ;
        :boxed_row {
            label = "图形尺寸" ;
            :edit_box {
                edit_width = 8 ;
                key="kww";
                label = "宽度WW:" ;
            }
            :edit_box {
                edit_width = 8 ;
                key="khh";
                label = "高度HH:" ;
            }
        }
        :button {
            key = "bb1" ;
            label = "DIA5B1-L型" ;
        }
        :button {
            key = "bb2" ;
            label = "DIA5B2-X型" ;
        }
        :button {
            key = "bb3" ;
            label = "DIA5B3-漏斗型" ;
        }
        spacer_1;
        cancel_button;
    }

    LSP程序控制代码如下。

    (defun c:dia5b ()
        (setvar "cmdecho" 0)
        (dcl_dia5b)
        (prin1)
    )
    (defun dcl_dia5b ()
        (setq dcl_id (load_dialog "dia5b"))
        (new_dialog "dia5b" dcl_id)
        (set_tile "kww" "50")
        (set_tile "khh" "50")
        (action_tile "bb1" "(get_ww_hh) (done_dialog 1)")
        (action_tile "bb2" "(get_ww_hh) (done_dialog 2)")
        (action_tile "bb3" "(get_ww_hh) (done_dialog 3)")
        (setq dd (start_dialog))
        (cond ((= dd 1) (c:dia5b1))
          ((= dd 2) (c:dia5b2))
          ((= dd 3) (c:dia5b3))
          (t (alert "未完成任何动作!!!"))
        )
    )
    (defun get_ww_hh ()
        (setq ww (atof (get_tile "kww")))
        (setq hh (atof (get_tile "khh")))
    )
    (defun c:dia5b1    ()
        (setvar "cmdecho" 0)
        (get_input_data)
        (command "pline" p1 p2 p3 pm34 pm pm14 "c")
        (prin1)
    )
    (defun c:dia5b2    ()
        (setvar "cmdecho" 0)
        (get_input_data)
        (command "pline" p1 p2 p3 p4 "c")
        (command "line" P1 P3 "")
        (command "line" p2 p4 "")
        (prin1)
    )
    (defun c:dia5b3    ()
        (setvar "cmdecho" 0)
        (get_input_data)
        (command "pline" p1 p2 p4 p3 "c")
        (prin1)
    )
    (defun get_input_data ()
        (setq p1 (getpoint "\n插入点:"))
        (setq p2 (polar p1 0 ww))
        (setq p3 (polar p2 (* pi 0.5) hh))
        (setq p4 (polar p3 pi ww))
        (setq pm (inters p1 p3 p2 p4))
        (setq pm12 (polar p1 0 (* ww 0.5)))
        (setq pm34 (polar p3 pi (* ww 0.5)))
        (setq pm23 (polar p2 (* pi 0.5) (* hh 0.5)))
        (setq pm14 (polar p1 (* pi 0.5) (* hh 0.5)))
    )

    代码完。

    指甲长了打字很不舒服。

    作者:codee
    文章千古事,得失寸心知。


  • 相关阅读:
    第7章例7-12
    第7章例7-11
    第7章例7-9
    第7章例7-8
    第7章例7-7
    第7章例7-6
    第7章例7-5
    第7章例7-4
    第7章例7-3
    第7章例7-2
  • 原文地址:https://www.cnblogs.com/bimgoo/p/2503062.html
Copyright © 2020-2023  润新知