How to find adjacent breps?

How to script a component that finds if two or more breps are adjacent one to the other?
I need to script a component that assesses if two or more breps are adjacent, they need to have at least one surface or part of it touching but they do not have to intersect. I tried using the Intersect and IsPointInside methods but I couldn’t find a solution.

Hi Federico,
I have modified the function rs.IntersectBreps() a little. This code should print whether the selected breps intersect or not.
I am not the best Coder out there, so maybe someone has a better solution :slight_smile:

import Rhino
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc

def Main(tolerance = None):
    brep1 = rs.GetObject("Select the first brep", rs.filter.surface | rs.filter.polysurface)
    if brep1:
        brep2 = rs.GetObject("Select the second", rs.filter.surface | rs.filter.polysurface)
        if brep2: 
            brep1 = rs.coercebrep(brep1, True)
            brep2 = rs.coercebrep(brep2, True)
            if tolerance is None or tolerance < 0.0:
                tolerance = sc.doc.ModelAbsoluteTolerance
            rc = rg.Intersect.Intersection.BrepBrep(brep1, brep2, tolerance)
            if not rc[0]:
                return None
            out_curves = rc[1]
            out_points = rc[2]
            if out_curves or out_points:
                print("The breps intersect")
            else: print("The breps do not intersect")

if __name__ == "__main__":
    Main()