Documentation RhinoCommon API

Python_III_RhinoCommon - Create and Bake Geometry Objects:



import Rhino

# Create and add a Point
point = Rhino.Geometry.Point3d(0,0,0)
Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(point)

# Create and add a TextDot
textdot = Rhino.Geometry.TextDot("my_text",Rhino.Geometry.Point3d(0,0,0))
Rhino.RhinoDoc.ActiveDoc.Objects.AddTextDot(textdot)

# Create and add a Line
line = Rhino.Geometry.Line(Rhino.Geometry.Point3d(0,0,0),Rhino.Geometry.Point3d(0,0,1))
Rhino.RhinoDoc.ActiveDoc.Objects.AddLine(line)

# Create and add a Polyline
polyline = Rhino.Geometry.Polyline([Rhino.Geometry.Point3d(1,0,0),Rhino.Geometry.Point3d(1,0,1)])
Rhino.RhinoDoc.ActiveDoc.Objects.AddPolyline(polyline)

# Create and add a Curve
curve = Rhino.Geometry.Curve.CreateInterpolatedCurve([Rhino.Geometry.Point3d(0,0,0),Rhino.Geometry.Point3d(0.5,0,1),Rhino.Geometry.Point3d(1,0,0)],3)
Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(curve)

# Create and add a Mesh
mesh = Rhino.Geometry.Mesh()
mesh.Vertices.Add(Rhino.Geometry.Point3d(0,0,0))
mesh.Vertices.Add(Rhino.Geometry.Point3d(1,0,1))
mesh.Vertices.Add(Rhino.Geometry.Point3d(0,1,1))
mesh.Vertices.Add(Rhino.Geometry.Point3d(1,1,0))
mesh.Faces.AddFace(Rhino.Geometry.MeshFace(0,1,2,3))
mesh.RebuildNormals()
Rhino.RhinoDoc.ActiveDoc.Objects.AddMesh(mesh)

# Create and add a Brep
brep = Rhino.Geometry.Cylinder(Rhino.Geometry.Circle(Rhino.Geometry.Plane.WorldXY,1),2).ToBrep(True,True)
Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(brep)

# Create and a Surface
surface = Rhino.Geometry.NurbsSurface.CreateFromPoints([Rhino.Geometry.Point3d(0,0,0),Rhino.Geometry.Point3d(1,0,1),Rhino.Geometry.Point3d(0,1,1),Rhino.Geometry.Point3d(1,1,0)],2,2,3,3)
Rhino.RhinoDoc.ActiveDoc.Objects.AddSurface(surface)