Site Tools

Reversing the Direction of Curves


Summary: Demonstrates how to reverse the direction of curves using the Rhino SDK.
NOTICE: The Rhino.NET SDK is deprecated in Rhino 5. This example adapted for the new RhinoCommon SDK is here


I am trying to reverse the direction of a curve that I have selected. I found that there is a OnCurve.Reverse method, but I do not know how to use it.


In order to modify any geomatric object that exists in Rhino, you must:

  1. Get the object.
  2. Make a copy of it.
  3. Modify the copy.
  4. Replace the original object with the copy.

The following code sample demonstrates how to reverse the direction of one or more curves.


public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
  MRhinoGetObject go = new MRhinoGetObject();
  go.SetCommandPrompt("Select curves to reverse");
  go.GetObjects(1, 0);
  if (go.CommandResult() != IRhinoCommand.result.success)
    return go.CommandResult();
  for (int i = 0; i < go.ObjectCount(); i++)
    IRhinoObjRef obj_ref = go.Object(i);
    IOnCurve crv = obj_ref.Curve();
    if( crv != null)
      OnCurve dupe = crv.DuplicateCurve();
      if( dupe != null )
        context.m_doc.ReplaceObject(obj_ref, dupe);
  return IRhinoCommand.result.success;
developer/sdksamples/curvereverse.txt ยท Last modified: 2020/08/14 (external edit)