read if you have interest - I think I am trying a different, but very similar, approach.
the real world problem is a single line architectural plan.
the geometry is all polygons, in autolisp LWPOLYLINES, fitting together like pieces in a puzzle.
my goal is to be able to create point lists for the apparent intersections and to insert these as new vertexes.
I start with the perimeter and create a point list.
a point list for a simple rectangle might look like this:
((0.0 0.0) (50.0 0.0) (50.0 30.0) (0.0 30.0))
I modify that list so that instead of representing the vertexes of a rectangle,
the new list represents the endpoints of the implied segments.
(((0.0 0.0) (50.0 0.0)) ((50.0 0.0) (50.0 30.0)) ((50.0 30.0) (0.0 30.0)) ((0.0 30.0) (0.0 0.0)))
I create a filtered fence selection, the fence point list being a straight line: in this case the first would look like this:
f_pt_lst ((6.12303e-018 0.1) (50.0 0.1))
I do get rounding error at times, I think it is because I am using polar to find these points.
with this point list for a fence selection, I (ssget "_F" f_pt_lst '((0 . "LWPOLYLINE") (8 . "rooms")))
and I have all the polygons that have vertexes "on" the first segment of the perimeter.
at this point, any method that would retrieve points on this perimeter segment would serve.
I am comfortable with stripping the points list from a LWPOLYLINE, so I try that first.
in my test file, the first entity in the selection set produces this list
((50.0 4.06105) (50.0 13.2111) (37.362 13.2111) (37.362 4.06105))
the second, and last in this example, polyline having endpoints on the perimeter is
((50.0 13.2111) (50.0 30.0) (25.0 30.0) (25.0 13.2111))
I create a repeat loop with (sslength selection_set) within which I
get the point list for each adjacent polygon and
extract only the points "on" the perimeter.
within the inner loop I thought I would insert the new points for each individual polygon,
but I was using car and cadr on BOTH lists
(car n) being the outer loop and should evaluate ((0.0 0.0) (50.0 0.0)) for the segment to add vertexes to.
then I was testing the angle implied from (caar points), which is (car n) in the foreach, to each point
in the second list, against (angle (0.0 0.0) (50.0 0.0) )
if you START at a point on the perimeter and follow the same angle, the point is on the line.
otherwise, not.
I don't have the points of the interior polygons until I am in the inner foreach.
but the points on the segment are "n" in the outer foreach.
so, I wanted to nest them and see if I could pass "n" into the inner "k" loop.