Original-Prusa-i3/Printed-Parts/SCAD/bearing.py

54 lines
1.9 KiB
Python

"""Auto-converted from bearing.scad — cadbuildr.foundation port."""
from cadbuildr.foundation import (
Part, Sketch, Point,
Square, Rectangle, Circle, RegularPolygon, RectangleRounded,
Extrusion, Lathe, Hole,
Cylinder, Box, Sphere, Cone,
show,
)
# === SCAD constants reproduced verbatim ===
bearing_diameter = 14.95
thinwall = 3
bearing_size = bearing_diameter + 2 * thinwall
class Bearing(Part):
def __init__(self):
super().__init__()
sketch = self._sketch = Sketch(self.xy())
# vertical_bearing_base: cylinder h=58 r=bearing_size/2
self._add_cyl(0, 0, 29, bearing_size / 2, 58)
# flat backing slab
self._add_box(-2 - bearing_size / 4, 0, 29, 4 + bearing_size / 2, bearing_size, 58)
# vertical_bearing_holes (cut=True)
# Main bore cylinder
self._add_cyl(0, 0, -1 + 31, (14.80 / 2), 62, cut=True)
# Entry chamfer cone approximated as cylinder at bottom
self._add_cyl(0, 0, 0.25, (bearing_diameter / 2) + 0.7, 0.5, cut=True)
# Retention slot: thin cube rotated ~-40 deg — approximate as box
self._add_box(bearing_diameter / 2 - 2.9, -0.5, 31, thinwall * 2, 1, 62, cut=True)
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 = Bearing()
show(part)