# Trim curve with another curve

**URL:** <https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974>\
**Category:** Grasshopper\
**Tags:** windows\
**Created:** [January 7, 2023, 12:00pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974 "2023-01-07T12:00:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 7, 2023, 12:00pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/1 "2023-01-07T12:00:08Z")

</div>

Hello, GH community.  
I have a closed curve and two curves ( Those two curves are outside of the curve, see pic, a.).  
I want to get the desired result ( see pic, b.-curve in red color). What is the easiest and most convenient way to do this in GH? I tried many ways but have not figured out how to trim the closed curve with those two curves. Thx

 ![snt_1](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/1/d/c1d0e4368c225e17cdcee852f72ff49cf1d04679.png)

---

<div class="post-metadata">

**Author:** ![magicteddy](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@magicteddy](https://discourse.mcneel.com/u/magicteddy)\
**Post date:** [January 7, 2023, 12:15pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/2 "2023-01-07T12:15:28Z")

</div>

Hello,

After ordering the open curves around the closed one, and flipping their end points accordingly, this is a game of projecting the points and extract the correct subcurves. You could skip the first part if your curves are correctly drawn and referenced, but this should work for any amount of curves.

You get three open curves as a result in this example.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/a/e/3aec870628945271cbad93d7bae5604c69dae8a4.jpeg)

[TrimClosedCurve.gh](https://discourse.mcneel.com/uploads/short-url/8qmmtxJ3d3U1voQluG2IurcKi1O.gh) (13.2 KB)

---

<div class="post-metadata">

**Author:** ![magicteddy](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@magicteddy](https://discourse.mcneel.com/u/magicteddy)\
**Post date:** [January 7, 2023, 12:24pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/3 "2023-01-07T12:24:27Z")

</div>

Another solution with `Trim with Breps` that doesn’t require sorting.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/a/e/f/aef0547a2df1f8bb1393663f1fcb9a0ca4ea2c7d.png)

[TrimClosedCurve2.gh](https://discourse.mcneel.com/uploads/short-url/rXi6MZz04E4ZM2D0reQ41OtYQBx.gh) (8.2 KB)

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 7, 2023, 12:40pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/4 "2023-01-07T12:40:58Z")

</div>

Thank you a lot for your quick reply, Teddy. Both solutions work perfectly. I will examine it in more detail )))

---

<div class="post-metadata">

**Author:** ![anon39580149](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@anon39580149](https://discourse.mcneel.com/u/anon39580149)\
**Post date:** [January 7, 2023, 2:42pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/5 "2023-01-07T14:42:20Z")

</div>

Check this as well

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/4/4/e443ebdbfa4467dc58f1692d7503be46ec989201.png)

[split & join.gh](https://discourse.mcneel.com/uploads/short-url/tXbiQeRY9EO0p58pWe2QrQxab6q.gh) (10.3 KB)

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 7, 2023, 5:28pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/6 "2023-01-07T17:28:45Z")

</div>

Thank You, Khaled. Another interesting approach indeed. This is the way I was trying to solve this issue but riched only the point “Region Union”, after that I could not figure out how to cull the top parts of the curve )))  
An instant question… Is it possible to sweep any profile along the resulting curves? ( actually, I wanted these solutions because of floor molding). Thx again 🙏

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 7, 2023, 5:30pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/7 "2023-01-07T17:30:08Z")

</div>

Teddy, is it possible to use sweep 1 component or something like that along the resulting curves?

---

<div class="post-metadata">

