
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Please could someone tell me why this is not working. I am trying the calculate the number of points of intersection that could be created by using the vertices of a polyline. The first point of intersection would be possible once there are four vertices to the polyline. Thereafter, whenever the number of vertices is an even number, another point of intersection becomes available.
In the code below, the variable 'p' is used for the number of points of intersection and the variable 'n' is used for the number of vertices. The trouble is, 'p' is returning too many points of intersection? For example, when I analyse a polyline with 6 vertices, 'p' is 8? I just can't figure out what is wrong with it?
(defun c:r15 ()
(setq e (entget (car (entsel "Select polyline to analyse: "))))
(setq p1 (getpoint "Click where you want the table: "))
(setq p2 p1)
(setq tz (getreal "Enter text height: "))
(setq ct 0)
(setq lnth (length e))
(setq tbly 0)
(setq n 0)
(repeat lnth
(setq ct (+ 1 ct))
(setq tx (nth ct e))
(setq ts (car tx))
(if (= ts 10)
(progn
(setq n (+ 1 n))
(set (read (strcat "crd" (itoa n))) (cdr tx))
)
)
(if (= n 4) (setq p 1))
(if (and
(> n 4)
(= (rem n 2) 0))
(setq p (+ p 1))
)
)
Solved! Go to Solution.