Wish: convert curve to arcs & polylines

Hi,

I wish for a function to convert a curve to arc and line segments. Similar to the _Convert command with the option Output=Arcs.

Right now I think there’s only ToPolyline available from RhinoCommon.
Or do I miss a way to convert nurbs curves to arcs and lines?

Thanks,
Jess

No, I don’t believe RhinoCommon exposes anything like what the Convert command does.

https://mcneel.myjetbrains.com/youtrack/issue/RH-37392

– Dale

RH-37392 is fixed in the latest WIP

1 Like

Works great! Thanks!

Jess

I’m having issues using the Convert RhinoCommon command from a C# script in Grasshopper. This is an example of one of the issues.

There’s another case I don’t have a good example of where it fails to return a result.
Convert command in Rhino has no issues with these curves. Thoughts?

Convert.gh (15.4 KB)

Hi @jokamm,

This seems to provide good results:

  private void RunScript(Curve curve, ref object A)
  {
    var tolerance = RhinoDocument.ModelAbsoluteTolerance;
    var angleTolerance = RhinoDocument.ModelAngleToleranceRadians;
    A = curve.ToArcsAndLines(tolerance, angleTolerance, 0.0, 0.0);
  }

– Dale

It provides good curves if Angle tolerance isn’t set to 0.0
Rhino documentation says :
AngleTolerance The maximum angle between segments at endpoints, overriding the [system tolerance setting. Specify 0 (zero) to allow non-tangent arcs. The output will have kinks, but since it consists of arc segments, there will be fewer segments than if the Lines option was used. This is useful for approximating a curve with the smallest number of segments.
https://docs.mcneel.com/rhino/6/help/en-us/index.htm#commands/convert.htm?Highlight=arc%20convert
Seems less clear in Rhinocommon if 0 is useful
angleTolerance
The angle tolerance in radians. This is the maximum deviation of the arc end directions from the curve direction. When in doubt, use the document’s model space angle tolerance.
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_ToArcsAndLines.htm

Problems are comming with very low angle tolerance

Thanks @dale and @laurent_delrieu.

I somehow missed angle tolerance when trying to get things working.

Yes, it didn’t occur to me that might be the case.

Thanks!