Boolean Difference failure when subtraction objects share a surface

Hello,

I have been progressing my Python skills over the past month or so since I received some help in the early days. I have found that by combining the wealth of information available in the forum with appropriate head scratching, many apparent road blocks have been cleared through knowledge growth.

However, I have been struggling with a Boolean Difference problem for a few days, and I now think that it might be a BD bug.

I found https://discourse.mcneel.com/t/booleandifference-fail/163125/2 which appears to relate to similar circumstances, but perhaps not identical. I notice in YT that there is no resolution yet.

In my case, I have internal walls with 3 components - Frame, Brace and Lining. The wall components were created as extrusions by Python code. As a clean up step, I have Python code to use BD to remove portions of the Lining which overlap Frame and Brace objects.

Whether using the Rhino command line or Python code, BD allows a portion of the Lining to be removed by either Frame or Brace, but not by both. Trying both together fails. Trying either Frame or Brace first works, but then the second fails.

I suspect that it might be due to the fact that Frame and Brace objects have adjacent faces. By changing the width of all Frame objects so that there is separation between them and the parallel Brace objects, BD works when both Frame and Brace are specified together, and also when each is applied separately. This is true for both Rhino command line and Python.

I have attached a sample model with the code.

The first Py3 node establishes some variables.

The second Py3 node is the main logic. It references MyFunct.py, which requires registration in the code. I have commented out the second BD code block, which should not be required, given that both Frame and Brace should be OK as subtraction objects in the first code block. The second code block can be activated for testing.

I have stripped out the code which creates the wall objects, so after each BD test, the model requires an undo to reinstate the wall objects.

Regards, Garry.

AddObjects BoolDiff.3dm (6.0 MB)

AddObjects BoolDiff.gh (11.1 KB)

MyFunct.py (3.6 KB)

first guess:
your details are
0.006 meters
absolute document tolerance
0.0001 m
per rule of tumb - this should be ok (document tolerance = 1/10 of smallest detail)

… further digging…

what should be done exactly ?

please use colors to help stupid readers like me:

frame violet
brace green
lining red

now Boolean whom with what ???

is this what you need ?
boolean difference in two goes work here.
boolean union the cutters first then do boolean difference works too.

  • check tolerances (and play with more precision)
  • check intermediate result for edge tolerance and non manifold edges (what command)
  • test with and without mergeallcoplanarfaces option

hope this somehow helps - kind regards -tom

For me it is also entirely unclear what is the desired result.

It would be nice if you can share the objects that need to be used as cutters and the objects that you use to substract from, as well as the desired end result. If it is a BD problem (likely) we should not focus on any code.

That being said, booleans can be tricky and are relatively time consuming operations. Do you really need to depend on Booleans to generate the end result? If you generate all the geometry in code, then over-modeling the cutters is highly recommended to avoid situations where faces are coplanar.

1 Like

@Tom_P I have added clarification below, but thought that I defined the requirement in…

I have reattached the model with the layer colours set.

I could build separate cutter objects, but I am hoping that the real model objects will do the job, as they define exactly the cutting volume. I had considered the BU approach, but again that seems like steps that should not be required.

The first image shows the Lining objects selected and the Frame and Brace objects with control points. This is before BD.

Pasted Graphic.png

The second image shows a Lining object trimmed by command line BD using Frame as the cutter.

Pasted Graphic 2.png

The third image shows the same Lining object trimmed further by command line BD using Brace as the cutter. This is what is required. Interestingly, it would not work correctly earlier. I have not made any changes to tolerances etc.

Pasted Graphic 3.png

The third image is now also correctly created by command line BD using both Frame and Brace together as cutters. I am sure that it failed in the posted model earlier today.

Even more interestingly, now the Python code is working in the posted model with both Frame and Brace together as cutters.

The only change that I have made is to assign red, green and blue to the 3 layers. However, when I close the model without saving any changes, then reopen it with all layers still black, the command line BD and the Python BD work as expected with both Frame and Brace together as cutters.

I then returned to the full model, and the BD is still failing in both command line and Python. The only difference that comes to mind is that the posted model has the Frame, Brace and Lining objects copied from the full model, where they were created by Python code.

Regards, Garry.

AddObjects BoolDiff.3dm (6.0 MB)

@Gijs and @Tom_P I have another line to investigate. There are additional Frame, Brace and Lining objects in the full model. I will work through them to see if there is a particular set of objects that is causing the problem. I will provide an update later.

Regards, Garry.

@Gijs I have found the wall intersection which is causing the problem. The updated model contains only the walls which have that intersection. As I mentioned above, the posting model was exhibiting the problem earlier today, but at the last minute before posting, I decided to delete most of the wall objects to avoid visual overload. Having deleted, I should have retested the model.

The problem manifests in both Rhino command line and Python, so as you suggested, there is no need to investigate the Python code.

The Lining objects are to be subtracted using the Frame and Brace objects as cutters. For the failing intersection, when cutting with Frame first, then Brace afterwards, the BD works as expected. When cutting with Frame and Brace together, the BD fails.

@Tom_P I have changed the tolerance to 0.00001 in Python, but the BD still failed. Also tried 0.001.

Image 1 below shows the Lining selected for subtraction. Image 2 shows the Frame and Brace selected as cutters.

Rhino Mac Version 8 (8.26.25328.09002, 2025-11-24)

Regards, Garry.

AddObjects BoolDiff.3dm (8.2 MB)

AddObjects BoolDiff.gh (11.1 KB)

MyFunct.py (3.6 KB)

so ist there a minimal setup (files) to repeat the issue / failing boolean ?
and a minimal text to describe what to do ?
e.g: Boolean difference fails: from first object (color 1) subtract 2nd / 3rd (color 2, color 3) - nobody will read such a long description to repeat 3 mouse clicks.

Tom,

Open the model.

Command line Boolean Difference.

Select the Lining objects via the Layers panel as the objects to be cut.

Select the Frame and Brace objects via the Layers panel as the cutters.

The BD fails.

Try with either Frame or Brace and BD works.

Regards, Garry.

1 Like

is n t that the expected result ? :


Version 8 (8.25.25328.11002, 2025-11-24)
on mac intel.

sorry i can not repeat any error - or do i miss something ?

Hi Tom,

I can repeat the error by following the OP’s instructions immediately above and selecting all the items via layers.

However, if I only select the items that actually overlap (i.e. will result in a boolean difference) - which are one lining, one frame and one brace - then the BD succeeds even when using the frame and the brace in a single operation.

It appears to be the blanket inclusion of the irrelevant Frame and Brace elements that causes the BD to fail (it may be a specific element, I don’t have time to try narrowing it down).

Including the irrelevant Lining elements doesn’t matter.

Regards
Jeremy

EDIT: The error does not happen in the WIP, so it looks like improvements made there have fixed it.

Jeremy,

For me, selecting only the one overlapped Lining, then only the one overlapping Frame and one overlapping Brace as cutters results in BD failure.

The model now includes only the 3 overlapping objects.

Regards, Garry.

AddObjects BoolDiff.3dm (5.9 MB)

SysInfo.txt (4.8 KB)