Cylinder
Geometric definition
A cylinder is an object with a constant circular section, and whose axis is perpendicular to its circular base. It can also be seen as the surface for which all the included points are at a constant distance from a given axis.
How to add
RhinoCommons
import Rhino
import scriptcontext as sc
# Parameter needed to create the cylinder
my_circle = Rhino.Geometry.Circle(2)
# Will create a cylinder from a base circle and a height
my_cylinder = Rhino.Geometry.Cylinder(my_circle, 5)
sc.doc.Objects.AddSurface(my_cylinder.ToNurbsSurface())
import Rhino
import scriptcontext as sc
# Parameter needed to create the cylinder
my_circle = Rhino.Geometry.Circle(2)
# Will create a cylinder from a base circle and with an infinite height
# Nevertheless, it cannot be added to the document as it is an infinite object
my_infinite_cylinder = Rhino.Geometry.Cylinder(my_circle)
Rhinoscriptsyntax
import rhinoscriptsyntax as rs
# Parameters needed to create the cylinder
my_plane = Rhino.Geometry.Plane.WorldXY
height = 5
radius = 2
cap_ends = True
# Will create a cylinder from a base plane, a height and a radius
my_cylinder = rs.AddCylinder(my_plane, height, radius, cap_ends)
Main methods and properties:
Methods
The main methods for the cylinder class are:
import math
# Will retrieve the line on the surface of the cylinder at a given angle from the axis
my_line = my_cylinder.LineAt(math.pi/2)
# Will transform the cylinder object into a NURBS surface
my_nurbs_cylinder = my_cylinder.ToNurbsSurface()
# Will transform the cylinder object into a Brep
my_brep_cylinder = my_cylinder.ToBrep(capBottom = True, capTop = False)
Properties
The main properties for the cylinder class are:
# Will retrieve the axis of the cylinder
cyliner_axis = my_cylinder.Axis
# Will retrieve the base plane of the cylinder
cyliner_base_plane = my_cylinder.BasePlane
# Will retrieve the radius of the cylinder
cyliner_radius = my_cylinder.Radius
🛠 Exercise
01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍
Solution:
01: 🐍⬇️⬇️⬇️ Download the script here ⬇️⬇️⬇️🐍