M_Rhino_Geometry_Sphere__ctor_1 - mcneel/rhinocommon-api-docs GitHub Wiki

Sphere Constructor (Point3d, Double)

Initializes a new sphere given center point and radius.

Namespace: Rhino.Geometry
Assembly: RhinoCommon (in RhinoCommon.dll) Version: Rhino 6.0

Syntax

C#

public Sphere(
	Point3d center,
	double radius
)

VB

Public Sub New ( 
	center As Point3d,
	radius As Double
)

Parameters

 

center
Type: Rhino.Geometry.Point3d
A center point.
radius
Type: System.Double
A radius value.

Examples

VB

Partial Class Examples
  Public Shared Function AddSphere(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result
    Dim center As New Rhino.Geometry.Point3d(0, 0, 0)
    Const radius As Double = 5.0
    Dim sphere As New Rhino.Geometry.Sphere(center, radius)
    If doc.Objects.AddSphere(sphere) <> Guid.Empty Then
      doc.Views.Redraw()
      Return Rhino.Commands.Result.Success
    End If
    Return Rhino.Commands.Result.Failure
  End Function
End Class

C#

using System;

partial class Examples
{
  public static Rhino.Commands.Result AddSphere(Rhino.RhinoDoc doc)
  {
    Rhino.Geometry.Point3d center = new Rhino.Geometry.Point3d(0, 0, 0);
    const double radius = 5.0;
    Rhino.Geometry.Sphere sphere = new Rhino.Geometry.Sphere(center, radius);
    if( doc.Objects.AddSphere(sphere) != Guid.Empty )
    {
      doc.Views.Redraw();
      return Rhino.Commands.Result.Success;
    }
    return Rhino.Commands.Result.Failure;
  }
}

Python

import Rhino
import scriptcontext
import System.Guid

def AddSphere():
    center = Rhino.Geometry.Point3d(0, 0, 0)
    radius = 5.0
    sphere = Rhino.Geometry.Sphere(center, radius)
    if scriptcontext.doc.Objects.AddSphere(sphere)!=System.Guid.Empty:
        scriptcontext.doc.Views.Redraw()
        return Rhino.Commands.Result.Success
    return Rhino.Commands.Result.Failure


if __name__ == "__main__":
    AddSphere()

Version Information

Supported in: 6.0.16224.21491, 5D58w

See Also

Reference

Sphere Structure
Sphere Overload
Rhino.Geometry Namespace

⚠️ **GitHub.com Fallback** ⚠️