Grasshopper

algorithmic modeling for Rhino


I want to modify the polyline as shown ..

make four or three segments into one segment.
any idea? (c#)

Views: 424

Replies to This Discussion

Here is a solution

angle must be close to Math.PI (3.14159)  for your purpose Math.Pi - angle tolerance  (1° in radian)

private void RunScript(Polyline c, double angle, ref object A, ref object B)
{

//Breaks polyline at kinks
Polyline[] crs = c.BreakAtAngles(angle);

//Take all the first points of polyline

List<Point3d> pts = new List<Point3d> ();
foreach (Polyline pl in crs)
{
     pts.Add(pl.First);
}

//Add the last point
pts.Add(crs[crs.Count() - 1].Last);

//Create the new polyline
A = new Polyline(pts);

}

Thanks Andrew,

before answering I read RhinoCommon help and I though this command will merge points close from each other. I didn't test it ! Bad idea. It is answering exactely the question of Platut. 

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