66 lines
2.5 KiB
Python
66 lines
2.5 KiB
Python
"""Auto-converted from Einsy-hinges.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 EinsyHinges(Part):
|
|
def __init__(self):
|
|
super().__init__()
|
|
sketch = self._sketch = Sketch(self.xy())
|
|
|
|
# === upper_hinge() ===
|
|
# body cylinder h=26 r=2.4
|
|
self._add_cyl(0, 0, 0, 2.4, 26)
|
|
# top taper cone
|
|
self._add_cone(0, 0, 26, 2.4, 1.8, 2)
|
|
# body block: translate([-5,-10.7,0]) cube([7,10.7,21])
|
|
self._add_box(-5 + 7/2, -10.7 + 10.7/2, 0 + 21/2, 7, 10.7, 21)
|
|
|
|
# M3 screw hole (along X — approx as horizontal box cut)
|
|
self._add_box(-12.5 + 20/2, -2.5, 17, 20, 1.75*2, 1.75*2, cut=True)
|
|
# screw head recess
|
|
self._add_box(-1.5 + 9/2, -2.5, 17, 9, 3*2, 3*2, cut=True)
|
|
# angle cut (approx as box)
|
|
self._add_box(-2.9 + 25/2, -20 + 5/2, -1 + 26/2, 25, 5, 26, cut=True)
|
|
|
|
# === lower_hinge() — offset so it doesn't overlap ===
|
|
OX = 15 # separate the two hinges visually
|
|
# body cylinders at translate([0,6,0])
|
|
self._add_cyl(0 + OX, 6, 0, 2.4, 15)
|
|
self._add_cyl(0 + OX, 6, 0, 2.8, 10)
|
|
self._add_cone(0 + OX, 6, 15, 2.4, 1.8, 2)
|
|
# body block: translate([-5,6,0]) cube([7,10.7,10])
|
|
self._add_box(-5 + 7/2 + OX, 6 + 10.7/2, 0 + 10/2, 7, 10.7, 10)
|
|
|
|
# M3 screw (along X)
|
|
self._add_box(-0.5 + 20/2 + OX, 8.5, 4, 20, 3*2, 3*2, cut=True)
|
|
self._add_box(-12 + 20/2 + OX, 8.5, 4, 20, 1.75*2, 1.75*2, cut=True)
|
|
# angle cut
|
|
self._add_box(-5 + 20/2 + OX, 20 + 5/2, -1 + 20/2, 20, 5, 20, 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 = EinsyHinges()
|
|
show(part)
|