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.

Circle_Pack_Triangles_GhPython.gh (1.2 MB)

**Code for ghpython component:**

```
"""
'Trims' a bunch of lines with some circles.
Inputs:
Circles: the circles to use as boundaries for the lines.
Lines: The lines to trim with the circles.
Output:
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:
continue
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
TrimmedLines[i].append(new_line)
elif ln.To == circle.Center:
new_line = Rhino.Geometry.Line(ln.To, ln.From)
new_line.Length = circle.Radius
TrimmedLines[i].append(new_line)
TrimmedLines = th.list_to_tree(TrimmedLines)
```