本帖最后由 jun353835273 于 2020-3-2 10:50 编辑
借花献佛,代码是应该是lee大佬的
试一试这个,只删除重叠直线的
- (defun c:killline ( / _line _online a e i l s )
- (defun _line ( a b )
- (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 b)))
- )
- (defun _online ( p a b )
- (equal (+ (distance p a) (distance p b)) (distance a b) 1e-8)
- )
- (if (setq s (ssget '((0 . "LINE"))))
- (progn
- (repeat (setq i (sslength s))
- (setq e (entget (ssname s (setq i (1- i))))
- l (cons (list (cdr (assoc 10 e)) (cdr (assoc 11 e))) l)
- )
- )
- (while (setq a (car l))
- (foreach b (setq l (cdr l))
- (cond
- ( (or
- (and
- (equal (car a) (car b) 1e-8)
- (equal (cadr a) (cadr b) 1e-8)
- )
- (and
- (equal (car a) (cadr b) 1e-8)
- (equal (cadr a) (car b) 1e-8)
- )
- )
- (apply '_line a)
- )
- ( (and
- (_online (car a) (car b) (cadr b))
- (_online (car b) (car a) (cadr a))
- (not (equal (car a) (car b) 1e-8))
- )
- (_line (car a) (car b))
- )
- ( (and
- (_online (car a) (car b) (cadr b))
- (_online (cadr b) (car a) (cadr a))
- (not (equal (car a) (cadr b) 1e-8))
- )
- (_line (car a) (cadr b))
- )
- ( (and
- (_online (cadr a) (car b) (cadr b))
- (_online (car b) (car a) (cadr a))
- (not (equal (cadr a) (car b) 1e-8))
- )
- (_line (cadr a) (car b))
- )
- ( (and
- (_online (cadr a) (car b) (cadr b))
- (_online (cadr b) (car a) (cadr a))
- (not (equal (cadr a) (cadr b) 1e-8))
- )
- (_line (cadr a) (cadr b))
- )
- )
- )
- )
- )
- )
- (princ)
- )
|