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:
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.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object);
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 )
{
dupe.Reverse();
context.m_doc.ReplaceObject(obj_ref, dupe);
}
}
}
context.m_doc.Redraw();
return IRhinoCommand.result.success;
}