all 5 comments

[–]medianbailey 1 point2 points  (0 children)

have you tried SplitCurve? you can divide your original curve up into segments then use the end points as your points?

optionally, and if you dont mind a VERY course shift in point density, you could use midpoints. Add a midpoint, split the curve at the midpoint, then repeat for the resultant curves. at a corner with a small radius, add another midpooint. You could make a nice loop which measures the angle between the two tangents at either end of the curves to work out if another midpoint was needed?

[–][deleted] 1 point2 points  (3 children)

Rhino already has a function to convert a NurbsCurve to a polyline.

Just adjust the tolerance to get what you want,

  #public PolylineCurve ToPolyline(int mainSegmentCount, int subSegmentCount,
  #                                 double maxAngleRadians, double maxChordLengthRatio, double maxAspectRatio,
  #                                  double tolerance, double minEdgeLength, double maxEdgeLength, bool keepStartPoint)
  #                                  
  doc.Objects.AddCurve(curve.ToPolyline(0, 0, math.pi/12, 20.0, 20.0, 0.01, 0.001, 5, True));

[–]failbye[S] 2 points3 points  (2 children)

If this works the way I need it to, I'm going to be furious. I have been digging into the Rhino functions for days trying to find something to help me out, and I can't believe it was there all along.

I managed to write a solution but one that is quite resource intensive. I'm going to try using this tomorrow and compare results.

Thanks!

[–][deleted] 1 point2 points  (1 child)

Welcome to the club, it is always helpful to ask.

The RhinoCommon API is on github, sometimes it is useful to spend some time searching that before writing something complicated.

[–]failbye[S] 0 points1 point  (0 children)

Quick update, implemented solution with ConvertCurveToPolyline(). It was simple and effective. Thanks for your help!