找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 552|回复: 2

[求助] [求助]:帮忙看一下程序!找原因!(行差标注)

[复制链接]
发表于 2005-4-12 10:00:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

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

×
DCL语言
dimention:dialog{
      label="行差标注";
   :row{width =42;
        :image{width=30;
          height=8;
          key="dimg";
          color=7;
          }
        :boxed_column{
                label="数据项";
                width=12;
             :row{
             :edit_box
                 {label="字体高度&H";
                 key="height";
                 width=4;
                 value="12";
                 }
                :button{
                      label="光标指定(&D)<";
                      width=4;
                      key="pheight";
                      }
                   }
                 :edit_box{label="标注名称&N";
                      key="name";
                      width=8;
                      value="A";
                       }
                  :edit_box{label="标注行差&V";
                            key="dvalue";
                            width=8;
                            value="002";
                         }
                 :button{label="选取点项(&p)...";
                         key="pickp";
                         }
                      }
                    }
                   ok_cancel;
               }
         dpoint:dialog{
;;;;;;;;;;;;
;;;;;;;;;;;;;
lsp语言
(defun diall();主对话筐驱动程序
   (if (not(new_dialog "dimention" dcld))(exit))
   (start_image "dimg")
   (slide_image 0 0(dimx_tile "dimg")(dimy_tile "dimg")"smain")
   (end_image)
   (set_tile "height"(rtos h 2 2))
   (set_tile "name"dimname)
   (set_tile "dvalue"dimv)
   (action_tile "pheight""(done_dialog 3)")
   (action_tile "pickp""(getmain)(dial2)")
   (action_tile "accept""(getmain)(done_dialog 1)")
   (action_tile "cancel""(done_dialog -1)")
  )
   (defun dial2()  ;选项对话框驱动程序
       (if (not (new_dialog "dpoint" dcld))(exit))
       (start_image "pimg")
       (slide_image 0 0 (dimx_tile "pimg")(dimy_tile "pimg")"spoint")
       (end_image)
       (set_tile "p1x" (rtos x1 2 2))
       (set_tile "p1y" (rtos y1 2 2))
       (set_tile "p2x" (rtos x2 2 2))
       (set_tile "p2y" (rtos y2 2 2))
       (action_tile "pickp1""(done_dialog 6)")
       (action_tile "dimsnap""(setq osmode (atoi $value))")
       (action_tile "pickp2" "(done_dialog 7)")
       (action_tile "accept" "(getpon)(done_dialog 4)")
       (action_tile "cancel""(done_dialog 5)")
       (setq retv (start_dialog))
       (if (= retv 6)(done_dialog 6))
                   (if(= retv 7)(done_dialog 7))
       )
     (defun getmain()      ;获取对话框控件属性值
          (setq dimname(get_tile "name"))
          (setq dimv(get_tile "dvalue"))
          (setq h (atof (get_tile "height")))
        )
   
         (defun getpon()         ;获取编辑中点的坐标值
          (setq x1 (atof(get_tile "p1x")))
          (setq y1 (atof(get_tile "p1y")))
          (setq x2 (atof (get_tile "p2x")))
             (setq y2 (atof(get_tile "p2y")))
             (setq p1 (list x1 y1 0)p2(list x2 y2 0))
           )
           (defun mvdraw()        ;绘图程序
             (setq xm x1)
             (setq ym y2)
             (setq m (list xm ym))
             (setq la(strlen dimv))
             (setq lb(strlen dimname))
             (setq l(+ 1 la lb))
             (setq l(* h l))
             (setvar "snapmode" osmode)
             (if (>= x1 x2)(setq xa x2)(setq xa (+ x2 l)))
                 (setq ya (+ y2(* 0.8 h)))
             (setq xc (- xa 1))
             (setq yc (- y2 (* 0.8 h)))
             (setq a (list xa ya))
             (setq c(list xc yc))
             (setq arh (* 0.5 h))
             (setq ymp (* l h))
             (if (< y2 y1)(setq ymp (- 0 ymp)))
             (setq ymp (+ ymp y1))
             (setq mp(list x1 ymp))
             (setq j (list (+ xc(* l h))yc))
             (setq k (list (- xa (* (strlen dimname)h))ya))
             (command "pline" p1 "w" 0 arh mp "")
             (command "line" mp m p2 "")
             (command "rectang" a c)
             (command "text"(list (+(car c) 2)(+(cadr c) 2)) h 0 "%%c")
             (command "rectang" j (list (- (car k)2)ya))
             (command "text"(list(+(car j)4)(+ yc 2)) h 0 dimv)
             (command "text"(list (car k)(+ yc 2)) h 0 dimname)
             )
           (defun c:mydim()        ;主程序,添加绘图命令
              (setq dcld (load_dialog "c8_4.dcl"))
              (if(< dcld 0)(exit))
              (setq x1 45 y1 45 x2 90 y2 90 retv 3 h 12)                                                                                                                  
              (setq dimname "m" dimv "009")
              (setq p1 (list x1 y1 0) p2 (list x2 y2 0))
              (while (> retv 1);检测对话框状态
              (diall)
              (if (or(= retv 6)(= retv 7))(dial2))
                  (if (and (and(/= retv 1)(/= retv -1))(/= retv 6)(/= retv 7))
                     (setq retv (start_dialog))
        )
                (if (= retv 3)(setq h (getdist "charactor height\n")))
                (if (= retv 6)
                    (setq p1 (getpoint "point p1:\n") x1 (car p1 )y1 (cadr p1))
                  )
                    (if (= retv 7)
                        (setq p2 (getpoint "point p2 :\n")x2 (car p2)y2(cadr p2))
                          )
                          )
                 ;(unload_dialog dcld)
                 (if (= retv 1)(mvdraw))
              (unload_dialog dcld)
                 (princ)
                 )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2005-4-12 19:34:33 | 显示全部楼层
1楼楼主最好说明程序那儿有问题,大家有针对性地给你提提建议,总不至于要大家逐字逐句对程序,理思路吧?哈哈,开个玩笑,别介意...
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-13 09:04:44 | 显示全部楼层
运行后snapmode返回为nil,我对snapmode和osmode是比较糊涂的,给点这反面的编程经验!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-28 02:34 , Processed in 0.429707 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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