# Cut object by plane

**URL:** <https://discourse.mcneel.com/t/cut-object-by-plane/68731>\
**Category:** Rhino Developer\
**Tags:** rhinocommon\
**Created:** [August 13, 2018, 2:38pm UTC](https://discourse.mcneel.com/t/cut-object-by-plane/68731 "2018-08-13T14:38:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexander.meyer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alexander.meyer/32/110574_2.png) [@alexander.meyer](https://discourse.mcneel.com/u/alexander.meyer)\
**Post date:** [August 13, 2018, 2:38pm UTC](https://discourse.mcneel.com/t/cut-object-by-plane/68731/1 "2018-08-13T14:38:29Z")

</div>

I have an ObjRef from GetObject.

Now I want to split this object in 3 parts by dividing with to planes . Is there a way to do this?

Basically I would like to have a version of [https://developer.rhino3d.com/5/api/RhinoCommonWin/html/M\_Rhino\_Geometry\_Brep\_CreateContourCurves.htm](https://developer.rhino3d.com/5/api/RhinoCommonWin/html/M_Rhino_Geometry_Brep_CreateContourCurves.htm) where I just get an array of objects back, divided along the conture lines.

EDIT:  
Ok, I tried some things.  
The most promising lead was this post by Dale [RhinoCommon Brep split by plane](https://discourse.mcneel.com/t/rhinocommon-brep-split-by-plane/62869/2?u=alexander.meyer)  
I did like it was written there, I get a PlanarSurface, when I draw it, it is straight throug my object etc. But Brep.Split simply continues returning 0 objects. This is slowly a bit unnerving.

Effectively, I just need the functionality of the BooleanSplit Comman in the Interface. I also tried RunScrip to use the BooleanSplit directly, but it also just returnes with false…

---

<div class="post-metadata">

**Author:** ![Chuck\_Driesler](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/chuck_driesler/32/758802_2.png) [@Chuck\_Driesler](https://discourse.mcneel.com/u/Chuck_Driesler)\
**Post date:** [August 13, 2018, 3:46pm UTC](https://discourse.mcneel.com/t/cut-object-by-plane/68731/2 "2018-08-13T15:46:40Z")

</div>

In pseudocode, I would do something like this:

> `List<ObjRef> SplitByPlanes(ObjRef obj, List<Plane> cutters) {`  
> `--`  
> `--var splitObjs = new List<obj> {obj};`  
> `--`  
> `--foreach (Plane cutter in cutters) {`  
> `----`  
> `----var objCache = new List<obj>();`  
> `----`  
> `----foreach (ObjRef obj in splitObjs) {`  
> `------`  
> `------objCache.Add(SplitByPlane(obj, cutter));`  
> `----}`  
> `----`  
> `----splitObjs = objCache;`  
> `--}`  
> `--`  
> `--return splitObjs;`  
> `}`
> 
> `List<ObjRef> SplitByPlane(ObjRef obj, Plane cutter) {`  
> `--return obj.Split(obj, cutter);`  
> `}`

---

<div class="post-metadata">

**Author:** ![alexander.meyer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alexander.meyer/32/110574_2.png) [@alexander.meyer](https://discourse.mcneel.com/u/alexander.meyer)\
**Post date:** [August 14, 2018, 7:02am UTC](https://discourse.mcneel.com/t/cut-object-by-plane/68731/3 "2018-08-14T07:02:22Z")

</div>

Hi Chuck,

thank you for your answer.

The generall setup is clear to me - what I need is the function to perform the actuall splitting, in your code the

> [@Chuck\_Driesler](#):
>
> obj.Split(obj, cutter);

As far as I can see, the ObjRef Class does not offer a function “Split” ([RhinoCommon API](https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_ObjRef.htm))

I can only find a split method for Breps ([RhinoCommon API](https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_Split.htm)), but this also requires an Brep as cutter, and planes cannot be converted to Breps.  
I think I could somehow piece together a way to represent my plane as Brep, but it seems like an unnecessary detour to me. Thus I was wondering if there is a more direct way.

---

<div class="post-metadata">

**Author:** ![alexander.meyer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alexander.meyer/32/110574_2.png) [@alexander.meyer](https://discourse.mcneel.com/u/alexander.meyer)\
**Post date:** [August 14, 2018, 9:23am UTC](https://discourse.mcneel.com/t/cut-object-by-plane/68731/4 "2018-08-14T09:23:09Z")

</div>

Ok, I tried some things.  
The most promising lead was this post by Dale [RhinoCommon Brep split by plane](https://discourse.mcneel.com/t/rhinocommon-brep-split-by-plane/62869/2?u=alexander.meyer)  
I did like it was written there, I get a PlanarSurface, when I draw it, it is straight throug my object etc. But Brep.Split simply continues returning 0 objects. This is slowly a bit unnerving.

Effectively, I just need the functionality of the BooleanSplit Comman in the Interface. I also tried RunScrip to use the BooleanSplit directly, but it also just returnes with false…

---

<div class="post-metadata">

**Author:** ![Chuck\_Driesler](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/chuck_driesler/32/758802_2.png) [@Chuck\_Driesler](https://discourse.mcneel.com/u/Chuck_Driesler)\
**Post date:** [August 14, 2018, 12:46pm UTC](https://discourse.mcneel.com/t/cut-object-by-plane/68731/5 "2018-08-14T12:46:56Z")

</div>

My bad, `obj.Split` was a bit of a hand-wave because I wasn’t sure either, misunderstood.

Do you have a copy of the brep and plane returning nothing that you can upload? Dale’s example looks like it should work pretty reliably.

Also, a few alternatives to test (that are actually real, but maybe not as efficient):

`brep.Trim(plane, tolerance)` result is one contour  
`plane.Flip()`  
`brep.Trim(plane, tolerance)` result is next brep to trim

or

`Geometry.Intersect.Intersection.BrepPlane(brep, plane, tolerance, out crv, out pt)`  
`var splitter = Brep.CreatePlanarBrep(crv)`  
`Brep.Split(splitter)`

---

<div class="post-metadata">

**Author:** ![alexander.meyer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alexander.meyer/32/110574_2.png) [@alexander.meyer](https://discourse.mcneel.com/u/alexander.meyer)\
**Post date:** [August 22, 2018, 8:53am UTC](https://discourse.mcneel.com/t/cut-object-by-plane/68731/6 "2018-08-22T08:53:53Z")

</div>

Ok, I am now just converting everything to a Mesh (object and splitting plane) and can then do Mesh.CreateBooleanSplit

This works, but having to convert everything is somewhat cumbersome. There really should be a Split(Obj, Plane) Method…
