Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a drawing with network of lines and points. I am writing a program to select all points at the end of lines and do some processing.
- select a start point object
- function will do processing on the point object
- function select the lines connecting the point object
- function select the points at the ends of these lines and do processing
- so on till all points are processed in all the branches
I have written the following code. This is not working properly. It process points in one branch and then stops.
(defun c:run( / ent)
(setq line_last nil)
(setq ent (car(entsel)))
(find_point ent)
)
(defun find_point (ent / pt sst sst_line ent_line other_end ent_point cn)
(process_point ent)
(setq sst (ssget "_cp" (get-rect-points (cdr (assoc 10 (entget ent))) 0.1) '((0 . "LWPOLYLINE")) ));;select lines connecting to the point
(if line_last (setq sst_line (ssdel line_last sst)) (setq sst_line sst));;incoming line is removed from selection set
(if (/= (sslength sst_line) 0)
(progn
(setq len (sslength sst_line))
(setq cn 0)
(while (< cn len)
(setq ent_line (ssname sst_line cn))
(setq line_last ent_line)
;;select point on the other end of line
(setq other_end (cdr (assoc 10 (reverse(entget ent_line)))))
(setq ent (ssname (ssget "_cp" (get-rect-points other_end 0.1) '((0 . "POINT")) ) 0))
(if ent (find_point ent))
(setq cn (+ 1 cn))
);while
));if
)
(defun process_point(ent)
(command "change" ent "" "p" "color" "red" "")
)
;;get points of 4 sides at specified distance
(defun get-rect-points (pt dist / pt0$ pt1$ pt2$ pt3$ pt4$)
(setq pt0$ (polar pt 0 dist))
(setq pt1$ (polar pt0$ (/ pi 2) dist))
(setq pt2$ (polar pt1$ pi (* 2 dist)))
(setq pt3$ (polar pt2$ (/ (* 3 pi) 2) (* 2 dist)))
(setq pt4$ (polar pt3$ 0 (* 2 dist)))
(list pt1$ pt2$ pt3$ pt4$ pt1$)
)
Any help would be highly appreciated.
Thanks in advance.
Solved! Go to Solution.