Curve Intersections - doing all curves at once instead of 2 at a time, c#, Grasshopper, Rhino - Help!


I am trying to use the Intersection.CurveCurve method to find the intersections between 6 different curves, in c# and cannot figure out for the life of me how to get it to do the command for all the curves at once, instead of me trying to find them for each pair of curves. I have my 6 curves stored as a list “fpath”, and tried inputting them into the script, but get an error about # of arguments.

Here is my code:
List xpoints = new List();
List xoverlap = new List();

    double tolerance = 0.001;

    Rhino.Geometry.Intersect.CurveIntersections xe =
      Rhino.Geometry.Intersect.Intersection.CurveCurve(a1, a2, tolerance, tolerance);
    foreach (Rhino.Geometry.Intersect.IntersectionEvent x in xe)
      if (x.IsPoint)
        xpoints.Add(x.PointA); //intersection points as seen on first curve
        xpoints.Add(x.PointB); //intersection points on other curves
      { //x is not a point but an overlap
        xoverlap.Add(new Line(x.PointA, x.PointA2));
        xoverlap.Add(new Line(x.PointB, x.PointB2));

    A = xpoints;
    B = xoverlap;

And here is my previous code in which I make the paths and store as a list:

//make curves through the points
Curve a1 = NurbsCurve.CreateInterpolatedCurve(pp1, 3, CurveKnotStyle.UniformPeriodic);
Curve a2 = NurbsCurve.CreateInterpolatedCurve(pp2, 3, CurveKnotStyle.UniformPeriodic);
Curve a3 = NurbsCurve.CreateInterpolatedCurve(pp3, 3, CurveKnotStyle.UniformPeriodic);
Curve a4 = NurbsCurve.CreateInterpolatedCurve(pp4, 3, CurveKnotStyle.UniformPeriodic);
Curve a5 = NurbsCurve.CreateInterpolatedCurve(pp5, 3, CurveKnotStyle.UniformPeriodic);
Curve a6 = NurbsCurve.CreateInterpolatedCurve(pp6, 3, CurveKnotStyle.UniformPeriodic);
//put those into a list for easy output
List < Curve > fpath = new List<Curve>{a1,a2,a3,a4,a5,a6};
A = Ents;
B = paths;
C = a3;
D = fpath;

I have them outputted to D, fpath. I thought I could input D into another c# component, as fpath’s as well (with the hint curves) and just reference that in this portion of the code:
Rhino.Geometry.Intersect.Intersection.CurveCurve(fpath, tolerance, tolerance);

But it does not work. Any help would be much appreciated, I am very new to coding!

Attached are the files, if that helps. (11.8 KB)

Take a look at this. Not optimized, brute-force checking all segments against all segments, but you’ll see the idea: (14.5 KB)

// Rolf

That was quick! thank you so much.

I just took a look, and let me see if I try to understand this correctly.

You have stored fpath as a variable, and called in lineA? so as long as i < count of fpath, then you do the same for fpath as line B, store that, and then you just input the fpath as lineA and lineB.

Is there a way to apply this same thing to cull/delete/trim all of the lines that fall outside of my boundary? another area that I was having trouble w/. My boundary is my only external input.

thanks so much!

Is not clear what is your goal,

Maybe you have curves:

And you want this?

BTW: Avoid the “short”/dirty way (i.e. splitting a BrepFace with curves). Instead split all with all using some similar Method: