How to load curves quickly with the C# script

I want to know how to quickly load geometric structures such as curves and further use rhinocommon for processing.

  private void RunScript(List<System.Object> Lines, Point3d P, ref object A, ref object B)
      List<Point3d> points = new List<Point3d>();
      Curve[] newlines = new Curve[Lines.Count];

    for (int i = 0; i < Lines.Count; i++)
      Curve L = (Curve) Lines[i];
      newlines[i] = L;

    A = newlines;
    B = points;

the model file: (223.4 KB)

You use Curve Type for no reason (line.Form/To does the job - if the end pts are what you are after)…

Explain in full detail what is your goal. And what means “quickly” ??? in relation to what?

I want to get the endpoint of the curve, but the C # script takes a long time (70ms). How to optimize this process.

You can use // (a thread safe one - obviously) but I can’t post similar stuff (any parallel solution is a strictly internal thing).

In the mean time get an entry level connectivity on that matter (spot the impact on connectivity). (343.8 KB)

Note: since you have Islands the above is 100% incomplete. In real-life we solve that in a second pass solely using the first pass VV - as provited (this yields a 2 dim Tree for obvious reasons: first dim is the Cluster Index). That said I also can’t provide a Graph Island detection C#.

Just for the record: here’s your Graph with thread safe //, Island detection (i.e. Clustering) and correct conn Trees (15 ms using - on purpose - an ancient 9 gen I5):

And using some other demo Graph