Rhino.Geometry.Brep.CreateBooleanDifference not creating difference (

Hi there,

I am trying to cut texts into solids.
The result I am getting is an empty array/list.

I know that all the breps created face to the outside, but that should not be a problem I suppose.

for n in annotations:

    vector = n.Plane.ZAxis
    vector = vector * (-1)

    dim_style = Rhino.RhinoDoc.ActiveDoc.DimStyles.Current

    polysrfs = n.CreatePolySurfaces(dim_style, 10)

    for polysrf in polysrfs:
        if polysrf != None:

            polysrf.Translate(vector)
            #polysrf.Flip()
            #Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(polysrf)

#Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(panel)

tolerance = scriptcontext.doc.ModelAbsoluteTolerance

newbreps = Rhino.Geometry.Brep.CreateBooleanDifference([panel], polysrfs, tolerance)
print (newbreps)
print (Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(newbreps[0]))

panel and annotations are variables from the rest of the code.
The model itself looks like this


and the texts and everything is created perfectly fine.

Any idea what I am missing?

Thanks,
T.

Hi @tobias.stoltmann,

Can you post your geometry? If you don’t have any geometry, then can you provide a working sample, that we can run here, that reproduces the problem?

Thanks,

– Dale

@dale
Thanks first of all for the solution - and sorry for not posting this earlier.

for brep in out_breps:
    
    # new and improved!
    brep.Faces.SplitKinkyFaces(Rhino.RhinoMath.DefaultAngleTolerance, True)
    if Rhino.Geometry.BrepSolidOrientation.Inward == brep.SolidOrientation:
        brep.Flip()

@dale
Concerning the solution above everything is working fine.

But I have noticed a very strange thing.
Sometimes, when I run the code not all polysurfaces I wanna subtract are subtracted.
It’s not always happening like that, most of the times everything works perfectly fine.

Here’s an example:
This is what it is supposed to look like:

This is what it looks like from time to time.

Of course I always check if the code produces a bug and I simply will redo the whole thing.
But in general I would be very interested what the problem could possibly be.
May it have to do with the view that I have to redraw before performing the boolean operation?
Or would the view always have to be oriented towards the “subtractee”?

Thanks,
T.

@dale
just asking… did you have any time to look into this?

Hi @tobias.stoltmann

Thanks,

– Dale

Hi @dale,
sorry.
So here we are.
Most of the time I get this:

But sometimes this is a possible result as well.

Testfile.3dm (59.7 KB) Testfile.py (882 Bytes)
Here are the files I re-created hte problem in.

Hi @tobias.stoltmann,

See if this works any better.

test_boolean_difference.py (1.1 KB)

– Dale

@dale
never replied to this one, sorry.
working fine!