Brep.CreateBooleanDifference and Brep.CreateBooleanUnion switched?

When writing Python for Rhino on the Mac
when I call CreateBooleanDifference, I get the Union of the inputs
when I call CreateBooleanUnion, I get the Difference of inputs

When I perform the steps manually in Rhino it works fine, but when I try to do it in code it seems to be swapped.

Is anyone else seeing this problem?

I am running Rhino version 5.1 (58161) with Iron Python version 5.1.2015.131

I kinda doubt this is the case, tests here seem to work OK… Is this happening with any two objects, or just certain ones. Can you post a sample file and some code to test? --Mitch

It appears that the problem lies with performing a boolean on a SumSurface

My test code creates a “capped cylinders” using an Extrusion, a Cylinder, and a SumSurface. It then performs the boolean with a Cone and each of the three “capped cylinders”. The SumSurface. boolean was the only one that appears to be swapped

Note that if I add these “geometries” to the document and then perform the boolean via the UI, everything is good.

I’ll dig into it a little more.

SumSurface is not the problem. The problem seems to be adding caps to the cylinder. Both an Extrusion and a Cylinder can be created with caps.
SumSurface does not, so I needed to call CapPlanarHoles. I changed the code so that none of the cylinders were created with caps and called CapPlanarHoles to cap each cylinder. This resulted in the incorrect boolean results for all cylinders.

I tried the same experiment using boxes that were capped using CapPlanarHoles and they work fine with the boolean operation.

Note also that with the cylinders, calling CreateBooleanIntersection results in what appears to be a union. Boxes give the correct result.

When the results of Boolean operations end up inverted, it’s almost always because one or more of the objects are open and have the normals facing the wrong way. Since your explanations involve capped or uncapped objects, I suspect that’s the case, you’re assuming the normals face outwards when they don’t. However, as you didn’t post an example, impossible to say for sure.

–Mitch