booleanDifference problem

Hy there,
I am having issues with boolean difference sometimes. I could not fiigure out any regularity behind it. Sometimes it works perfect, sometimes not.
Here you see a profile (grey) and the red solid that needs as boolean solid. On the right are already some holes that have been created with the exact same solid. But this one did not work in my plugin. But when I boolean it within Rhino it works without any problems… Any suggestions for this?
here is part of the code doing the boolean:

            booleanDiffResult = Rhino.Geometry.Brep.CreateBooleanDifference(MyBrep, _thisDrillCutter, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
            if (booleanDiffResult != null)
            {
                if (booleanDiffResult.Count() > 0)
                {
                    maxBrep = booleanDiffResult[0];
                    foreach(Brep thisBrep in booleanDiffResult )
                    {
                        vol = thisBrep.GetVolume();
                        if(vol>maxVol)
                        {
                            maxVol = vol;
                            maxBrep = thisBrep;
                        }
                    }
                    MyBrep = maxBrep;
                }
                else
                {
                    if(Rhino.Geometry.Intersect.Intersection.BrepBrep(MyBrep, _thisDrillCutter,RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, out inseCrvs, out insePts ))
                    {
                        if(inseCrvs.Count()>0)
                        {
                            gr = RhinoDoc.ActiveDoc.Groups.Add();
                            tmpBrep.Attributes.ObjectColor = System.Drawing.Color.Red;
                            tmpBrep.Attributes.AddToGroup(gr);
                            tmpBrep.addRhinoObject(RhinoDoc.ActiveDoc);
                            pt = tmpBrep.MyBrep.ClosestPoint(Plane.WorldXY.Origin);

                            warningDot = new roc_dot("drill could not be performed!", pt);
                            warningDot.Attributes.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
                            warningDot.Attributes.ObjectColor = System.Drawing.Color.Red;
                            warningDot.Attributes.AddToGroup(gr);
                            warningDot.addRhinoObject(RhinoDoc.ActiveDoc);
                        }
                    }

                    }
}


                }
              
            }

Here is the file
BooleanDiffProblem.3dm (2.2 MB)

I’ve reported this as a bug.

http://mcneel.myjetbrains.com/youtrack/issue/RH-31606

OK, the gray input is non-manifold. The underlying code called by Brep.CreateBooleanDifference ignores any non-manifold input. I will tune up this function, for V6, to allow for non-manifold input.

So this means @DominikIC needs to close the gray surface and then it will work?

Hy Dale,

cool, thanks! Should have recognized that myself earlier…
Anyway, now I know what I Need to take care of in future :slight_smile:

Well, …
SelOpenPolysrf will select that gray object but when you run DupBorder on it, nothing will be returned - meaning it is closed. The problem is that it’s non-manifold - one of the holes at the bottom of the object touches the bottom side. Of course, I don’t know the design constraints here but I am tempted to say that this hole is in the wrong place (or the object should be a bit longer).

If the design is as it should and you need to fix this manually until RH6 can do the boolean automatically, you can extract the surface of the hole and the two bottom surfaces that are split by the seam of this cylinder. When you join the two planar surfaces and run MergeAllFaces on these and then join all surfaces again, you will end up with a closed polysurface and the boolean will work.

But if you use ShowEdges it will show those 2 points, also when you select the object it tells it is an open surface. Means. It is not closed.

Quark mechanics.
Non-manifold objects are both open and closed at the same time. The single answer depends on your viewpoint.

Yeah thought it would be more complicated as it looks like.
Maybe it is “closed” but Rhino 5 does not recognize it as closed, so it won’t work.