Site Tools


Differences

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

Link to this comparison view

developer:rhinocommonsamples:addbrepbox [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Add Brep Box =====
 +
 +===== C# =====
 +<code c#>
 +public static Rhino.Commands.Result AddBrepBox(Rhino.RhinoDoc doc)
 +{
 +  Rhino.Geometry.Point3d pt0 = new Rhino.Geometry.Point3d(0,​ 0, 0);
 +  Rhino.Geometry.Point3d pt1 = new Rhino.Geometry.Point3d(10,​ 10, 10);
 +  Rhino.Geometry.BoundingBox box = new Rhino.Geometry.BoundingBox(pt0,​ pt1);
 +  Rhino.Geometry.Brep brep = box.ToBrep();​
 +  Rhino.Commands.Result rc = Rhino.Commands.Result.Failure;​
 +  if( doc.Objects.AddBrep(brep) != System.Guid.Empty )
 +  {
 +    rc = Rhino.Commands.Result.Success;​
 +    doc.Views.Redraw();​
 +  }
 +  return rc;
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Shared Function AddBrepBox(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result
 +  Dim pt0 As New Rhino.Geometry.Point3d(0,​ 0, 0)
 +  Dim pt1 As New Rhino.Geometry.Point3d(10,​ 10, 10)
 +  Dim box As New Rhino.Geometry.BoundingBox(pt0,​ pt1)
 +  Dim brep As Rhino.Geometry.Brep = box.ToBrep()
 +  Dim rc As Rhino.Commands.Result = Rhino.Commands.Result.Failure
 +  If doc.Objects.AddBrep(brep) <> System.Guid.Empty Then
 +    rc = Rhino.Commands.Result.Success
 +    doc.Views.Redraw()
 +  End If
 +  Return rc
 +End Function
 +</​code>​
 +===== Python =====
 +<code python>
 +import Rhino
 +import scriptcontext
 +import System.Guid
 +
 +def AddBrepBox():​
 +    pt0 = Rhino.Geometry.Point3d(0,​ 0, 0)
 +    pt1 = Rhino.Geometry.Point3d(10,​ 10, 10)
 +    box = Rhino.Geometry.BoundingBox(pt0,​ pt1)
 +    brep = box.ToBrep()
 +    rc = Rhino.Commands.Result.Failure
 +    if( scriptcontext.doc.Objects.AddBrep(brep) != System.Guid.Empty ):
 +        rc = Rhino.Commands.Result.Success
 +        scriptcontext.doc.Views.Redraw()
 +    return rc
 +
 +if( __name__ == "​__main__"​ ):
 +    AddBrepBox()
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/addbrepbox.txt ยท Last modified: 2015/09/14 (external edit)