I created a custom component using python, the code is very simple, it basically takes a bunch of multiple-segment curves and finds out if the first segment of curves intersect with berps, finally if the curve doesn’t intersect with the breps I add it to a list. Then I find the intersection points between the last segment of the curves in that list and a surface. I ran into a problem, if I print out the length of that list I get 242 (this is realistic) but the output in a grasshopper panel shows 1454 curves. Curves in the list are duplicated 4 times. Any ideas??

Update: I Attached the GH file

Custom_Labib.gh (27.5 KB)

```
import Rhino as rc
import rhinoscriptsyntax as rs
import itertools
#Explode rays into line segments
explodedRays = rs.ExplodeCurves(rays)
#Get number of segments
numberOfSegments = int(len(explodedRays)/len(rays))
#Organize line segments into a list of lists
segments = []
for x in range(numberOfSegments):
segment = explodedRays[x:][::numberOfSegments]
segments.append(segment)
#Solve lines and obstructing surfaces intersection
intersectionPoints = []
for line in segments[0]:
for brep in obstructingSrfs:
newLine= rs.coercecurve(line)
allIntersectionPts = rc.Geometry.Intersect.Intersection.CurveBrep(newLine,brep, .0001)
intersectionPoints.append(allIntersectionPts[2])
#Put intersection points into a flattened list
intersectionPts = list(itertools.chain.from_iterable(intersectionPoints))
# Get index of intersection points and apply indecies to line segments lists
intersectIndex = []
notIntersectIndex = []
for i, j in enumerate(intersectionPoints):
if len(j) == 0:
notIntersectIndex.append(i)
else:
intersectIndex.append(i)
newUnobstructedRays = [rays[i] for i in notIntersectIndex]
obstructedRays = [rays[i] for i in intersectIndex]
#newlist2 = [firstSegment[i] for i in b]
#newlist3 = [secondSegment[i] for i in b]
newSegments= []
for x in range(numberOfSegments):
newList = [segments[x][i] for i in notIntersectIndex]
newSegments.append(newList)
lastUnobstructedSegments = []
for o in newSegments[-1]:
c = rs.coercecurve(o)
lastUnobstructedSegments.append(c)
analysisIntersectionPoints = []
for l in lastUnobstructedSegments:
for s in analysisSrfs:
lines = rs.coercecurve(l)
newIntersectionPts = rc.Geometry.Intersect.Intersection.CurveBrep(lines,s, .0001)
analysisIntersectionPoints.append(newIntersectionPts[2])
analysisPts = list(itertools.chain.from_iterable(analysisIntersectionPoints))
cleanlist = []
[cleanlist.append(x) for x in analysisPts if x not in cleanlist]
#newUnobstructedRays1 =[ii for n,ii in enumerate(newUnobstructedRays) if ii not in newUnobstructedRays[:n]]
#print len(newUnobstructedRays1)
print len(newUnobstructedRays)
```