Grasshopper

algorithmic modeling for Rhino

Hi.

 

I have managed to create a curve from a list of points, but I am sure it is not the best way?


NurbsCurve crv = new NurbsCurve(1, pointList.Count);

// set control points
for(int i = 0; i < testOutput.Count; i++)
crv.Points.SetPoint(i, testOutput[i]);

A= crv.Points.ControlPolygon();

 

The only way I get a curve following all the points is to use the ControlPolygon function. However, this is just a curve of polylines between the points, and not a proper nurbscurve. If I return the NurbsCurve (crv), I get a curve made of several small segments, and it does not connect to all points.

Is there a better way to get a curve from a list of points?

 

Cheers, Eirik

Views: 681

Replies to This Discussion

Hi Erik,

 

Does this rhino common sample provide the advice you need?  

http://wiki.mcneel.com/developer/rhinocommonsamples/addnurbscurve

 

Cheers,  Jon

Thanks Jon,

 

it's beautiful.

 

It works perfect. Since I had a list of points, I could use that directly in the constructor:


Point3dList points = new Point3dList(pointList);
NurbsCurve nc = NurbsCurve.Create(false, 3, points);
Rhino.Commands.Result rc = Rhino.Commands.Result.Failure;
if (nc != null && nc.IsValid)
{
if (doc.Objects.AddCurve(nc) != Guid.Empty)
{
doc.Views.Redraw();
rc = Rhino.Commands.Result.Success;
}
}

A = rc;

 

... and thereby save the points.Add() ..

 

I wasn't aware of the McNeel Wiki, it's a great resource.

 

Thanks, Eirik

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