# Automating the "Trim" command via python or the c++ SDK?

**URL:** <https://discourse.mcneel.com/t/automating-the-trim-command-via-python-or-the-c-sdk/8787>\
**Category:** Scripting\
**Created:** [May 29, 2014, 10:36pm UTC](https://discourse.mcneel.com/t/automating-the-trim-command-via-python-or-the-c-sdk/8787 "2014-05-29T22:36:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh1](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@josh1](https://discourse.mcneel.com/u/josh1)\
**Post date:** [May 29, 2014, 10:36pm UTC](https://discourse.mcneel.com/t/automating-the-trim-command-via-python-or-the-c-sdk/8787/1 "2014-05-29T22:36:54Z")

</div>

I’m trying to automate execution of the “trim” command to trim a surface using a few isocurves. The context is [Howto form spout for glass cup/pitcher?](http://discourse.mcneel.com/t/howto-form-spout-for-glass-cup-pitcher/8695/15)

Anyone know how to do this in python, or failing that, via the c++ SDK? Rhino python has a TrimSurface() method, but it looks like it only trims in one of the U and V directions, not both at the same time, like the “trim” command does. The TrimBrep method looks promising if I could construct a polysurface from the isocurves somehow…  
Thanks for any ideas!  
Josh

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [May 30, 2014, 5:46pm UTC](https://discourse.mcneel.com/t/automating-the-trim-command-via-python-or-the-c-sdk/8787/2 "2014-05-30T17:46:27Z")

</div>

You might consider using Rhino.Geometry.BrepFace.Split and then throw away the piece(s) you don’t need.

---

<div class="post-metadata">

**Author:** ![josh1](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@josh1](https://discourse.mcneel.com/u/josh1)\
**Post date:** [June 3, 2014, 6:42pm UTC](https://discourse.mcneel.com/t/automating-the-trim-command-via-python-or-the-c-sdk/8787/3 "2014-06-03T18:42:28Z")

</div>

> [@dale](#):
>
> You might consider using Rhino.Geometry.BrepFace.Split and then throw away the piece(s) you don’t need.

Yeah, it took a fair bit of code to explicitly create the right polysurface that I think Trim creates internally, but it worked, thanks.
