Sorting breps by collinearity and proximity

I have a list of breps sorted by their normals. I need to sort these lists by their collinearity and proximity to create a bounding box around the frames to simplify the groups into one box. A secondary problem will then be making a bounding box(shrink box) around those groups rather than a rectangular shape.

Preferrable would like a solution without plugins, thanks

Attached the frames in a .gh file

FRAMES.gh (4.4 MB)

Strange reverse engineering case that one (in real-life and in some proper AEC/BIM app this type of classification is addressed totally differently - you design things on a per Entity/Space basis etc etc).

Anyway … since you post here I assume that you are familiar with coding.

So … declare a Class with a Type (called, say, BrepInfo) that has Properties suitable for the clustering scope and then GroupBy/OrderBy etc etc (i.e. use P/LINQ).

In general this is a classic soft flat clustering case where adjacent Spaces may own “common” boundary objects (walls, slabs and the likes).