Intersections between circles

Hello all,
Please, I’m trying to write a script that checks for the intersection between inclined circles on Rhino and calculates the length. I tried using curvecurveintersection, but it’s always returning no intersection, wvwn when the circles are intersected.

NB: my circles are guid objects I inserted in a box, then saved the GUIDs in a list, so I want to use the list to find intersection between the circles

Can you post some code with a sample file that’s not working?


> def LengthOfIntersection(circle_list):
>     length = 0
>     print circle_list
>     for i in range(len(circle_list)):
>         curveA = circle_list[i]
>         for j in range(len(circle_list)-1):
>             if j != i:
>                 intersection = rs.CurveCurveIntersection(curveA,circle_list[j])
>                 #print intersection
>                 if intersection != None:
>                     length += math.sqrt((intersection[1][1][0]-intersection[0][1][0])**2 + (intersection[1][1][1]-intersection[0][1][1])**2)

The circle_list is a list of GUIDs

I have now converted the circles into surfaces for the intersections to be detected. But I am getting a weird error

def LengthOfIntersection(surface_list):
    length = 0
    for i in range(len(surface_list)):
        curveA = surface_list[i]
        for j in range(len(surface_list)):
            if j != i:
                intersection = rs.CurveCurveIntersection(curveA,surface_list[j])
                #print intersection
                if intersection != None:
                length += math.sqrt((intersection[1][1][0]-intersection[0][1][0])**2 + (intersection[1][1][1]-intersection[0][1][1])**2)
        else: continue       
print length    

Message: unable to convert ef49509a-0bb4-46d9-b03d-e966960c84e2 into Curve geometry

line 1447, in CurveCurveIntersection, “C:\Users\falol\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\”
line 1002, in coercecurve, “C:\Users\falol\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\”
line 171, in LengthOfIntersection, "C:\Users\falol\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts\sec.

This is the function generating and converting the circles to surfaces.

def AddCircle(n,radius,boxlength):
    A function to add a fixed number of circles in a cube
    #initialize a list to store circle GUIDs
    circle_list = []
    surface_list = []
    #a loop to insert the fixed number of circles
    for i in range(n):
    #create a center point for the circle
        x = random.uniform(0+radius,boxlength-radius)
        y = random.uniform(0+radius,boxlength-radius)
        z = random.uniform(0+radius,boxlength-radius)
        #store the random origin
        origin = [x,y,z]
        #convert the origin to a plane
        plane = InclinePlane(origin)
        #insert the circle in the cube
        my_circle = rs.AddCircle(plane,radius)
        #append the circle GUID to the list
        surf = rs.AddPlanarSrf(my_circle)
    print surface_list
    return surface_list