BooleanDifference Fail

I came across this while trying to figure out why one of my scripts was failing, after trying to isolate the problem I finally figured out that it wasn’t actually a scripting logic error but that the RhinoCommon Brep.CreateBooleanDifference() method was failing for some reason. I then checked the normal Rhino BooleanDifference command with the same objects and found it also failed.

The odd thing is that it is such a simple case, and that it represents a general problem not related to a specific set of objects - I was surprised to not have discovered it previously. The file is a V7 file, but the same thing happens in V8.

It happens if any single one of the objects in the first group - to be subtracted from - is completely ‘eaten’ by the object(s) to subtract with. The BooleanDifference will then simply fail. The file below has just a box and two cylinders, one of the cylinders is completely enclosed by the box. Try subtracting the box from the two cylinders, it fails. BooleanUnion, BooleanIntersection, and even BooleanSplit all work in this case.

BDFail.3dm (2.0 MB)

IMO, the objects completely ‘eaten’ by the BD should just go away, it should not fail in this type of case.


In testing further, I found that if the cylinder in the middle of the box is scaled 1D vertically so that the top and bottom faces are not concurrent with the top bottom faces of the box (i.e. completely inside the box), it is indeed removed by the BD. Therefore I conclude this is less of a general case as I first thought; perhaps it is a problem with the concurrent surfaces confusing things, causing the ‘containment detection’ algorithm to fail in this case.

It seems that only when selecting both cylinders, it removes the inner cylinder when it is fully inside the box, otherwise I get a ‘Objects do not intersect’

I’m not seeing that here. If I select just the cylinder that is in the middle as the part to subtract from and the the box as the part to subtract with, I get simply “Boolean difference failed.” I don’t see an “Objects do not intersect” message, which would also be wrong anyway, as they do.

Note this happens with anything I can make that has at least one concurrent planar surface with the box, in the file with additional examples, the cone has only one surface that is concurrent with the bottom of the box, it still fails. The spheres and the ellipsoids work if you select both, but fail if you only select the one in the center.

BDFail2.3dm (7.8 MB)

Again, if you modify the inside objects so that they do not touch the box, then if they are selected with any other object that does, the BD will succeed. But alone they will still fail.

It seems to me there is a logic conflict with how Rhino decides this stuff. If there is a single item that would be completely removed by the BD - or would form a non-manifold object in the case of a smaller volume enclosed by a bigger one - Rhino decides this is a ‘failure’ and does nothing. If another object (that would normally be valid for the BD) is chosen along with the first, then Rhino gets conflicted trying to decide whether it should eliminate the problem object or not. If it has no closed curve intersection, it gets deleted and the operation is considered successful. However if a closed curve intersection is found - i.e. when at least one surface is concurrent with the box - then it decides that the whole operation is a failure and does nothing.

Note in all of these cases, BU, BI and BSplit all work all of the time.

yes, I get that too, but I was saying, if one of the objects is fully inside, and you select only that one, it will not substract, but with one that is fully inside and the other intersecting, it would delete the object that is fully inside.

Thanks for the additional sample Iogged this as RH-75954 BooleanDifference fails