Room.Boundaries - more curves than walls..?

This is caused by different Room bounding conditions. For example:

Capture

 

 

Capture

 

 

Capture

 

 

 

You are probably noticing a pattern there. Revit has trouble recognizing a wall by its “short” face. Also, in case there was a small break in-between the walls, rooms will automatically fill in the gap to enclose themselves, but in that case - and understandably - there is no wall associated with that particular edge.

Does that make sense?

However, what is possible is what you have originally asked for - that is to join some lines together. This of course comes with a risk of lines not exactly matching to their walls. Let’s say that we assume that every time there is a small modeling mistake (like images above) and Revit automatically fills in the gaps in room boundaries, we can safely say that that short stub of a line can belong to the “next” wall in series. Now, if every time that we encounter a Null in a list of walls, we take a corresponding Curve and join it to the next curve in series, then technically we are just “applying” it to the next wall in series. Then we can just clean the Null reference from the walls list, and we are good to go. Something like this:
Capture

 

 

And here is the code to clean up the Null references in the walls while making some polycurves in curve list:
Capture