83 lines
3.0 KiB
Python
83 lines
3.0 KiB
Python
"""Auto-converted from z-axis-top.scad — cadbuildr.foundation port."""
|
|
from cadbuildr.foundation import (
|
|
Part, Sketch, Point,
|
|
Square, Rectangle, Circle, RegularPolygon, RectangleRounded,
|
|
Extrusion, Lathe, Hole,
|
|
Cylinder, Box, Sphere, Cone,
|
|
show,
|
|
)
|
|
|
|
MX = 25 + 4.3 # rod/screw centre X
|
|
MY = 3.0 # rod centre Y
|
|
|
|
class ZAxisTop(Part):
|
|
def __init__(self):
|
|
super().__init__()
|
|
sketch = self._sketch = Sketch(self.xy())
|
|
|
|
# === z_top_base() ===
|
|
self._add_box(0 + 8/2, -5 + 45/2, 0 + 16/2, 8, 45, 16)
|
|
self._add_box(0 + 33/2, -5 + 3.6/2, 0 + 12/2, 33, 3.6, 12)
|
|
self._add_box(0 + 38/2, -5 + 45/2, 0 + 5/2, 38, 45, 5)
|
|
# rod boss
|
|
self._add_cyl(MX, MY + 0.2, 5, 7, 2.5)
|
|
|
|
# === z_top_holes() (cuts) ===
|
|
# Screw holes (along X)
|
|
self._add_box(-1 + 20/2, 10, 10, 20, 1.6*2, 1.6*2, cut=True)
|
|
self._add_box(-1 + 20/2, 30, 10, 20, 1.6*2, 1.6*2, cut=True)
|
|
|
|
# Screw heads
|
|
self._add_box(4 + 20/2, 10, 10, 20, 3.1*2, 3.1*2, cut=True)
|
|
self._add_box(4 + 10/2, 10 - 3.1, 10 + 10/2, 10, 6.2, 10, cut=True)
|
|
self._add_box(4 + 20/2, 30, 10, 20, 3.1*2, 3.1*2, cut=True)
|
|
self._add_box(4 + 10/2, 30 - 3.1, 10 + 10/2, 10, 6.2, 10, cut=True)
|
|
|
|
# Z rod holder
|
|
self._add_cyl(MX, MY, 0.6, 4.05, 50, cut=True)
|
|
self._add_cone(MX, MY, 3.4, 4.05, 4.3, 4.2) # taper (not cut)
|
|
|
|
# Material saving hex cutouts
|
|
self._add_cyl(16, 10, -4, 8, 50, cut=True)
|
|
self._add_cyl(16, 28, -4, 8, 50, cut=True)
|
|
|
|
# Z screw hole (leadscrew nut pocket)
|
|
self._add_cyl(MX, MY + 17, 0.6, 5.8, 50, cut=True)
|
|
|
|
# Rod slot
|
|
self._add_box(MX - 1 + 2/2, MY + 15/2, 0.6 + 8/2, 2, 15, 8, cut=True)
|
|
|
|
# Shape cuts (outer profile)
|
|
self._add_box(4 + 30/2, -1 - 5 + 50/2, 12 + 30/2, 30, 50, 30, cut=True)
|
|
self._add_box(8 + 50/2, 28 + 50/2, -3 + 51/2, 50, 50, 51, cut=True)
|
|
|
|
# left variant (mirrored, offset)
|
|
self._add_box(60 + 8/2, -5 + 45/2, 0 + 16/2, 8, 45, 16)
|
|
self._add_box(60 + 33/2, -5 + 3.6/2, 0 + 12/2, 33, 3.6, 12)
|
|
self._add_box(60 + 38/2, -5 + 45/2, 0 + 5/2, 38, 45, 5)
|
|
self._add_cyl(60 + MX, MY + 0.2, 5, 7, 2.5)
|
|
self._add_cyl(60 + MX, MY, 0.6, 4.05, 50, cut=True)
|
|
self._add_cyl(60 + MX, MY + 17, 0.6, 5.8, 50, 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 = ZAxisTop()
|
|
show(part)
|