Click or drag to resize

BoundingBoxIsDegenerate Method

Determines whether a bounding box is degenerate (flat) in one or more directions.

Namespace:  Rhino.Geometry
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
public int IsDegenerate(
	double tolerance


Type: SystemDouble
Distances <= tolerance will be considered to be zero. If tolerance is negative (default), then a scale invariant tolerance is used.

Return Value

Type: Int32
0 = box is not degenerate 1 = box is a rectangle (degenerate in one direction). 2 = box is a line (degenerate in two directions). 3 = box is a point (degenerate in three directions) 4 = box is not valid.
using Rhino;
using Rhino.Geometry;
using Rhino.Commands;
using Rhino.Input;
using Rhino.DocObjects;

namespace examples_cs
  public class BrepFromCurveBBoxCommand : Command
    public override string EnglishName { get { return "csBrepFromCurveBBox"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
      Rhino.DocObjects.ObjRef objref;
      var rc = RhinoGet.GetOneObject("Select Curve", false, ObjectType.Curve, out objref);
      if( rc != Result.Success )
        return rc;
      var curve = objref.Curve();

      var view = doc.Views.ActiveView;
      var plane = view.ActiveViewport.ConstructionPlane();
      // Create a construction plane aligned bounding box
      var bbox = curve.GetBoundingBox(plane);

      if (bbox.IsDegenerate(doc.ModelAbsoluteTolerance) > 0) {
        RhinoApp.WriteLine("the curve's bounding box is degenerate (flat) in at least one direction so a box cannot be created.");
        return Result.Failure;
      var brep = Brep.CreateFromBox(bbox);
      return Result.Success;
import Rhino
from Rhino.Geometry import *
from Rhino.Commands import Result
from Rhino.Input import RhinoGet
from Rhino.DocObjects import ObjectType
import rhinoscriptsyntax as rs
from scriptcontext import doc

def RunCommand():
  rc, objRef = RhinoGet.GetOneObject("Select curve", False, ObjectType.Curve)
  if rc <> Result.Success:
    return rc
  curve = objRef.Curve()
  if None == curve:
    return Result.Failure

  view = doc.Views.ActiveView
  plane = view.ActiveViewport.ConstructionPlane()
  # Create a construction plane aligned bounding box
  bbox = curve.GetBoundingBox(plane)

  if bbox.IsDegenerate(doc.ModelAbsoluteTolerance) > 0:
    print "the curve's bounding box is degenerate (flat) in at least one direction so a box cannot be created."
    return Result.Failure

  brep = Brep.CreateFromBox(bbox)

  return Result.Success

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