就你这个图,下面的程序能解决,但不知道你真正的图中是否有别的情况,主要是 1.梁为lwpolyline,而且只有两个顶点,没有圆弧2.墙为LINE,- (defun Check(ents1 ents2 / ptc pt1 pt2)
- (setq ptc (mapcar '(lambda(e1 e2) (/ (+ e1 e2) 2.0)) (cdr (assoc 10 ents2)) (cdr (assoc 11 ents2))))
- (setq pt1 (cdr (assoc 10 ents1)))
- (setq pt2 (cdr (assoc 10 (cdr (member (assoc 10 ents1) ents1)))))
- (if (equal (angle pt1 ptc) (angle ptc pt2) 0.000001)
- t
- nil
- )
- )
- (defun c:test( / ss1 ss2 ents1 ents2 ent2 i j)
- (setq ss1 (ssget "x" '((0 . "LWPOLYLINE") (8 . "梁"))))
- (setq ss2 (ssget "x" '((0 . "LINE") (8 . "墙"))))
- (if (and ss1 ss2)
- (progn
- (setq i 0)
- (repeat (sslength ss1)
- (setq ents1 (entget (ssname ss1 i)))
- (setq j 0)
- (while (< j (sslength ss2))
- (setq ent2 (ssname ss2 j))
- (setq ents2 (entget ent2))
- (if (check ents1 ents2)
- (progn
- (if (assoc 62 ents1) (setq color (cdr (assoc 62 ents1))) (setq color 256))
- (if (assoc 62 ents2)
- (setq ents2 (subst (cons 62 color) (assoc 62 ents2) ents2))
- (setq ents2 (append ents2 (list (cons 62 color))))
- )
- (entmod ents2)
- (ssdel ent2 ss2)
- );progn
- (setq j (1+ j))
- );if
- );while
- (setq i (1+ i))
- );repeat
- );progn
- );if
- (princ)
- )
|