Extracting objects from CurveIntersections type

Hello everyone,

I would like to extract the intersection points from the intersection of a curve and a plane in C#. As return I get a variable with CurveIntersection type. I want to know that how I can get the point as return.


1 Like

Thanks Peter.

BTW: Found a simple thingy on that matter:

Curve_Ccx_Plane_EntryLevel_V1.gh (123.8 KB)

Having trouble with the same topic using nested loops.
The error is “Object reference not set to an instance of an object”
Many tries and no luck. Help is highly appreciated! Thanks…

curvesXplanee.gh (128.1 KB)
Here I included some tries, but I can´t reference the CurveIntersection object to extract results.

DataTree<Point3d?> pTree = new DataTree<Point3d?>();
    DataTree<double?> tTree = new DataTree<double?>();

    List<GH_Path> paths = curves.Paths.ToList();

    for(int k = 0;k < planes.Count;k++){
      Plane p = planes[k];

      for (int i = 0; i < paths.Count; i++){
        List<Curve> crvs = curves.Branch(paths[i]);
        for (int j = 0; j < crvs.Count; j++){
          Curve c = crvs[j];
          var events = Rhino.Geometry.Intersect.Intersection.CurvePlane(c, p, 0.001);

          if(events == null) {
            pTree.Add(null, new GH_Path(k, i, j));
            tTree.Add(null, new GH_Path(k, i, j));

          for(int m = 0; m < events.Count;m++){
            var ccx = events[m];
            pTree.Add(ccx.PointA, new GH_Path(k, i, j));
            tTree.Add(ccx.ParameterA, new GH_Path(k, i, j));

    ccxPtsTree = pTree;
    ccxParamTree = tTree;

Thank you @PeterFotiadis. I thought the trick was converting DataTree to Lists but seems that´s not the way. I´m getting the same error trying to reproduce your answer in my end (“Object reference not set to an instance of an object”). I upload the file again that include my last try. Seems there is something I don´t know or I´m missing.

I created a new topic for this and I got an answer that works using IEnumerator (an unknown thing to me). I just like to know if there is a simple way like yours.

The link for documentation: Extracting objects from CurveIntersections type within nested loops

curvesXplane.gh (130.8 KB)

curvesXplane_V1.gh (137.1 KB)

Note: storing Events means that you should unbox the content IF you use multiple C#'s (say: one for the above job another for doing something etc etc). It’s rather preferable to use multiple DataTrees of “ordinary/common” Types (like Point3d, double, Crv pieces etc).

Plus: you should avoid multi dims in the crvsTree if there’s no reason for that. For instance if you have paths like {0,1,0,3,0} … {0,1,0,55,0} add some dim simplification Method.

1 Like

Thank you for your notes and examples. I like using lists within loops now and discover the new tricks the community has in its pockets.