永不言弃 发表于 2014-1-23 12:53:51

好的,谢谢

xujinhua 发表于 2014-2-11 17:03:14

顶到高手出来........

荒野孤行 发表于 2016-1-31 22:22:17

本帖最后由 荒野孤行 于 2016-1-31 22:24 编辑


;;;查找相交线(短路)
(defun c:xj      (/ objlis)
(princ "选取直线、多段线、圆、圆弧、样条曲线:")
(vl-load-com)
(setq
    ss (ssget '((0 . "LWPOLYLINE,POLYLINE,ARC,CIRCLE,SPLINE,LINE"))
       )
)
(if (not ss)
    (progn (princ "\n提示:未选取对象.") (exit))
)
(setvar "osmode" 0)
(setq      i   0
      num (sslength ss)
)
(command "LAYER" "M" "层-短路" "C" "251" "层-短路" "")
(repeat num
    (setq ent (ssname ss i)
          obj (vlax-ename->vla-object ent)
    )
    (setq objlis (cons obj objlis))
    (setq i (1+ i))
)
(setq i 0)
(while (< i (- (length objlis) 1))
    (setq obj1 (nth i objlis))
    (setq j (+ 1 i))
    (while (< j (length objlis))
      (setq obj2 (nth j objlis))
      (if (vlax-invoke obj1 'intersectwith obj2 0)
      (progn
          (vla-put-Layer obj1 "层-短路")
          (vla-put-Layer obj2 "层-短路")
      )
      )
      (setq j (1+ j))
    )

    (setq i (1+ i))
)
(alert
    "★提示:如果存在短路的对象,会把它们置于“层-短路”图层!"
)
(alert "若需了解更多功能的程序,欢迎下载WDY工具箱。")
(command "BROWSER" "http://bbs.mjtd.com/thread-108389-1-1.html")
(princ)
)


页: 1 [2]
查看完整版本: 线相交检查