With service release 2 of Rhino 4, a new curve offset function was added. Thie function is RhUtil.RhinoOffsetCurve. There is an older version of this function that does not work quite as well with the same name. The way to differentiate is the new function returns an integer where the older function returned a bool
public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
{
MRhinoGetObject go = new MRhinoGetObject();
go.SetCommandPrompt( "Select Curve");
go.SetGeometryFilter( IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object );
go.GetObjects(1,1);
if( go.CommandResult() != IRhinoCommand.result.success )
return go.CommandResult();
IOnCurve curve_in = go.Object(0).Curve();
if( null == curve_in )
return IRhinoCommand.result.failure;
double distance = 0.1;
MRhinoGetPoint gp = new MRhinoGetPoint();
gp.SetCommandPrompt( "Select Side" );
gp.GetPoint();
if( gp.CommandResult() != IRhinoCommand.result.success )
return IRhinoCommand.result.failure;
On3dPoint pt = gp.Point();
OnCurve[] curves_out = null;
int curve_count = RhUtil.RhinoOffsetCurve(curve_in, distance, pt, OnUtil.On_zaxis,
1, 0.01, out curves_out);
if (curve_count > 0 && curves_out != null)
{
for (int i = 0; i < curves_out.Length; i++)
{
context.m_doc.AddCurveObject(curves_out[i]);
}
context.m_doc.Regen();
}
return IRhinoCommand.result.success;
}
Public Overrides Function RunCommand(ByVal context As RMA.Rhino.IRhinoCommandContext) _
As RMA.Rhino.IRhinoCommand.result
Dim go As New MRhinoGetObject()
go.SetCommandPrompt("Select Curve")
go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object)
go.GetObjects(1, 1)
If (go.CommandResult() <> IRhinoCommand.result.success) Then
Return go.CommandResult()
End If
Dim curve_in As IOnCurve = go.Object(0).Curve()
If (curve_in Is Nothing) Then Return IRhinoCommand.result.failure
Dim distance As Double = 0.1
Dim gp As New MRhinoGetPoint()
gp.SetCommandPrompt("Select Side")
gp.GetPoint()
If (gp.CommandResult() <> IRhinoCommand.result.success) Then
Return IRhinoCommand.result.failure
End If
Dim pt As On3dPoint = gp.Point()
Dim curves_out() As OnCurve = Nothing
Dim curve_count As Integer = RhUtil.RhinoOffsetCurve(curve_in, distance, pt, _
OnUtil.On_zaxis, 1, 0.01, _
curves_out)
If (curve_count > 0 AndAlso curves_out IsNot Nothing) Then
For i As Integer = 0 To curves_out.Length - 1
context.m_doc.AddCurveObject(curves_out(i))
Next i
context.m_doc.Regen()
End If
Return IRhinoCommand.result.success
End Function