**Author:** ![magicteddy](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@magicteddy](https://discourse.mcneel.com/u/magicteddy)\
**Post date:** [January 7, 2023, 5:34pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/8 "2023-01-07T17:34:27Z")

</div>

Have a look at this thread.  
Hopefully the sharp corners don’t mess up the sweep, it will depend on your section I guess.

> [@Pipe but with Triangle](https://discourse.mcneel.com/t/pipe-but-with-triangle/152958):
>
> Hi guys, I need some help please; I have a triangle which i want to use for follow me in Grasshopper and i want this to be done along the arch which i have created (Please see attached script). The issue is that the triangle is currently flat on the xy axis and it also does not align with the arch. [image] [image] [Follow me.gh](https://discourse.mcneel.com/uploads/short-url/sNePOtCo0UMOmZ6F2JwUo5sm7yW.gh) (6.9 KB)

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 7, 2023, 9:25pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/9 "2023-01-07T21:25:40Z")

</div>

Yep, Teddy, it works with any shape (profiles) regardless of the sharp corners… Here the important thing is correctly using the “ORIENT” component ( correctly placing the profile curve, face, or brep onto starting points of the rail, which we can get using the “PERP FRAME” component with parameters 0). 🙂

---

<div class="post-metadata">

**Author:** ![anon39580149](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@anon39580149](https://discourse.mcneel.com/u/anon39580149)\
**Post date:** [January 8, 2023, 12:03pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/10 "2023-01-08T12:03:30Z")

</div>

> [@Bakuri\_Gogua](#):
>
> sweep

For the sweep , the one from Heteroptera plugin works better

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/8/4/4/844d27f83953cd52f9298714e090b0b7beed2462.png)

[split & join2.gh](https://discourse.mcneel.com/uploads/short-url/rdatGSly6Xwvlgtx7vLeb7lCKuE.gh) (19.2 KB)

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 8, 2023, 10:40pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/11 "2023-01-08T22:40:14Z")

</div>

Thx, Khaled. I will look into it. 🙏

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 9, 2023, 6:01pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/12 "2023-01-09T18:01:21Z")

</div>

> [@magicteddy](#):
>
> Hopefully, the sharp corners don’t mess up the sweep

You were right, Teddy, not in the cases we discussed here, but when I try to use Sweep 1 on a rectangle (the rectangle as rail) the corners are not joined(welded) correctly ((

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 10, 2023, 2:59pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/13 "2023-01-10T14:59:59Z")

</div>

> [@anon39580149](#):
>
> Heteroptera

Hi, Khaled,  
Does it work with rectangles? I tried and failed (( Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![anon39580149](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@anon39580149](https://discourse.mcneel.com/u/anon39580149)\
**Post date:** [January 10, 2023, 4:24pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/14 "2023-01-10T16:24:43Z")

</div>

The section is a rectangle by default

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/1/3/f13e20070cbba26ec1888016b3077973299879d8.png)

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 10, 2023, 6:15pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/15 "2023-01-10T18:15:15Z")

</div>

Sorry, Khaled, I didn’t explain it clearly. There is no problem with split&join “issue” we discussed above… I meant a different situation when we have a closed curve with sharp edges

 ![rec1](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/b/e/cbe52153e34d11f4c82fc7373197b7756fbdf115.png)

---

<div class="post-metadata">

**Author:** ![anon39580149](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@anon39580149](https://discourse.mcneel.com/u/anon39580149)\
**Post date:** [January 10, 2023, 6:56pm UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/16 "2023-01-10T18:56:04Z")

</div>

Sweep works only with opened curve, you need to split the curve

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/c/b/bcb69635819b444ddd6b43f9f20daf2744bf3502.png)

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 12, 2023, 6:33am UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/17 "2023-01-12T06:33:09Z")

</div>

Hello Teddy, Khaled,  
Finally, I managed to sweep desired shapes on the closed curve with sharp edges using seam adjusting method, but to my surprise, It doesn’t sweep all of the profiles(moldings), although all profiles are the very same(The difference is only in shapes). Pls, see the attached files.  
What could be the reason for this, or am I doing something wrong?

 ![scr_1](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/8/6/186ac72d9936ac4afad82d417e665c957e90b717.png)  
[sweep1\_on\_closed\_crv.gh](https://discourse.mcneel.com/uploads/short-url/kdZIuTQ1fSbfVxIVkyq3BTiRUZr.gh) (20.9 KB)

---

<div class="post-metadata">

**Author:** ![kev.r](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kev.r/32/766021_2.png) [@kev.r](https://discourse.mcneel.com/u/kev.r)\
**Post date:** [January 12, 2023, 8:25am UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/18 "2023-01-12T08:25:16Z")

</div>

I don’t know why the Sweep1 component is failing with some of your profile curves.

I made a one line C# script and it succeeds with all of your curves as inputs.

[sweep1\_on\_closed\_crv\_re.gh](https://discourse.mcneel.com/uploads/short-url/1wVtTRPYV2A27kPnwLYoJLxvcWW.gh) (23.0 KB)

The script uses this RhinoCommon method. You might want to look at the parameters to see if you want to change anything.

> **[Brep.CreateFromSweep Method (Curve, IEnumerable(Curve), Point3d, Point3d,...](https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Brep_CreateFromSweep_5.htm)**
>
> Sweep1 function that fits a surface through a series of profile curves that define the surface cross-sections and one curve that defines a surface edge.

I don’t know what version of Rhino you are using but this method was new in V7.0

-Kevin

---

<div class="post-metadata">

**Author:** ![Bakuri\_Gogua](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bakuri_gogua/32/680287_2.png) [@Bakuri\_Gogua](https://discourse.mcneel.com/u/Bakuri_Gogua)\
**Post date:** [January 12, 2023, 9:49am UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/19 "2023-01-12T09:49:11Z")

</div>

Hello, Kevin,  
I use Rhino 7. I don’t have a good knowledge in scripting on C#. Often, in my working process I have to change many details and technics while modeling different things , it requires constantly change or modify the scrips, so its not convenient to me to work with those scripts in C#. Anyway, thank you very much, appreciate your effort. 🙏 I will try to figure it out what the heck is going with my profile curves in GH.

---

<div class="post-metadata">

**Author:** ![kev.r](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kev.r/32/766021_2.png) [@kev.r](https://discourse.mcneel.com/u/kev.r)\
**Post date:** [January 12, 2023, 10:32am UTC](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974/20 "2023-01-12T10:32:08Z")

</div>

I think your profile curves should work.

I tried your curves 2, 4, and 8 in the Rhino V8 WIP with Grasshopper 2. Using the Sweep From Rail component (Sweep1) they work without problems.

There might be a plug-in with a more robust sweep component that would work for your needs with V7.

-Kevin

[Next page](https://discourse.mcneel.com/t/trim-curve-with-another-curve/152974.md?page=2)
