Test Curve Linear & Degree 1

Hi All,


the method indicated in the link checks if a curve is linear, but to check if it is also a simple straight line with only two control points, I have to check if it is of degree 1 right. . . there is no specific method?

Curve c;
var b= c.IsLinear(0.001) && c.Degree == 1;

1 Like

ok @Tao_Lin thanks for reply :+1:

Not exactly …
A Polyline may be linear.

Just look at what rhinoscriptsyntax does

def IsLine(object_id, segment_index=-1):
    """Verifies an object is a line curve
      curve_id (guid): identifier of the curve object
      segment_index (number, optional): the curve segment index if `curve_id` identifies a polycurve
      bool: True or False indicating success or failure
      import rhinoscriptsyntax as rs
      obj = rs.GetObject("Select a line")
      if rs.IsLine(obj):
          print "The object is a line."
          print "The object is not a line."
    See Also:
    curve = rhutil.coercecurve(object_id, segment_index, True)
    if isinstance(curve, Rhino.Geometry.LineCurve): return True
    rc, polyline = curve.TryGetPolyline()
    if rc and polyline.Count==2: return True
    return False
1 Like