本帖最后由 Gu_xl 于 2012-5-11 16:02 编辑
soly2006 发表于 2012-5-4 11:17
院长把交叉、裂缝、冗余点检查集成,超强!
命令:zxjxjc
- ;;仅供思路参考
- (defun c:ZXJXJC (/ MKCIRCLE GETBOX N NN PICKBOX SS
- BOXSIZE S I L PL OLDPT PTBOX
- PLS PLSS FLAG
- ) ;_ /
- (defun mkcircle (pt r)
- (entmake (list '(0 . "circle")
- (cons 10 pt)
- (cons 40 r)
- (cons 62 1)
- (cons 8 "检查标记")))
- )
- (defun getbox (pt size)
- (list (polar pt (* pi 1.25) (sqrt (* 0.5 size size)))
- (polar pt (* pi 0.25) (sqrt (* 0.5 size size)))
- )
- )
- (setierr)
- (setq n 0 nn 0 pickbox (getvar 'pickbox))
- (setvar 'pickbox 5)
- (while (progn
- (princ "\n选择要检查的物体:")
- (setq ss (ssget '((0 . "lwpolyline"))))
- )
- (gxl-SYS-STORESVIEWSIZE)
- (gxl-SYS-ZOOM_WINDOW (gxl-GETSSBOX ss))
- (setq boxsize (gxl-SYS-GETPICKBOX))
- (setq s nil n 0)
- (repeat (setq i (sslength ss))
- (setq s (cons (ssname ss (setq i (1- i))) s))
- )
- (foreach en s
- (setq l (vl-remove en s))
- (setq pl (mapcar 'cdr
- (vl-remove-if-not
- '(lambda (x) (= 10 (car x)))
- (entget en)))
- oldpt nil)
- (foreach pt pl
- (if (equal pt oldpt 1e-6)
- (progn
- (mkcircle pt (* boxsize 2))
- (setq n (1+ n))
- )
- )
- (setq oldpt pt)
- (setq ptbox (getbox pt boxsize))
- (setq pls (ssget "c" (car ptbox) (cadr ptbox) '((0 . "lwpolyline"))))
- (if pls
- (progn
- (setq plss nil)
- (repeat (setq i (sslength pls))
- (setq plss (cons (ssname pls (setq i (1- i))) plss))
- ) ;_ repeat
- (setq Flag
- (vl-some
- '(lambda (x)
- (not
- (equal (vlax-curve-getclosestpointto en pt)
- (vlax-curve-getclosestpointto x pt)
- 1e-6
- ) ;_ equal
- )
- ) ;_ lambda
- plss
- ) ;_ vl-some
- ) ;_ setq
- (if Flag
- (progn
- (mkcircle pt (* boxsize 2))
- (setq n (1+ n))
- ) ;_ progn
- ) ;_ if
- ) ;_ progn
- ) ;_ if
- )
- )
- (gxl-SYS-RESTORESVIEWSIZE)
- (princ (strcat "\n发现 " (itoa n) "处问题:"))
- (setq nn (+ n nn))
- )
- (princ (strcat "\n总共发现 " (itoa nn) "处问题:"))
- (setvar 'pickbox pickbox)
- (reerr)
- (princ)
- )
- (princ "\n折线间隙检查 By 明经通道 Gu_xl 命令:ZXJXJC")
|