To Find Self Intersection of LWPOLYLINE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am posting useful function to find Self Intersection for selected LWPOLYLINE.
You might be having other options, but I find this one as a quickest and Simple
(defun IsSelfIntersect (l / vcnt vcnt1 crossresult pt1 pt2 pt3 pt4)
(setq vcnt 0)
(setq crossresult F)
(repeat (1- (length l))
(setq pt1 (nth vcnt l))
(setq pt2 (nth (1+ vcnt) l))
(setq vcnt1 vcnt)
(setq isdone "T")
(while isdone
(if (and (nth (+ 2 vcnt) l) (nth (+ 3 vcnt) l))
(progn
(setq pt3 (nth (+ 2 vcnt) l))
(setq pt4 (nth (+ 3 vcnt) l))
(if (inters pt1 pt2 pt3 pt4)
(progn
(setq crossresult T)
);progn
);if
);progn
(progn
(setq isdone nil)
);progn
);if
(setq vcnt (1+ vcnt))
);while
(setq vcnt (1+ vcnt1))
);repeat
crossresult
);defun
Below Function to get the Coordinate list of LWPOLYLINE
(defun lwptslw (lst / pair rtn)
(while (setq pair (assoc 10 lst))
(setq rtn (cons (cdr pair) rtn)
lst (cdr (member pair lst))
)
)
(reverse rtn)
)
USAGE:
Command: (IsSelfIntersect (LWPTSLW (ENTGET (CAR (ENTSEL "\nSelect Lwpolyline to find Self Intersectioni")))))
Regards,
Rajesh