Site Tools


Sample: Brep Face Area

C#

protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
{
  Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
  go.SetCommandPrompt("Select surface for area calculation");
  go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface;
  go.SubObjectSelect = true;
  go.Get();
  if (go.CommandResult() != Rhino.Commands.Result.Success)
    return go.CommandResult();
 
  Rhino.DocObjects.ObjRef objref = go.Object(0);
  Rhino.Geometry.BrepFace face = objref.Face();
  if (null == face)
    return Rhino.Commands.Result.Failure;
 
  Rhino.Geometry.Brep brep = face.DuplicateFace(true);
  if (null == brep)
    return Rhino.Commands.Result.Failure;
 
  Rhino.Geometry.AreaMassProperties area = Rhino.Geometry.AreaMassProperties.Compute(brep);
 
  RhinoApp.WriteLine("Surface area =  {0}.", area.Area);
  return Rhino.Commands.Result.Success;
}
developer/rhinocommonsamples/facearea.txt ยท Last modified: 2015/09/14 (external edit)