Grasshopper

algorithmic modeling for Rhino

Hi

 

how can I obtain the points for each length?

if is possible in C#

 

Views: 319

Replies to This Discussion

Here's a version in C#, which assumes your inputs are "c" (a curve) and "d" (a list of double values).

 

    double sumDist = 0;

    double crvLen = c.GetLength();
    List<Point3d> ptList = new List<Point3d>();

    for (int i = 0; i < d.Count; i++){
      sumDist += d[i];
      if (sumDist > crvLen) break;
      ptList.Add(c.PointAtLength(sumDist));
    }

    A = ptList;

 

Note that if you're trying to do this for a straight line, I would recommend taking a unitized vector, multiplying it by the distance you need, and adding that to a base point.

Here is the C# script for serial summation, such that the input list {1, 2, 3, 4} would result in {1, 3, 6, 10}.

 

  private void RunScript(List<double> L, object y, ref object A)

  {

    List<double> Result = new List<double>();

    for (int i = 0; i < L.Count; i++) {

      if (i == 0) {

        Result.Add(L[i]);

      } else {

        Result.Add(L[i] + Result[i - 1]);

      }

    }

    A = Result;

  }

 

Remember to set the input L as list of double.

 

Hi,

thank you a lot for yours help.

I will watch them with very carefull.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service