Brep.Split by curves issue

Hi I am trying to make use of this:



What kind of curve does it expect?
How can I make it work with any kind of curve/polycurve?

I could not find any examples of brep split by curve in the forums, yet in Rhino command it works.

Could anyone provide a working example please?

Put the curve in an array.

1 Like

A list with curves.

cutter = [curve] should solve it.

1 Like

I see, I do have a list of curves but I was iterating over each curve passing it to the brep.split method. :smile:

Thanks @menno, @rgr

Hi @menno, @rgr,

What can I do in this situation?

Yes, this is where Python really shows its (in my view) weakness: it has no type information.
The problem is that there are two Split functions that both take 2 arguments. One takes an array of curves, the other an array of surfaces. In strongly typed programming languages, this is sorted out at compile time, but in Python this is not done.

Looks like the following might work (I haven’t tried it)

srf.Split[IEnumerable[Curve]](crv_objs, tol)

Check this topic and links in it for more details

Thanks for the reply @menno

Well arguably that can be seen as a weakness of the .net api for using overloaded methods instead of separate methods :wink:

I tried this:

Now that it failed I’ll take a look at the thread you suggested.

Is there a way to create an enumerator for the overloaded methods and use some integer in order to pick the one I need?

I also tried these:

crvtype = type(crv_objs[0]) #that is a LineCurve

breps = srf.Split[System.Collections.Generic.IEnumerable[Rhino.Geometry.Curve]]([crv for crv in crv_objs], tol)
breps = srf.Split[List[Rhino.Geometry.Curve]]([crv for crv in crv_objs], tol)
breps = srf.Split[Array[Rhino.Geometry.Curve]]([crv for crv in crv_objs], tol)
breps = srf.Split[System.Collections.Generic.IEnumerable[crvtype]]([crv for crv in crv_objs], tol)

All result with

Did you import Array before using it?

This sample works…

import Rhino
import scriptcontext as sc
from System import Array

def splitBrepWithMultipleCurves():
    # get brep
    result, objRef = Rhino.Input.RhinoGet.GetOneObject("Pick brep to split", False, Rhino.DocObjects.ObjectType.Brep)
    if result != Rhino.Commands.Result.Success: return result
    brep = objRef.Geometry()
    # get curves
    result, arrObjRefs = Rhino.Input.RhinoGet.GetMultipleObjects("Pick curves to split with", False, Rhino.DocObjects.ObjectType.Curve)
    if result != Rhino.Commands.Result.Success: return result
    listCurves = [obj.Geometry() for obj in arrObjRefs]
    # construct nice distinct strictly typed Curve array for brep.split overload
    arrCurves = Array[Rhino.Geometry.Curve](listCurves)
    # split the brep
    arrBrepSplitResult = brep.Split(arrCurves, sc.doc.ModelAbsoluteTolerance)
    # Add to doc
    if arrBrepSplitResult:
        for brep in arrBrepSplitResult:
    # redraw viewport so we see what we did
if __name__ == "__main__":

Sure I did

hmm, thanks @lando.schumpich,

Your code worked perfectly.

I need to investigate now the “why”.

i see now, your parentheses are off:

# instead of this:
breps = srf.Split[Array[Rhino.Geometry.Curve]]([crv for crv in crv_objs], tol)
#do this:
breps = srf.Split(Array[Rhino.Geometry.Curve](crv_objs), tol)

Here is some additional information how to use Arrays in ironpython:

1 Like

Damn, I was trying that but after I saw @menno’s comment I didn’t even test. LoL :smiley:


Lovely, thanks @dale

I guess I just had to wait for our NA friends to wake up :slight_smile:

Hi @dale,

Is it possible to add a link to this article, or the example code to the RhinoCommon api documentation?

Somewhere here maybe: