明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2280|回复: 5

请大家帮忙看一下这个程序是否有缺陷?

[复制链接]
发表于 2003-2-17 14:34:00 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2003-2-19 08:03:00 | 显示全部楼层

只对直线有效..

;;---------------------------------------------------
;;****此程序功能是对管道线进行管径标注,其符号为DN。
;;****只对直线有效<Only work for 2000+>
;;---------------------------------------------------

(defun C:BDN (/             CMD_OLD           OS_OLD SS         SS1        SS2    PT
              PT0    PT1    PT2           ANG          DN         DN0        BDN_ER BDN_OE
              VOBJ   PNT    PARAM1 PARAM2
             )

  (defun DXF (CODE ELIST)
    (cdr (assoc CODE ELIST))
  )

  (defun DO_IT ()
    (setq ANG0 (angle PT1 PT2))
    (if
      (and (> ANG0 (* pi 0.5)) (<= ANG0 (* pi 1.5)))
       (setq ANG0 (+ ANG0 pi))
    )
    (setq ANG (+ ANG0 (* pi 0.5)))
    (setq PT0 (polar PT ANG (* (getvar "textsize") 10)))
    (setq PT (inters PT1 PT2 PT0 PT NIL))
    (setq PT (polar PT ANG (* (getvar "textsize") 0.35)))
    (setq DN0 (rtos (distance PT1 PT2) 2 2))
    (setq DN (getstring (strcat "\n请输入该管道管径<" DN0 ">:")))
    (if
      (= DN "")
       (setq DN DN0)
       (setq DN0 DN)
    )
    (setq DN (strcat "DN" DN))
    (command "_.text"
             "C"
             PT
             (getvar "textsize")
             (angtos ANG0 0 3)
             DN
    )
  )

  (setq CMD_OLD (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq OS_OLD (getvar "osmode"))
  (setvar "osmode" 0)
  (defun BDN_ER        (S)
    (if        (/= MSG "功能取消")
      (if (= MSG "退出 / 中止")
        (princ)
        (princ (strcat "\n功能取消!"))
      )
    )
    (eval (read U:E))
    (if        BDN_OE
      (setq *ERROR* BDN_OE)
    )
    (if        temp
      (redraw temp 1)
    )
    (princ)
  )
  (if *ERROR*
    (setq BDN_OE  *ERROR*
          *ERROR* BDN_ER
    )
    (setq *ERROR* BDN_ER)
  )
  (setq        U:G "(command \"undo\" \"group\")"
        U:E "(command \"undo\" \"en\")"
  )
  (while
    (setq SS (entsel "\n请拾取需标注管径的管道<回车退出>:"))
     (setq SS1 (entget (car SS)))
     (setq SS2 (DXF 0 SS1))
     (setq PT (osnap (trans (cadr SS) 1 0) "MID"))
     (cond
       ((= SS2 "LINE")
        (setq PT1 (DXF 10 SS1)
              PT2 (DXF 11 SS1)
        )
        (DO_IT)
       )
       ((or (= SS2 "LWPOLYLINE")
            (= SS2 "OLYLINE")
        )
        (setq VOBJ (vlax-ename->vla-object (car SS)))
        (setq PARAM1 (vlax-curve-getparamatpoint VOBJ PT))
        (setq PARAM1 (fix PARAM1))
        (setq PARAM2 (1+ PARAM1))
        (if (equal PARAM1 (vlax-curve-getstartparam VOBJ) 1e-10)
          (setq PT1 (vlax-curve-getstartpoint VOBJ))
          (setq PT1 (vlax-curve-getpointatparam VOBJ PARAM1))
        )
        (if (equal PARAM2 (vlax-curve-getendparam VOBJ) 1e-10)
          (setq PT2 (vlax-curve-getendpoint VOBJ))
          (setq PT2 (vlax-curve-getpointatparam VOBJ PARAM2))
        )
        (DO_IT)
       )
       (t
        (alert "\n所选像素不能进行管径标注!重新选取")
       )
     )
  )
  (setvar "cmdecho" CMD_OLD)
  (setvar "osmode" OS_OLD)
  (princ)
)
(prompt "\nEnter BDN to start")
 楼主| 发表于 2003-2-19 14:14:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2003-2-19 18:13:00 | 显示全部楼层

这个程序的缺陷在于对LwPOLYLINE资料分析不正确,所以有时会出错,龙大侠改正了它。

 楼主| 发表于 2003-2-19 20:40:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2016-5-6 20:34:14 | 显示全部楼层
很想学学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-3 08:08 , Processed in 0.245419 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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