找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 701|回复: 0

[LISP程序]:标注的坐标入高程值(回车为空值

[复制链接]
发表于 2006-11-14 18:26:06 | 显示全部楼层 |阅读模式

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

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

×
(defun c:zb (/ os pt y x p1 p2 h str-h test-xy x1 x2 y1 sh ts txt -ts ts1 l tyu tyd a b ph)
  (setvar "cmdecho" 0)
  (command "ucs" "w")
  (setq os (getvar "osmode"))
  (command "osnap" "int,end")
  (setq pt (getpoint "\n请点取欲标注坐标的点:"))
  (PRINC PT)
  (command "osnap" "non")
  (command "pline" pt "")
  (command "osnap" "off")
  (command "ucs" "v")
  ;(setq p1 (getpoint (trans pt 0 1) "\n标注线起点:"))
  (setq p1 (getpoint  "\n标注线起点:"))
  (PRINC P1)
  (setq p2 (getpoint  "\n标注线终点方向:"))
  (PRINC P2)
  ;(setq h (strcase (getstring t "\n请输入高程值(回车为空值):") 1))
  (setq h (getstring  "\n请输入高程值(回车为空值):"))
  (if (= (strlen h) 0)
   (setq str-h h)
   (setq str-h (strcat "H=" h))
  )
  (setq test-xy (getstring  "\n标注坐标值是否需互换?<回车为否/Yes>:"))
  (if (= (strlen test-xy) 0)
    (setq x (strcat " X=" (rtos (car pt) 2 3)))
    (setq y (strcat " Y=" (rtos (cadr pt) 2 3)))
  )
  (if (/= (strlen test-xy) 0)
    (setq x (strcat " X=" (rtos (cadr pt) 2 3)))
    (setq y (strcat " Y=" (rtos (car pt) 2 3)))
  )
  (setq x1 (car p1))
  (setq y1 (cadr p1))
  (setq x2 (car p2))
  (setq y2 (cadr p2))
  (setq sh (cAr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
  (setq w  (cdr (assoc 41 (tblsearch "style" (getvar "textstyle")))))
  
  (setq ts (if (> sh 0)
               (SETQ sh (getvar "TEXTSIZE"))
           )
  )

  (setq txt-ts (strcat "\n文本尺寸为" (rtos ts 2 1)))
  (prompt txt-ts)
  (setq ts1 (getreal "\n文本尺寸为<回车为默认值>"))
  (if (= ts nil)
     (setq ts ts)
     (setq ts ts1)
  )
  (setq l (* (max (strlen y) (strlen x)) ts 0.9 w))
  (setq tyu (+ y1 (* ts 0.5)))
  (setq tyd (- y1 (* ts 1.5)))
  (if (> x1 x2)
      (setq x2 (- x1 1))
      (setq y2 (+ y1 1))
  )
  (command "pline" "@0,0,0" "w" 0 0 p1 (list x2 y1) "")
  (if (> x1 x2)
      (setq a x2)
      (setq a x1)
  )
  (if (> x1 x2)
      (setq b x1)
      (setq b x2)
  )
  (if (> sh 0)
     (progn
        (command "text" (list a tyd) TS1 0 y "")
        (command 'text" (list a tyu) TS1 0 x "")
     )
     (progn
        (command "text" (list a tyd) ts 0 y "")
        (command 'text" (list a tyu) ts 0 x "")
     )
  )
  (if (/= "H=" h)
     (progn
       (if (> x2 x1)
         (setq ph (list (+ x2 (/ ( * ts w ) 2)) (- y1 (/ ts 2))))
         (setq ph (list (- x2 (* (strlen str-h) ts w)) (- y1 (/ ts 2))))
       )
       (if (> sh 0)
         (command "text" ph 0 str-h "")
         (command "text" ph ts 0 str-h "")
       )
     )
   )
  (setvar "osmode" os)
  (command "ucs" "w")
  (command "redraw")
)

*-*9
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-6-15 05:32 , Processed in 0.191506 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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