C# Polycurve through Data Tree

Hi guys,

I am trying to do something very simple, but its my first time implementing Data Trees in C#. Basically I am trying to recreate the record data component, to be able to draw trails of any type of simulation. Since recording points over time is computationally expensive, I want to output polycurves instead of points.

My question is how can I access each branch to be able to draw a polyline through its items?. This sounds like a job for a for loop, but I dont know exaclty how to implement the appropiate Data tree Class methods.

Here is the small code:

private void RunScript(bool reset, bool trails, List<Point3d> pts, ref object A)
{
    for(int i = 0;i < pts.Count;i++)
      record.Add(pts[i], new GH_Path(i));

    if (reset)
      record.ClearData();

    A = record;
    //A = new PolylineCurve(record.Branch(10));
}

  // <Custom additional code> 
  public DataTree<Point3d> record = new DataTree<Point3d>();

Any guidance will be great!

Thank you,

Nicholas

1 Like

If you’re operating on trees, you’ll need to set your pts input to Tree instead of List access.

record trails.gh (11.8 KB)

1 Like

David,

thank you, very helpful comments on the file.

datarecorder overwriting


changed for myself decided to share :sunglasses: