Original-Prusa-i3/Printed-Parts/SCAD/z-screw-cover.py

63 lines
2.2 KiB
Python

"""Auto-converted from z-screw-cover.scad — cadbuildr.foundation port."""
from cadbuildr.foundation import (
Part, Sketch, Point,
Square, Rectangle, Circle, RegularPolygon, RectangleRounded,
Extrusion, Lathe, Hole,
Cylinder, Box, Sphere, Cone,
show,
)
class ZScrewCover(Part):
def __init__(self):
super().__init__()
sketch = self._sketch = Sketch(self.xy())
# Main body: cone from r=8 to r=4.6 over h=4 starting at z=1
self._add_cone(0, 0, 1, 8, 4.6, 4)
# Base disk r=8, h=1
self._add_cyl(0, 0, 0, 8, 1)
# Central bore cut: cylinder r=4.2, h=7 starting at z=-1
self._add_cyl(0, 0, -1, 4.2, 7, cut=True)
# Entry chamfer cut: cone r1=4.5 r2=4.2, h=1
self._add_cone(0, 0, 0, 4.5, 4.2, 1) # forms chamfer shape (not a cut here)
# Decorative fins (small cones along X/Y axes, approximated as small cylinders)
# Layer 1 z=4.3
self._add_cyl(-4.2, 0, 4.3, 0.5, 1)
self._add_cyl(4.2, 0, 4.3, 0.5, 1)
self._add_cyl(0, 4.2, 4.3, 0.5, 1)
self._add_cyl(0, -4.2, 4.3, 0.5, 1)
# Layer 2 z=4.0
self._add_cyl(-4.2, 0.5, 4.0, 0.45, 0.8)
self._add_cyl(4.2, -0.5, 4.0, 0.45, 0.8)
self._add_cyl(0.5, 4.2, 4.0, 0.45, 0.8)
self._add_cyl(-0.5, -4.2, 4.0, 0.45, 0.8)
# Layer 3 z=3.7
self._add_cyl(-4.2, 1, 3.7, 0.4, 0.6)
self._add_cyl(4.2, -1, 3.7, 0.4, 0.6)
self._add_cyl(1, 4.2, 3.7, 0.4, 0.6)
self._add_cyl(-1, -4.2, 3.7, 0.4, 0.6)
def _pt(self, x, y):
return Point(self._sketch, x, y)
def _add_box(self, x, y, z, w, d, h, cut=False):
self.add_operation(Box(self._pt(x, y), w, d, h, cut=cut))
def _add_cyl(self, x, y, z, radius, height, cut=False):
self.add_operation(Cylinder(self._pt(x, y), radius, height, cut=cut))
def _add_cone(self, x, y, z, r1, r2, height):
self.add_operation(Cone(self._pt(x, y), r1, r2, height))
def _add_sphere(self, x, y, z, radius, cut=False):
self.add_operation(Sphere(self._pt(x, y), radius, cut=cut))
def _add_extrusion(self, shape, end, start=0, cut=False):
self.add_operation(Extrusion(shape, end=end, start=start, cut=cut))
part = ZScrewCover()
show(part)