Grasshopper

algorithmic modeling for Rhino

Hi ,all.

 

I am trying to draw lines between two list of points.

 

List A has 40 points, and List B has 50 points.

 

I just wonder, is there any code as same as 'shortest list, longest lsit, cross reference' function in Grasshopper component?

 

I write kind of 'longest list' using conditional sentence like below,

---------------------------------------------------------

    Point3d[] pt00 = new Point3d[40];
    Point3d[] pt01 = new Point3d[50];
    crv00[0].DivideByCount(40, true, out pt00);
    crv00[1].DivideByCount(50, true, out pt01);

    Line ln00;
    List<Line> list00 = new List<Line>();

    for (int i = 0; i < pt01.Length; i++) {

      if (i > (pt00.Length - 1)) {
        ln00 = new Line(pt00[pt00.Length - 1], pt01[i]);
        list00.Add(ln00);
      } else {
        ln00 = new Line(pt00[i], pt01[i]);
        list00.Add(ln00);
      }
    }

    A = list00;

---------------------------------------------------------

 

I hope there would be good way! :)

Thanks!!

Views: 121

Reply to This

Replies to This Discussion

Nope, it's not exposed as a general utility function or class. But of course the logic is fairly simple.

 

//Shortest list

for (int i = 0; i < Math.Min(list0.Count, list1.Count); i++)

{

  int i0 = i;

  int i1 = i;

  ....

}

 

 

//Longest list

for (int i = 0; i < Math.Max(list0.Count, list1.Count); i++)

{

  int i0 = Math.Min(i, list0.Count - 1);

  int i1 = Math.Min(i, list1.Count - 1);

  ....

}

 

 

//Cross Reference

for (int i1 = 0; i1 < list1.Count; i1++)

{

  for (int i0 = 0; i0 < list0.Count; i0++)

  {

    ....

  }

}

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks!! David!!!

RSS

Translate

Search Grasshopper

© 2017   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service