54 lines
2.2 KiB
Python
54 lines
2.2 KiB
Python
"""Auto-converted from endstop-block.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 EndstopBlock(Part):
|
|
def __init__(self):
|
|
super().__init__()
|
|
sketch = self._sketch = Sketch(self.xy())
|
|
|
|
# body: translate([1,-16,1]) cube([12,9,14])
|
|
self._add_box(1 + 12/2, -16 + 9/2, 1 + 14/2, 12, 9, 14)
|
|
# chamfer block: translate([1,-16,1]) rotate([0,0,45]) cube([3,2.2,14]) — approx unrotated
|
|
self._add_box(1 + 3/2, -16 + 2.2/2, 1 + 14/2, 3, 2.2, 14)
|
|
# side tab: translate([0.5,-8,1]) cube([3,1,14])
|
|
self._add_box(0.5 + 3/2, -8 + 1/2, 1 + 14/2, 3, 1, 14)
|
|
|
|
# screw hole: translate([-4,-11,11]) rotate([0,90,0]) cylinder(r=1.65, h=10)
|
|
# rotated 90 deg around Y => lies along X axis; approximate as box cut
|
|
self._add_box(-4 + 10/2, -11, 11, 10, 1.65*2, 1.65*2, cut=True)
|
|
# screw head recess: translate([5,-11,11]) rotate([0,90,0]) cylinder(r=3.1, h=10)
|
|
self._add_box(5 + 10/2, -11, 11, 10, 3.1*2, 3.1*2, cut=True)
|
|
|
|
# edge cuts approximated as boxes
|
|
self._add_box(-13 + 15/2, -22 + 15/2, 0 + 15/2, 15, 15, 15, cut=True)
|
|
self._add_box(-1 + 15/2, 0 + 15/2, -10 + 15/2, 15, 15, 15, cut=True)
|
|
self._add_box(-12 + 15/2, -20 + 15/2, 0 + 15/2, 15, 15, 15, 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 = EndstopBlock()
|
|
show(part)
|