Categorising points into their own subtree in C#

Hi, within my C# script, I want to categorise each of these points within the tree into their own subtree from the start point to centre, can anyone help me with this?

Thank you.

Assuming that your Crvs/Lines start/end pts are OK (with regard the common pt).

public DataTree<Point3d> divPtTree;

  public void Divide(List<Curve> cList, int N, bool ends){
    divPtTree = new DataTree<Point3d>();
    for(int i = 0; i < cList.Count;i++){
      Point3d[] pts; cList[i].DivideByCount(N, ends, out pts);
      divPtTree.AddRange(pts, new GH_Path(i));
    }
  }
1 Like

Uploading the code would have helped !

 private void RunScript(List<Point3d> anchors, List<Point3d> allGoals, Point3d center, ref object A)
  {
    DataTree<Point3d> sorted = new DataTree<Point3d>();


    for (int i = 0; i < anchors.Count; i++)
    {
      Line l = new Line(center, anchors[i]);
      GH_Path g = new GH_Path(i);

      for (int j = 0; j < allGoals.Count; j++)
      {
        if (l.DistanceTo(allGoals[j], true) < Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)
        {
          sorted.Add(allGoals[j], g);
        }
      }
    }

    A = sorted;
  }

SortPtsByLine.gh (8.8 KB)

1 Like

Sorry about that, thanks for the solution

Thank you for this, it helped :grinning: