Saving Intersecting BREPs goes wrong (Rhino Inside API)

I have this code:

def has_overlap(brep_list1, brep_list2, tolerance):
for brep1 in brep_list1:
for brep2 in brep_list2:
success, intersectionCurves, intersectionPoints = Rhino.Geometry.Intersect.Intersection.BrepBrep(brep1, brep2, tolerance)
if success:
file3dm = Rhino.FileIO.File3dm()
file3dm.Objects.AddBrep(brep1)
file3dm.Objects.AddBrep(brep2)
temp_file = tempfile.NamedTemporaryFile(suffix=‘.3dm’, delete=False)
temp_file.close()
file3dm.Write(temp_file.name, 7)
print(“temp_file”, temp_file.name)
return True
return False

And when I run it on a test case with no overlaps I get success and this result:

image

How is that possible?

Version: 8.9.24194.18121 | 12. Juli 2024 | 600.2 MB

Looks like the result success is a measure if the intersection operation itself succeed, and did not get any bogus input or encounter an unexpected error. I think you will find that the intersectionCurves and intersectionPoints will both be empty and you should use that as a measure of whether or not two breps intersect.

Does that help?

Indeed:

Adding

if len(intersectionCurves) > 0:

seems to work!

Thank you!

PS: It would be nice to mention that in the documentation…

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.intersect.intersection/brepbrep

Anyway I can add that?

Documentation is indeed not explicit about this. You cannot edit this yourself, but I’ll make sure it gets clarified.