RhinoCommon Split Brep with multiple Breps

Just wanted to follow up on the limitation that @Helvetosaur had with intersecting cutters.
I note that when using
Split(self: Brep, cutters: IEnumerable[Brep], intersectionTolerance: float)
everything seems to split fine now; even with intersecting Brep cutters.

However, I am seeing the original limitation still happening with
Split(self: Brep, cutters: IEnumerable[Curve], intersectionTolerance: float)
I can’t seem to get intersecting curves to properly split surfaces. Only the curves in one direction are used to split the surface and I have to run the script again to split in the other direction.

I’d prefer to use Breps to do the splitting but it takes forever if I have a large selection of surfaces to split mutually. Interestingly, I’ve found it is much faster to find BrepBrep intersecting curves and then split the surface with those curves than just split the surface with the intersecting surfaces. I can even run my script twice to catch the surface splits that got missed on the first pass and its still faster than just splitting with the Breps.

Any thoughts on this or work-arounds would be appreciated as my runs can sometimes take a half an hour or more and I’d like not to have to run it twice if there is a better way, or a bug that needs fixing.

Hi @NavArch,

Have you had success with this override?

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_Split_4.htm

– Dale

I’m a little hesitant to use this method as I’m not always splitting planar surfaces and I can get some odd shaped splits if the vector is not in a good direction.

I did try to get it to work, but am getting this error:
Message: No match found for the method signature Split[IEnumerable1, Vector3d, Boolean, Double]. Expected [IEnumerable1, Double], [IEnumerable1, Vector3d, Boolean, Double], [IEnumerable1, Double], [Brep, Double], [Brep, Double, Boolean&]

Here is the code sample

Rbrep = rs.coercebrep(brep, True)
tol = sc.doc.ModelAbsoluteTolerance
norm = rs.SurfaceNormal(brep,[0.5,0.5])
pieces = Rbrep.Split.Overloads[IEnumerable[Rhino.Geometry.Curve], Rhino.Geometry.Vector3d, System.Boolean, System.Double](Rcutters, norm, True, tol)              

What might I be doing wrong?
Thanks

Sorry,
I just remembered we had almost this exact same conversation 6 months ago. I can try the method you suggested again, but looking back at the previous thread I did get it to work and it did split non-planar surfaces poorly.

So really my question is: Should the Basic Curve method (no input vector) work with intersecting curves on a planar surface?

Hi @NavArch,

The method I just mentioned works more like the Split command.

Can you post what you are trying to split?

– Dale

Here is the sample model:
I am having trouble with the highlighted surface that is getting split by the two stiffeners. My script will only split the surface into two parts instead of three. If I run it again it will get the other split.

Is there something obviously wrong with my code that would make the alternate method you suggested give me that error?
Thanks again

Split Test Model.3dm (1.1 MB)

Hmm…

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import time
import System

tol=sc.doc.ModelAbsoluteTolerance

def sps(b, s):
    #Rhino.Geometry.Brep.Split.Overloads[System.Array[Rhino.Geometry.GeometryBase, Rhino.Geometry.Vector3d, System.Boolean, System.Double]()
    lst = System.Collections.Generic.List[Rhino.Geometry.GeometryBase](s)
    b.Split.Overloads[System.Collections.Generic.IEnumerable, Rhino.Geometry.Vector3d, System.Boolean, System.Double](lst, Rhino.Geometry.Vector3d.XAxis, True, tol)


if __name__ == "__main__":
    
    objs_ids = rs.GetObjects("Select Objects: ",rs.filter.surface+rs.filter.polysurface)
    objs = [rs.coercebrep(ID) for ID in objs_ids]
    
    cutters_ids = rs.GetObjects("Select split plane: ", rs.filter.surface)
    cutters = [rs.coercebrep(cutter_id) for cutter_id in cutters_ids]
    
    sps(objs[0], cutters)

What’s the difference between:
[IEnumerable'1, Vector3d, Boolean, Double]
and
[IEnumerable'1, Vector3d, Boolean, Double]
???

:thinking:

Hi @NavArch,

I’m confused. We’ve been talking about splitting Breps with curve. But your model doesn’t have any curves. So what in this model are you trying to split and with that? Can you reduce the model to what is needed?

Thanks,

– Dale

I know this is an old thread but this is the title:
RhinoCommon Split Brep with multiple Breps

image

It kinda doesn’t

Dale,
I see why you are confused. I should have explained a little more.
Beacuse I found splitting Breps with Breps to be slow (when mutually splitting a large number of surfaces) my code first finds intersection curves. It then tries to split the surface with those intersection curves.

Ivelin is correct that I’m trying to split the triangular surface with the two stiffeners. My code correctly finds the intersection curves between it and the stiffeners but the split overload for curves will only split the surface along one of the curves and ignores the second. However I can rerun the script and the second split will happen then.

I left the other geometry in because I found in my own testing that how the surface gets split is dependent upon the intersection curves. Since my script will pick up the intersection with the green surface and the large curved polysurface I didn’t want to ignore them.

Hope that clarifies things. Thanks again for your help
Ian

Hi @NavArch,

Thanks for the clarification. I am able to repeat what you report and I’ve logged the issue:

https://mcneel.myjetbrains.com/youtrack/issue/RH-58024

In the mean time, you might see if the attached script is of any help.

rhino_brep_split.py (1016 Bytes)

Thanks,

– Dale

Thanks Dale,

I’ve got your script working. If I can get the cutter list function to be faster then it looks like a good work around for now.

Looking forward to having the bug fixed of course.
Thanks Again