Bug Rhino7 Mesh.CreateBooleanIntersection

Hello

I came across what appears to be a bug in Rhino.Geometry.Mesh.CreateBooleanIntersection. I am running the attached Python code on the two meshes in the attached file. One of the meshes has two vertices very close to each other at a distance of about 0.08, this is correct.

MeshBoolean200321.3dm (39.5 KB) MeshBoolean200321.py (791 Bytes)

import rhinoscriptsyntax as rs
import Rhino
selectedA = rs.GetObject(‘mesh a’,32)
selectedB = rs.GetObject(‘mesh b’,32)
for offsetX in [0, 200, -200]:
if offsetX:
meshA = rs.coercemesh(rs.CopyObject(selectedA,[offsetX,0,0]))
meshB = rs.coercemesh(rs.CopyObject(selectedB,[offsetX,0,0]))
else:
meshA = rs.coercemesh(selectedA)
meshB = rs.coercemesh(selectedB)
booleansAB = Rhino.Geometry.Mesh.CreateBooleanIntersection([meshA],[meshB])
booleansBA = Rhino.Geometry.Mesh.CreateBooleanIntersection([meshB],[meshA])
print offsetX, ((‘AB closed’ if booleansAB[0].IsClosed else ‘AB open’)if booleansAB else ‘AB failed’)
print offsetX, ((‘BA closed’ if booleansBA[0].IsClosed else ‘BA open’)if booleansBA else ‘BA failed’)

In Rhino 6, all booleans fail. In Rhino 7 curiously, I get the following result:

0 AB open
0 BA failed
200 AB open
200 BA failed
-200 AB closed
-200 BA closed

The same applies if done manually in Rhino 7: If I copy or move the objects by -200 along the x-axis they boolean fine, otherwise not.

As it might take time to fix the Rhino code, is there any quick fix I can do, such as rebuilding the mesh or similar? Thank you very much!

Hi @Ano,

As you assumend, this seems to be a problem with Rhinos internal MeshBooelan Code. Curiously running _MeshIntersect on your two test meshes yields a perfect closed Curve lying on both meshes, so its quite wierd thast the boolean fails. I Tried this in R6, definitely something for @piac to look at as an example for his rewrite of the Mesh Intersection code.

To maybe fix your immediate problem in the meantime:
Since your meshes are rather simple, I would convert them to Polysurfaces via the _ToNurbs command and do the boolean operations on those, as that code is more robust. You can then make a Mesh out of the result again via _Mesh

1 Like

Hi Chris @Ano

yes, there’s no new code for MeshBoolean in V7 WIP, yet – it’s the same as in V6 right now. The commands that have new code are listed on that page.

I created report RH-57533 so that this does not get lost.
Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

1 Like

Hello Lando and Giulio @lando.schumpich @piac

Thank you for looking into this. The other ugly thing I did was moving my geometry around by random vectors until it found a position where it worked.

@piac, it does not seem to be true that V7 uses the same code as V6. In V6 the booelans always failed, in V7 they sometimes work.

Best,

Chris

Oh you are right! I think the previous team added some tweaks to make it more robust. It’s still the old code, with some tweaks.