"""Auto-converted from x-end.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 === rod_distance = 45 bearing_diameter = 14.95 thinwall = 3 bearing_size = bearing_diameter + 2 * thinwall class XEnd(Part): def __init__(self): super().__init__() sketch = self._sketch = Sketch(self.xy()) # === x_end_base() === # Main block: translate([-15,-9,height/2]) cube([17,39,58], center=true) height = 58 self._add_box(-15, -9, height/2, 17, 39, height) self._add_box(-8 + 5/2, -28.5 + 1/2, 13.5/2, 5, 1, 13.5) # Vertical bearing base self._add_box(-2 - bearing_size/4, 0, 29, 4 + bearing_size/2, bearing_size, 58) self._add_cyl(0, 0, 29, bearing_size/2, 58) # Nut trap cylinder self._add_cyl(0, -17, 0, 12.5, 13.5) self._add_cyl(0, -17, 13, 12.5, 3) # === x_end_holes() (cuts) === # Vertical bearing bore self._add_cyl(0, 0, 31, bearing_diameter/2 + 0.2, 62, cut=True) # Belt stress relief slot self._add_box(-15, -10, 30, 10, 46, 28, cut=True) # Bottom pushfit rod hole self._add_cyl(-15, -41, 6, 7.8/2, 50, cut=True) # Top pushfit rod hole self._add_cyl(-15, -41.5, rod_distance + 6, 7.8/2, 50, cut=True) # TR Nut hole self._add_cyl(0, -17, -1, 6.7, 14.51, cut=True) # Screw holes for TR nut (approx positions) self._add_cyl(0 + 9.5 * 0.707, -17 - 9.5 * 0.707, -4, 1.65, 19, cut=True) self._add_cyl(0 - 9.5 * 0.707, -17 + 9.5 * 0.707, -4, 1.65, 19, cut=True) # Nut traps (hex approx as cylinders) self._add_cyl(0 + 9.5 * 0.707, -17 - 9.5 * 0.707, 11, 3.15, 6, cut=True) self._add_cyl(0 - 9.5 * 0.707, -17 + 9.5 * 0.707, 10, 3.1, 3, 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 = XEnd() show(part)