Site Tools


Differences

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

Link to this comparison view

developer:rhinocommonsamples:addcone [2015/09/14] (current)
Line 1: Line 1:
 +===== Sample: Add Cone =====
 +
 +===== C# =====
 +<code c#>
 +public static Rhino.Commands.Result AddCone(Rhino.RhinoDoc doc)
 +{
 +  Rhino.Geometry.Plane plane = Rhino.Geometry.Plane.WorldXY;​
 +  const double height = 10;
 +  const double radius = 5;
 +  Rhino.Geometry.Cone cone = new Rhino.Geometry.Cone(plane,​ height, radius);
 +  if (cone.IsValid)
 +  {
 +    const bool cap_bottom = true;
 +    Rhino.Geometry.Brep cone_brep = cone.ToBrep(cap_bottom);​
 +    if (cone_brep!=null)
 +    {
 +      doc.Objects.AddBrep(cone_brep);​
 +      doc.Views.Redraw();​
 +    }
 +  }
 +  return Rhino.Commands.Result.Success;​
 +}
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Shared Function AddCone(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result
 +  Dim plane As Rhino.Geometry.Plane = Rhino.Geometry.Plane.WorldXY
 +  Const height As Double = 10
 +  Const radius As Double = 5
 +  Dim cone As New Rhino.Geometry.Cone(plane,​ height, radius)
 +  If cone.IsValid Then
 +    Const cap_bottom As Boolean = True
 +    Dim cone_brep As Rhino.Geometry.Brep = cone.ToBrep(cap_bottom)
 +    If cone_brep IsNot Nothing Then
 +      doc.Objects.AddBrep(cone_brep)
 +      doc.Views.Redraw()
 +    End If
 +  End If
 +  Return Rhino.Commands.Result.Success
 +End Function
 +</​code>​
 +===== Python =====
 +<code python>
 +import Rhino
 +import scriptcontext
 +
 +def AddCone():
 +    plane = Rhino.Geometry.Plane.WorldXY
 +    height = 10
 +    radius = 5
 +    cone = Rhino.Geometry.Cone(plane,​ height, radius)
 +    if cone.IsValid:​
 +        cap_bottom = True
 +        cone_brep = cone.ToBrep(cap_bottom)
 +        if cone_brep:
 +            scriptcontext.doc.Objects.AddBrep(cone_brep)
 +            scriptcontext.doc.Views.Redraw()
 +    return Rhino.Commands.Result.Success
 +
 +if __name__=="​__main__":​
 +    AddCone()
 +</​code>​
 +
 +{{tag>​Developer rhinocommon}}
  
developer/rhinocommonsamples/addcone.txt ยท Last modified: 2015/09/14 (external edit)