Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:rhinocommonsamples:facearea [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Brep Face Area =====
 +
 +===== C# =====
 +<code 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;​
 +}
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/facearea.txt ยท Last modified: 2015/09/14 (external edit)