Click or drag to resize

NurbsCurveIncreaseDegree Method

Increase the degree of this curve.

Namespace:  Rhino.Geometry
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax
public bool IncreaseDegree(
	int desiredDegree
)

Parameters

desiredDegree
Type: SystemInt32
The desired degree. Degrees should be number between and including 1 and 11.

Return Value

Type: Boolean
true on success, false on failure.
Examples
using Rhino;
using Rhino.Commands;
using Rhino.Input;
using Rhino.DocObjects;

namespace examples_cs
{
  public class NurbsCurveIncreaseDegreeCommand : Command
  {
    public override string EnglishName { get { return "csNurbsCrvIncreaseDegree"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef obj_ref;
      var rc = RhinoGet.GetOneObject(
        "Select curve", false, ObjectType.Curve, out obj_ref);
      if (rc != Result.Success) return rc;
      if (obj_ref == null) return Result.Failure;
      var curve = obj_ref.Curve();
      if (curve == null) return Result.Failure;
      var nurbs_curve = curve.ToNurbsCurve();

      int new_degree = -1;
      rc = RhinoGet.GetInteger(string.Format("New degree <{0}...11>", nurbs_curve.Degree), true, ref new_degree,
        nurbs_curve.Degree, 11);
      if (rc != Result.Success) return rc;

      rc = Result.Failure;
      if (nurbs_curve.IncreaseDegree(new_degree))
        if (doc.Objects.Replace(obj_ref.ObjectId, nurbs_curve))
          rc = Result.Success;

      RhinoApp.WriteLine("Result: {0}", rc.ToString());
      doc.Views.Redraw();
      return rc;
    }
  }
}
Python
from Rhino import *
from Rhino.Commands import *
from Rhino.Input import *
from Rhino.DocObjects import *
from scriptcontext import doc

def RunCommand():
  rc, obj_ref = RhinoGet.GetOneObject("Select curve", False, ObjectType.Curve)
  if rc != Result.Success: return rc
  if obj_ref == None: return Result.Failure
  curve = obj_ref.Curve()
  if curve == None: return Result.Failure
  nurbs_curve = curve.ToNurbsCurve()

  new_degree = -1
  rc, new_degree = RhinoGet.GetInteger(
    "New degree <{0}...11>".format(nurbs_curve.Degree), True, new_degree, nurbs_curve.Degree, 11)
  if rc != Result.Success: return rc

  rc = Result.Failure
  if nurbs_curve.IncreaseDegree(new_degree):
    if doc.Objects.Replace(obj_ref.ObjectId, nurbs_curve):
      rc = Result.Success

  print "Result: {0}".format(rc)
  doc.Views.Redraw()
  return rc

if __name__ == "__main__":
  RunCommand()
See Also