@paliwal222 wrote:
WANT TO SELECT ALL OVER LAPPING POLYLINES,
LAYER,COLOR OR GLOBAL WIDTH, SAME OR DIFFERENT IS NOT MATTER,
WANT TO ERASE BOTH OVERLAPPED OBJECT.
THOUGH I HAVE BREAKED POLYLINES AT OVERLAPPING POINT ALREADY
For your particular case, where all entities are polylines, and overlaps are singe segment polylines (only two points) this will erase all overlapping elements and polylines laying under.
It is important that startpoint and endpoint of overlapping elements coincide. Direction how they are created and other features like layer, color etc. are not considered.
You should break polylines as you stated above.
(defun c:delete_overlap (/ *error* adoc collinear ss i a e eo mm to_delete)
;Author: hak_vz
;Thursday, September 30, 2021
;https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5530556
;Posted at
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-overlapping-polyline-and-delete-both/td-p/10649230
;Erases overlaped polyline segment (2 vertex poly) and polyline under it
(defun *error* ( msg )
(if (not (member msg '("Function cancelled" "quit / exit abort")))
(princ)
)
(if (and adoc) (vla-endundomark adoc))
(princ)
)
(defun collinear (p1 p2 p3 / a b c d)(setq a (angle p1 p2) b (angle p1 p3) c (angle p3 p1) d (angle p3 p2))(or (= a b)(= a c) (= a d) (= b a) (= b c) (= b d)))
(setq adoc (vla-get-ActiveDocument (vlax-get-acad-object)) blocks (vla-get-blocks adoc))
(vla-endundomark adoc)
(vla-startundomark adoc)
(setq ss (ssget '((0 . "LWPOLYLINE")(-4 . "=")(90 . 2))))
(setq i -1)
(while (< (setq i (1+ i)) (sslength ss))
(setq e (ssname ss i) eo (vlax-ename->vla-object e))
(setq mm (cons (list (vlax-Curve-getStartPoint eo)(vlax-Curve-getEndPoint eo) e) mm))
)
(while (and mm (>= (length mm) 2))
(setq a (car mm) mm (cdr mm))
(setq p1 (car a) p2 (cadr a))
(foreach e mm
(setq p3 (car e) p4 (cadr e))
(cond
(
(and
(<= (abs(- (distance p1 p2)(distance p3 p4))) 1e-8)
(or
(or
(apply 'and (mapcar '= p1 p3))
(apply 'and (mapcar '= p1 p4))
)
(or
(apply 'and (mapcar '= p1 p4))
(apply 'and (mapcar '= p2 p3))
)
)
(collinear p1 p2 p3)
(collinear p1 p2 p4)
)
(setq to_delete (cons (last a) to_delete))
(setq to_delete (cons (last e) to_delete))
)
)
)
)
(foreach e to_delete (entdel e))
(vla-endundomark adoc)
(princ)
)
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.