Module openscad_py.cylinder
Classes
class Cylinder (h, r=None, r1=None, r2=None, center: bool = False)
-
A 3D primitive, cylinder. Creates a cylinder or cone centered about the z axis. When center is true, it is also centered vertically along the z axis.
See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#cylinder
Expand source code
class Cylinder(Object): """A 3D primitive, cylinder. Creates a cylinder or cone centered about the z axis. When center is true, it is also centered vertically along the z axis. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language#cylinder """ def __init__(self, h, r=None, r1=None, r2=None, center: bool = False): self.height = h self.r1 = r if r1 is None else r1 self.r2 = r if r2 is None else r2 self.center = center # $fa, $fs, $fn def render(self): """Render the object into OpenSCAD code""" return f"cylinder(h={self.height}, r1={self.r1}, r2={self.r2}, center={self._center()});" @classmethod def from_ends(cls, radius: float, p1: TUnion[list, Point], p2: TUnion[list, Point]) -> Object: """Construct a cylinder between two points""" p1 = Point.c(p1) p2 = Point.c(p2) v = p2.sub(p1) length = v.length() assert length != 0 z = Point([0, 0, 1]) r = z.cross(v) rangle = v.angle(z) if r.length() == 0: # The cylinder is in the Z direction if abs(abs(rangle) - 180.) < .1: p1 = p2 rangle = 0 r = z else: r = r.norm() return cls(h=length, r=radius, center=False).rotate(a=rangle, v=r).move(p1)
Ancestors
Static methods
def from_ends(radius: float,
p1: list | Point,
p2: list | Point) ‑> Object-
Construct a cylinder between two points
Methods
def color(self, r, g, b, a=1.0) ‑> Object
-
Apply a color and return a new object. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#color
def delta_offset(self, delta, chamfer=False)
-
Inherited from:
Object
.delta_offset
Return a new 2D interior or exterior outline from an existing outline. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#offset
def diff(self,
tool: list | ForwardRef('Object')) ‑> Object-
Remove from the object using a difference operator, and return a new object. See …
def extrude(self, height, convexity=10, center: bool = False) ‑> Object
-
Inherited from:
Object
.extrude
Apply a linear extrusion and return a new object. If
center
is false, the linear extrusion Z range is from 0 to height; if it is true, the range is … def intersection(self,
objects: list | ForwardRef('Object')) ‑> Object-
Inherited from:
Object
.intersection
Get the intersection of self and an object of list of objects, and return a new object. See …
def move(self,
v: list | Point) ‑> Object-
Apply a translation and return a new object. Synonym of
translate()
def radial_offset(self, r)
-
Inherited from:
Object
.radial_offset
Return a new 2D interior or exterior outline from an existing outline. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#offset
def render(self)
-
Render the object into OpenSCAD code
def rotate(self,
a,
v: list | Point) ‑> Object-
Apply a rotation and return a new object. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#rotate
def rotate_extrude(self, angle, convexity=10) ‑> Object
-
Inherited from:
Object
.rotate_extrude
Apply a rotational extrusion and return a new object. For all points x >= 0 must be true. See …
def scale(self,
v: list | Point | float) ‑> Object-
Apply scaling and return a new object. Accepts a vector (a Point object or a list of floats) or a single float for uniform scaling. See …
def translate(self,
v: list | Point) ‑> Object-
Inherited from:
Object
.translate
Apply a translation and return a new object. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#translate
def union(self,
objects: list | ForwardRef('Object')) ‑> Object-
Form the union of self and an object or list of objects, and return a new object. See …