Methods for combining non-intersecting lines

I’m working on trying to get a polycurve that represents the outline of a room based on its outer finish wall, and I’m running into an issue due to the way I generate it.

To start, I use the interior boundary of the room, and offset by the wall thickness to create a series of lines that represent the outer boundary of a room.

My current method of joining these is to extend the lines, and create a point at the intersection, which I use for the polycurve.

This works great in 95% of circumstances, however I’m running into a problem when a room has differing wall thicknesses on the same side. By extending the lines, the curves don’t intersect, and the polycurve ignores the jog in the wall.

Picture1

I’ve always felt like my method for drawing the polycurve was a bit sloppy, but I’m having trouble figuring out a better way to get this boundary.

Ideas:

Create a cross at the start and end point of each line, and get the intersections of these points to use as my polycurve boundary.

This works for the indent, however it can’t function on corners due to multiple intersection points.

Take the lines, shift the indices so that a line is drawn from the end of the first line to the start of the second, and wrap your way around the room.

This works perfectly until corners, as it creates and angled line at the room corners, when I need them to be squared off.

Gather all the points (both intersection and start/end points) and run a polycurve through those.

I think this is the solution I’m looking for, but my difficulty here is finding a method to order them so that the polycurve is drawn correctly.

Picture2

I’ve attached the script and a sample revit file, There’s other stuff going on here that’s in various states of disrepair, but the section I’m focusing on right now is grouped in orange.

I would greatly appreciate any help or ideas to test out!

Requires Clockwork:
Room Outer Boundary V7.dyn (112.6 KB)
Revit 2020:
Room Outer Boundary Test.rvt (4.7 MB)

Turns out taking a quick break is all you need!

I walked back through everything and changed the way I get the boundaries.

Now what I do is take the wall geometry, turn it into a flat footprint, and check the lines to see if they’re in the room. Oddly enough I need to use a point in the middle, because the start/end points at the corners aren’t considered in the room, even though they’re the inner boundary points.

From there, I filter out the inner lines, and I’m left with outer lines to merge!

As an added bonus it works on circles, which was something I was planning on fixing later.