Hi,
I was wondering how you guys handle Errors in C#.net Development for Rhino.
For example:
This code adds a circle to the Document in RhinoPython
def AddArc(plane, radius, angle_degrees):
"""Adds an arc curve to the document
Parameters:
plane = plane on which the arc will lie. The origin of the plane will be
the center point of the arc. x-axis of the plane defines the 0 angle
direction.
radius = radius of the arc
angle_degrees = interval of arc
Returns:
id of the new curve object
"""
plane = rhutil.coerceplane(plane, True)
radians = math.radians(angle_degrees)
arc = Rhino.Geometry.Arc(plane, radius, radians)
rc = scriptcontext.doc.Objects.AddArc(arc)
if rc==System.Guid.Empty: raise Exception("Unable to add arc to document")
scriptcontext.doc.Views.Redraw()
return rc
Here is a simllar function in C#
public static Guid AddArc(Plane plane, double radius, double angle, bool angleAsDegrees = true)
{
RhinoDoc document = RhinoDoc.ActiveDoc;
if (angleAsDegrees)
{
// set angle to be in radians
angle = RhinoMath.ToRadians(angle);
}
Arc arc = new Arc(plane, radius, angle);
if (arc == null)
{
return System.Guid.Empty;
}
Guid guid = document.Objects.AddArc(arc);
document.Views.Redraw();
return guid;
}
It has no Error handling. How would you do that?
Thanks
Karl