"""O-ring splicing fixture after Draffone, US 4,050,975 (1977). FROM THE PATENT: flat surface 12 with three slotted spiral
walls (outer 13, intermediate 14, inner 16) about 3.175 mm thick; grooves 17 and 18 each 14.288 mm wide; 24 slots per wall
about 0.5 mm wide on diametral planes; the intermediate wall drawn as 10-degree arcs of radius D/2 for D = 26-40 mm in 2 mm
steps and 45-120 mm in 5 mm steps, each new centre found by measuring back along the last radius; outer and inner walls at
fixed distances from it; the outer wall starts and ends at the front face 19; an unslotted wall 33 below the surface
following the outer periphery; L-shaped blade holders 24, 26 on the front face with a nipple 31.
OURS: wall height 8, surface 3 thick, skirt 15 deep, the inner wall only where its radius is at least 5 mm, slot numbers
engraved in groove 17, blade-holder sizes for a 38 mm single-edge blade. mm, z up. Log: out/build.log"""
import os, math
import FreeCAD as App, Part
V = App.Vector
OUT = "/home/admiraloom/Desktop/youblob/JIRA-tasks/freecad/batch-2541/out/"
LOG = open(OUT + "build.log", "w")
def L(*a): LOG.write(" ".join(map(str, a)) + "\n"); LOG.flush()
WALL, GROOVE, SLOT = 3.175, 14.288, 0.5 # patent
H_WALL, T_PLATE, H_SKIRT = 8.0, 3.0, 15.0 # ours
OFF = GROOVE + WALL # wall centre to wall centre
D = [26, 28, 30, 32, 34, 36, 38, 40] + list(range(45, 121, 5))
assert len(D) == 24
# polycentric spiral: segment i = (centre, radius, a0, a1)
segs = []; a = math.radians(-60); C = (0.0, 0.0); P = None
for i, d in enumerate(D):
r = d / 2
if i: C = (P[0] - r * math.cos(a), P[1] - r * math.sin(a))
segs.append((C, r, a, a + math.radians(10)))
a += math.radians(10); P = (C[0] + r * math.cos(a), C[1] + r * math.sin(a))
def sector(C, r_in, r_out, a0, a1, z0, z1):
"""annular sector about C between radii, angles a0..a1 (rad), from z0 to z1"""
n = 12; pts = [V(C[0] + r_out * math.cos(a0 + (a1 - a0) * k / n), C[1] + r_out * math.sin(a0 + (a1 - a0) * k / n), z0) for k in range(n + 1)]
pts += [V(C[0] + r_in * math.cos(a1 - (a1 - a0) * k / n), C[1] + r_in * math.sin(a1 - (a1 - a0) * k / n), z0) for k in range(n + 1)]
w = Part.makePolygon(pts + [pts[0]])
return Part.Face(w).extrude(V(0, 0, z1 - z0))
def arc_sector(C, r_in, r_out, a0, a1, z0, z1): # exact arcs
ring = Part.makeCylinder(r_out, z1 - z0, V(C[0], C[1], z0)).cut(Part.makeCylinder(max(r_in, 0.01), z1 - z0 + 2, V(C[0], C[1], z0 - 1)))
R = r_out + 5
wedge = Part.Face(Part.makePolygon([V(C[0], C[1], z0 - 1)] + [V(C[0] + R / math.cos(math.radians(5)) * math.cos(a0 + (a1 - a0) * k / 4), C[1] + R / math.cos(math.radians(5)) * math.sin(a0 + (a1 - a0) * k / 4), z0 - 1) for k in range(5)] + [V(C[0], C[1], z0 - 1)])).extrude(V(0, 0, z1 - z0 + 2))
return ring.common(wedge)
walls = {"outer 13": +OFF, "intermediate 14": 0.0, "inner 16": -OFF}
wall_solids = {}
for name, off in walls.items():
sh = None
for (C, r, a0, a1) in segs:
rc = r + off
if rc - WALL / 2 < 5.0: continue # ours: no inner wall where it would be smaller than 5 mm
s = arc_sector(C, rc - WALL / 2, rc + WALL / 2, a0, a1, 0, H_WALL)
sh = s if sh is None else sh.fuse(s)
wall_solids[name] = sh.removeSplitter()
# outline: the outer wall's outer face, closed by the straight front face
def outer_pts(z, inset=0.0):
pts = []
for (C, r, a0, a1) in segs:
R = r + OFF + WALL / 2 - inset
for k in range(10):
t = a0 + (a1 - a0) * k / 10; pts.append(V(C[0] + R * math.cos(t), C[1] + R * math.sin(t), z))
C, r, a0, a1 = segs[-1]; R = r + OFF + WALL / 2 - inset; pts.append(V(C[0] + R * math.cos(a1), C[1] + R * math.sin(a1), z))
return pts
pts = outer_pts(0); front_r, front_l = pts[0], pts[-1]
L("front face from", [round(front_l.x, 1), round(front_l.y, 1)], "to", [round(front_r.x, 1), round(front_r.y, 1)], "length", round((front_r - front_l).Length, 1))
outline = Part.Face(Part.makePolygon(pts + [pts[0]]))
plate = outline.extrude(V(0, 0, -T_PLATE))
skirt = outline.extrude(V(0, 0, -H_SKIRT)) # ours: solid under the surface, so it prints flat on its base; its outside is wall 33
body = plate.fuse(skirt)
for s in wall_solids.values(): body = body.fuse(s)
# slots: one diametral plane per segment, through all three walls, down to the surface
for (C, r, a0, a1), d in zip(segs, D):
am = (a0 + a1) / 2
ux, uy = math.cos(am), math.sin(am)
r0, r1 = max(r - OFF - WALL, 0.5), r + OFF + WALL
sl = Part.makeBox(r1 - r0, SLOT, H_WALL + 1, V(r0, -SLOT / 2, 0.0))
sl.rotate(V(0, 0, 0), V(0, 0, 1), math.degrees(am)); sl.translate(V(C[0], C[1], 0))
body = body.cut(sl)
# slot numbers, engraved 0.5 deep in groove 17 beside each slot (ours)
FONT = "/usr/share/fonts/truetype/dejavu/"
for (C, r, a0, a1), d in zip(segs, D):
am = (a0 + a1) / 2 + math.radians(4.5 if d < 45 else 2.2)
rr = r + OFF / 2
chars = Part.makeWireString(str(d), FONT, "DejaVuSans-Bold.ttf", 3.6, 0)
faces = []
for cw in chars:
if cw: faces.append(Part.makeFace(cw, "Part::FaceMakerBullseye"))
if not faces: continue
txt = faces[0]
for f in faces[1:]: txt = txt.fuse(f)
bb = txt.BoundBox
txt.translate(V(-bb.Center.x, -bb.Center.y, 0))
txt.rotate(V(0, 0, 0), V(0, 0, 1), math.degrees(am) - 90) # reads along the groove
txt.translate(V(C[0] + rr * math.cos(am), C[1] + rr * math.sin(am), -0.5))
body = body.cut(txt.extrude(V(0, 0, 1.0)))
# blade holders 24, 26 and nipple 31 on the front face (ours: 30 mm apart, gap 0.8 at the top to 0.3 at the bottom)
fx = (front_r - front_l); fx.normalize(); nrm = V(fx.y, -fx.x, 0) # outward normal of the front face
if nrm.y > 0: nrm = nrm * -1
mid = (front_l + front_r) * 0.5
holders = None
for s in (-15.0, 15.0):
base = mid + fx * s
sx = 0.5 if s < 0 else -1.5 # standoff on the outer side of each L
stand = Part.makeBox(1.0, 3.3, 12.0, V(sx, -0.5, -14.0)) # base of the L, into the face
lip = Part.Face(Part.makePolygon([V(-1.5, 0.8, 0), V(-1.5, 0.3, -12), V(-1.5, 2.8, -12), V(-1.5, 2.8, 0), V(-1.5, 0.8, 0)])).extrude(V(3.0, 0, 0)).translate(V(0, 0, -2.0))
hook = stand.fuse(lip)
# local frame: x along the face, y outward
ang = math.degrees(math.atan2(fx.y, fx.x)) + 180.0 # local +y points out of the front face
hook.rotate(V(0, 0, 0), V(0, 0, 1), ang); hook.translate(V(base.x, base.y, 0))
holders = hook if holders is None else holders.fuse(hook)
nip = Part.makeSphere(0.6, V(mid.x, mid.y, -8.0)).common(Part.makeBox(4, 4, 4, V(mid.x - 2, mid.y - 2, -10)))
body = body.fuse(holders).fuse(nip.translate(nrm * -0.25)).removeSplitter()
bb = body.BoundBox
L("valid", body.isValid(), "solids", len(body.Solids), "size", round(bb.XLength, 1), round(bb.YLength, 1), round(bb.ZLength, 1), "vol cm3", round(body.Volume / 1000, 1))
# checks: groove widths and slot alignment on a few diametral planes
for i in (0, 8, 16, 23):
C, r, a0, a1 = segs[i]; am = (a0 + a1) / 2
L(f"D {D[i]}: centre ({C[0]:.2f}, {C[1]:.2f}) radius {r} wall radii", [round(r + o, 2) for o in walls.values()])
# centre steps (patent: each new centre 1 mm, 1 mm ... further back; 2.5 mm after 40)
L("centre steps", [round(math.dist(segs[i][0], segs[i + 1][0]), 2) for i in range(23)])
if os.environ.get("NOSAVE") != "1":
import MeshPart
MeshPart.meshFromShape(Shape=body, LinearDeflection=0.03, AngularDeflection=0.15).write(OUT + "o-ring-splicing-fixture.stl")
L("stl saved")
if os.environ.get("HERO") == "1":
import FreeCADGui as Gui
d = App.newDocument("h")
o = d.addObject("Part::Feature", "fixture"); o.Shape = body
# a cord lying in groove 17 for D = 70, cut at slot 70, for the picture
cord = None
for (C, r, a0, a1), dd in zip(segs, D):
rr = r + OFF / 2
seg = Part.makeTorus(rr, 2.5, V(C[0], C[1], 2.5), V(0, 0, 1), 0, 360).common(arc_sector(C, rr - 4, rr + 4, a0, a1, -1, 8))
cord = seg if cord is None else cord.fuse(seg)
if dd == 70: break
c = d.addObject("Part::Feature", "cord"); c.Shape = cord; d.recompute()
Gui.ActiveDocument.getObject("fixture").ShapeColor = (0.95, 0.62, 0.15)
Gui.ActiveDocument.getObject("cord").ShapeColor = (0.12, 0.12, 0.12)
v = Gui.ActiveDocument.ActiveView
v.setCameraType("Orthographic"); v.setViewDirection((0.35, 0.75, -0.75)); v.fitAll(); Gui.updateGui()
v.saveImage(OUT + "hero.png", 1600, 1200, "White"); L("hero saved")
LOG.close()
os._exit(0)