Boundary trim of curves in Grasshopper

Hi, is there a way in Grasshopper to do boundary trimmings like in the second picture?
I’m trying to use the circles as a boundary shapes to trim of delauney triangles.
In the second picture I used a python script in Rhino but I would prefer to do this in Grasshopper.
It can also be a 3D boolean if 2D curves are not possible as in the 3rd picture
Thanks (1.2 MB)

I guess you’re looking for TrimWithRegions: (1.1 MB)

1 Like

Alternatively, you can do it with ghpython. It’s still slow, but according to Grasshopper’s profiler it’s still faster (4.9s on my super old machine) than TrimWithRegions (15s).

EDIT: Note, that it only will work with lines and circles. Furthermore, only lines which start or end at the center of a circle are considered. So it won’t account for lines which are going through the circle but have no ‘connection’ to the circle’s center point. The script does not actually trim the lines, it rescales them to the respective circle’s radius. This is probably also the reason it’s faster because it does not need to check for actual intersections like TrimWithRegions. (1.2 MB)

Code for ghpython component:

'Trims' a bunch of lines with some circles.
        Circles: the circles to use as boundaries for the lines.
        Lines: The lines to trim with the circles.
        TrimmedLines: The 'trimmed' lines.

from ghpythonlib import treehelpers as th
import Rhino

TrimmedLines = [[] for x in Circles]

for i, circle in enumerate(Circles):
    if circle == None:
    for j, ln in enumerate(Lines):
        if ln.From == circle.Center:
            new_line = Rhino.Geometry.Line(ln.From, ln.To)
            new_line.Length = circle.Radius
        elif ln.To == circle.Center:
            new_line = Rhino.Geometry.Line(ln.To, ln.From)
            new_line.Length = circle.Radius

TrimmedLines = th.list_to_tree(TrimmedLines)
1 Like

Thank you so much, Mahdiyar and Max.
The Python Script seem to work better as my machine appears to be a bit too slow to handle trim with regions. But both of them does the job

Many Thanks

1 Like