Boolean Split in Python?

Hey everyone. This is my first attempt at writing a full script from beginning to end, and I’ve run into a problem. I noticed there isn’t a Boolean Split function in Rhino Python, so I had to work around it. Basically what I’m trying to do is take a whole model, create a cut plane, and split the bottom .25" so that both parts of the split model are separate closed polysurfaces. Here is the function that I wrote that does this:

For clarification, the variables I’m importing in the function are “obj_base,” which is a 2" base I created at the bottom of the model (the top surface of which I’m moving to create my cut plane) and “obj,” which is the model itself that is being cut.

I’m getting hung up on line 127 where it is trying to cap planar holes due to the BrepSplit function creating open faces on both halves of my model. I think I can work around this problem if I could just use a Boolean Split that would create two closed polysurfaces.

I’ll attach a commented file of the script as well in case there are further questions on how to solve this problem. The included blocky model works without problems, but when I imported a model from an actual job I am working on (sorry, not allowed to include that in the file), that’s when I ran into problems. But with that model I got an error on line 127 (line 130 in the included .py file) saying that it is unable to convert None into Brep geometry.

Thanks in advance for your help
-Rob

Slipcast Creation_TEST 3.py (5.1 KB)
Slipcast Creation_TEST2.3dm (165.2 KB)

There is no automatic split brep routine in rhinoscriptsyntax. The splitting Brep could be non-planar, so planar capping cannot be guaranteed. What BooleanSplit does is split both the object(s) to be split and a copy of the splitting object(s) then joins the necessary parts together and deletes the rest.

Without checking everything, I see when you do a rs.BooleanUnion on line 125, that returns a list (as the result could be several objects) - or perhaps None if it fails…

new_base = rs.BooleanUnion(obj_join, True)

new_base will be a list… However rs.CapPlanarHoles wants a single item.

obj_base_new = rs.CapPlanarHoles(new_base) will fail if you feed it a list.

You would need to loop through the list cap each item separately. However, as you are getting the message unable to convert None into Brep geometry, seems like the BooleanUnion is erroring out…

I might try scripting this more simply by scripting the actual Rhino commands BooleanUnion, BooleanSplit, etc…

–Mitch