"""Corker after Raiche US 675,906 (1901): kinematics and layout. EVERY number OURS (mm, ground z = base top).
x: from the standard's front face towards the bottle; y: across; z: up."""
import math
M, Z = 2.5, 16 # module, wheel teeth
R = M * Z / 2 # wheel pitch radius 20
FACE = 15.0 # tooth face width (y)
BOTTLE_TOP = 300.0 # 75 cl wine bottle (measure yours; the head is set by where the standard's rack sits)
COLLAR_H = 30.0 # collar 25 height = cork length it holds
CLEAR = 25.0 # collar bottom above the bottle top, head fully up
CORK_TOP_GAP = 0.0 # cork top flush with collar top
TIP_GAP = CLEAR # plunger tip this far above the cork: it just reaches the cork as the collar seats
PUSH_PAST = 2.0 # tip ends 2 mm below the bottle top: cork set just under flush
X_RACK7_PITCH = 1.25 * M # rack 7 root on the standard face (x = 0), pitch line here
X_AXLE = X_RACK7_PITCH + R
X_PLUNGER_PITCH = X_AXLE + R
X_PLUNGER_ROOT = X_PLUNGER_PITCH + 1.25 * M
PLUNGER_T = 12.0 # plunger body behind its teeth (x)
X_BOTTLE = X_PLUNGER_ROOT + PLUNGER_T / 2 # cork / bottle axis
# strokes
phase1 = CLEAR # head travel until the collar seats; plunger moves 2x (head + relative)
rel1 = phase1 # plunger travel relative to the head in phase 1
phase2_rel = COLLAR_H + PUSH_PAST # plunger travel relative to the (stopped) head in phase 2 = rack 7 rise
theta1, theta2 = phase1 / R, phase2_rel / R
COLLAR_BOT_UP = BOTTLE_TOP + CLEAR
CORK_TOP_UP = COLLAR_BOT_UP + COLLAR_H
TIP_UP = CORK_TOP_UP + TIP_GAP
TIP_END = BOTTLE_TOP - PUSH_PAST
# head (plates 10/11) and axle at the up position
TIP_OUT = 37.0 # M8 tip bolt sticks out this far below the plunger body (keeps the body out of the collar)
AXLE_UP = TIP_UP + 50.0
HEAD_H = 110.0
HEAD_BOT_UP = AXLE_UP - 50.0
if __name__ == "__main__":
print(f"axle x {X_AXLE:.2f}, plunger pitch x {X_PLUNGER_PITCH:.2f}, bottle axis x {X_BOTTLE:.2f}")
print(f"phase 1: head down {phase1}, plunger down {2*phase1} (2x); turn {math.degrees(theta1):.0f} deg")
print(f"phase 2: head still, plunger down {phase2_rel}, rack 7 up {phase2_rel} against the spring; turn {math.degrees(theta2):.0f} deg")
print(f"handle total {math.degrees(theta1+theta2):.0f} deg; tip {TIP_UP} -> {TIP_UP - 2*phase1 - phase2_rel} (target {TIP_END})")
print(f"collar bottom up {COLLAR_BOT_UP}, axle up {AXLE_UP}, axle down {AXLE_UP-phase1}")
# ---- build_all.py ----
"""Raiche corker (US 675,906) with our sizes: parts, clash check at three handle positions, STL export, hero render.
freecadcmd with NOSAVE=1 -> solids + clash only."""
import os, sys, math
sys.path.insert(0, "/home/admiraloom/Desktop/youblob/JIRA-tasks/batch-2535")
sys.path.insert(0, "/home/admiraloom/Desktop/youblob/JIRA-tasks/freecad/batch-2525")
import importlib, _geo as G; importlib.reload(G)
import FreeCAD as App, Part
V = App.Vector
OUT = "/home/admiraloom/Desktop/youblob/JIRA-tasks/freecad/batch-2535/out/"
LOG = open(OUT + "build.log", "w")
def L(*a): LOG.write(" ".join(map(str, a)) + "\n"); LOG.flush()
def box(x0, x1, y0, y1, z0, z1): return Part.makeBox(x1-x0, y1-y0, z1-z0, V(x0, y0, z0))
def ycyl(x, z, r, y0, y1): return Part.makeCylinder(r, y1-y0, V(x, y0, z), V(0, 1, 0))
def zcyl(x, y, r, z0, z1): return Part.makeCylinder(r, z1-z0, V(x, y, z0), V(0, 0, 1))
def xcyl(y, z, r, x0, x1): return Part.makeCylinder(r, x1-x0, V(x0, y, z), V(1, 0, 0))
m = G.M; p = math.pi * m; PA = math.radians(20); BL = 0.25
def rack(x_root, sgn, z0, z1, zref, y0, y1, body):
"""Rack along z; teeth point to +x (sgn=+1) or -x from the root line x_root; a tooth SPACE is centred at zref."""
xp = x_root + sgn * 1.25 * m; xt = xp + sgn * m
tw = p / 2 - BL # tooth thickness at the pitch line
half_p = tw / 2; dt = math.tan(PA)
solid = box(*(sorted([x_root, x_root - sgn * body])), y0, y1, z0, z1)
k0 = int((z0 - zref) / p) - 2; k1 = int((z1 - zref) / p) + 2
for k in range(k0, k1 + 1):
zc = zref + (k + 0.5) * p # tooth centre half a pitch from a space centre
pts = [(x_root, zc - half_p - 1.25 * m * dt), (xt, zc - half_p + m * dt), (xt, zc + half_p - m * dt), (x_root, zc + half_p + 1.25 * m * dt)]
w = Part.makePolygon([V(x, y0, z) for x, z in pts] + [V(pts[0][0], y0, pts[0][1])])
t = Part.Face(w).extrude(V(0, y1 - y0, 0))
solid = solid.fuse(t)
return solid.common(box(-500, 500, y0 - 1, y1 + 1, z0, z1)).removeSplitter()
try:
import gears as GR
GR.PA = PA; GR.BACKLASH = BL
prof = GR.involute_profile(G.Z, m, pts=10)
def wheel_at(x, z, ang):
w = Part.makePolygon([V(px, 0, pz) for px, pz in prof] + [V(prof[0][0], 0, prof[0][1])])
sh = Part.Face(w).extrude(V(0, G.FACE, 0)).translate(V(0, -G.FACE / 2, 0))
sh = sh.cut(ycyl(0, 0, 4.2, -20, 20))
sh.rotate(V(0, 0, 0), V(0, 1, 0), ang)
return sh.translate(V(x, 0, z))
# ---- fixed: base, standard, shoulder, rack 7 rest position ------------------------
base = box(-120, 180, -90, 90, -25, 0)
std = box(-50, 0, -20, 20, 0, 600).cut(box(-14.5, 0.1, -8, 8, 300, 601)).cut(box(-16.5, 0.1, -8, 8, 220, 300.1)) # groove 3 (rack) and groove 4 (spring)
shoulder = box(-14.4, -0.1, -7.9, 7.9, 300, 315).cut(zcyl(-7, 0, 4.3, 299, 316))
RACK7_Z0, RACK7_Z1 = 315.0, 470.0
def rack7(rise): return rack(0.0, 1, RACK7_Z0 + rise, RACK7_Z1 + rise, G.AXLE_UP + rise, -7.5, 7.5, 14.0).cut(zcyl(-7, 0, 3.4, RACK7_Z0 + rise - 1, RACK7_Z0 + rise + 30)).cut(Part.makePolygon([V(-7 + 7.6*math.cos(math.radians(60*i+30)), 7.6*math.sin(math.radians(60*i+30)), 0) for i in range(7)]).extend if False else Part.Face(Part.makePolygon([V(-7 + 7.6*math.cos(math.radians(60*i+30)), 7.6*math.sin(math.radians(60*i+30)), RACK7_Z0 + rise + 8) for i in range(7)])).extrude(V(0, 0, 7)))
# ---- head (moves down by h) ----------------------------------------------------------
XB = G.X_BOTTLE
def plates(h):
out = None
for s in (1, -1):
pl = box(-62, 68, 8 if s > 0 else -26, 26 if s > 0 else -8, G.HEAD_BOT_UP - 15, G.HEAD_BOT_UP + G.HEAD_H)
pl = pl.cut(box(-51, 0.2, -20.3 if s < 0 else 7, 20.3 if s > 0 else -7, 0, 700)) # room for the standard
pl = pl.cut(box(-51, 0.2, -20.3, 20.3, 0, 700))
out = pl if out is None else out.fuse(pl)
for (x, z, r) in ((G.X_AXLE, G.AXLE_UP, 4.3), (-56, G.AXLE_UP, 3.2), (62, G.HEAD_BOT_UP - 8, 3.2), (62, G.AXLE_UP - 35, 3.2)):
out = out.cut(ycyl(x, z, r, -40, 40))
return out.translate(V(0, 0, -h))
def bracket(h):
zb = G.COLLAR_BOT_UP
blk = box(XB - 22, XB + 22, -22, 22, zb, zb + G.COLLAR_H)
for s in (1, -1):
blk = blk.fuse(box(50, 70, 26 if s > 0 else -32, 32 if s > 0 else -26, zb, G.AXLE_UP - 25))
blk = blk.fuse(box(50, 70, 22 if s > 0 else -26, 26 if s > 0 else -22, zb, zb + G.COLLAR_H))
blk = blk.cut(zcyl(XB, 0, 18.2, zb - 1, zb + G.COLLAR_H + 1))
for z in (G.HEAD_BOT_UP - 8, G.AXLE_UP - 35): blk = blk.cut(ycyl(62, z, 3.2, -40, 40))
return blk.translate(V(0, 0, -h))
def collar(h):
zb = G.COLLAR_BOT_UP; H = G.COLLAR_H
outer = zcyl(XB, 0, 18.0, zb, zb + H)
bore = Part.makeCone(18.5 / 2, 27 / 2, H - 6.3, V(XB, 0, zb + 6.3), V(0, 0, 1))
seat = Part.makeCone(31 / 2, 18.5 / 2, 6.3, V(XB, 0, zb - 0.01), V(0, 0, 1))
return outer.cut(bore.fuse(seat).fuse(zcyl(XB, 0, 18.5/2, zb, zb + 7))).translate(V(0, 0, -h))
def bolts(h):
b = None
for (x, z) in ((-56, G.AXLE_UP), (62, G.HEAD_BOT_UP - 8), (62, G.AXLE_UP - 35)):
c = ycyl(x, z, 3.0, -36, 36); b = c if b is None else b.fuse(c)
return b.translate(V(0, 0, -h))
def plunger(h, rel):
zb = G.TIP_UP + G.TIP_OUT; body = rack(G.X_PLUNGER_ROOT, -1, zb, zb + 125, G.AXLE_UP, -7.5, 7.5, G.PLUNGER_T)
tip = zcyl(XB, 0, 4.0, G.TIP_UP, zb + 20)
return body.fuse(tip).translate(V(0, 0, -h - rel))
def axle_handle(h, ang):
ax = ycyl(G.X_AXLE, G.AXLE_UP, 4.0, -40, 60)
lever = box(-10, 180, 38, 48, -8, 8); lever = lever.fuse(ycyl(0, 0, 14, 38, 48))
lever.rotate(V(0, 0, 0), V(0, 1, 0), 240 + ang) # starts pointing up and back, pushed down and forward
lever.translate(V(G.X_AXLE, 0, G.AXLE_UP))
return ax.fuse(lever).translate(V(0, 0, -h))
bottle = zcyl(XB, 0, 14.5, 230, G.BOTTLE_TOP).fuse(zcyl(XB, 0, 37, 0, 230)).cut(zcyl(XB, 0, 9.25, 200, G.BOTTLE_TOP + 1))
# three positions: rest, collar seated, full stroke
th1, th2 = math.degrees(G.theta1), math.degrees(G.theta2)
STATES = {"rest": (0.0, 0.0, 0.0, 0.0), "seated": (G.phase1, G.rel1, 0.0, th1), "full": (G.phase1, G.rel1 + G.phase2_rel, G.phase2_rel, th1 + th2)}
for SIGN in (1,):
L("== wheel sign", SIGN)
for st, (h, rel, rise, ang) in STATES.items():
parts = {"base": base, "standard": std, "shoulder": shoulder, "rack7": rack7(rise), "plates": plates(h), "bracket": bracket(h),
"collar": collar(h), "bolts": bolts(h), "plunger": plunger(h, rel), "wheel": wheel_at(G.X_AXLE, G.AXLE_UP - h, SIGN * ang),
"axle+handle": axle_handle(h, -SIGN * ang if False else SIGN * ang), "bottle": bottle}
ks = list(parts); hits = []
for i in range(len(ks)):
for j in range(i + 1, len(ks)):
a, b = ks[i], ks[j]
if {a, b} in ({"axle+handle", "wheel"}, {"axle+handle", "plates"}, {"bolts", "plates"}, {"bolts", "bracket"}, {"collar", "bracket"}):
continue # intended fits (axle in its holes, bolts, collar in its holder)
v = parts[a].common(parts[b]).Volume
if v > 0.01: hits.append(f"{a}x{b}:{v:.2f}")
L(st, hits)
tot = th1 + th2
for a in range(0, int(tot) + 1, 8):
h = min(a, th1) / th1 * G.phase1
hp = axle_handle(h, a)
hh = [k for k, sh in (("standard", std), ("base", base), ("bottle", bottle), ("bracket", bracket(h)), ("plates", plates(h))) if (hp.common(sh).Volume > 0.01 and k != "plates") or (k == "plates" and hp.common(sh).Volume > 60)]
if hh: L("handle sweep", a, hh)
L("handle start 240, end", 240 + round(tot))
if os.environ.get("NOSAVE") != "1":
import MeshPart
h, rel, rise, ang = STATES["rest"]
prints = {"corker-wheel": wheel_at(0, 0, 0).cut(Part.Face(Part.makePolygon([V(7.6*math.cos(math.radians(60*i)), -7.5, 7.6*math.sin(math.radians(60*i))) for i in range(7)])).extrude(V(0, 6.5, 0))), "corker-rack": rack7(0), "corker-plunger": rack(G.X_PLUNGER_ROOT, -1, G.TIP_UP + G.TIP_OUT, G.TIP_UP + G.TIP_OUT + 125, G.AXLE_UP, -7.5, 7.5, G.PLUNGER_T).cut(zcyl(G.X_BOTTLE, 0, 4.3, G.TIP_UP, G.TIP_UP + G.TIP_OUT + 30)).cut(Part.Face(Part.makePolygon([V(G.X_BOTTLE + 7.6*math.cos(math.radians(60*i)), 7.6*math.sin(math.radians(60*i)), G.TIP_UP + G.TIP_OUT + 12) for i in range(7)])).extrude(V(0, 0, 7))), "corker-plates": plates(0),
"corker-collar-holder": bracket(0), "corker-collar": collar(0), "corker-shoulder": shoulder}
prints["corker-handle"] = axle_handle(0, 0).cut(ycyl(G.X_AXLE, G.AXLE_UP, 4.0, -40, 60)).translate(V(-G.X_AXLE, -38, -G.AXLE_UP)).cut(ycyl(0, 0, 4.3, -5, 15))
for k, v in prints.items():
L(k, "valid", v.isValid(), "solids", len(v.Solids), "vol cm3", round(v.Volume / 1000, 1))
MeshPart.meshFromShape(Shape=v, LinearDeflection=0.05, AngularDeflection=0.2).write(OUT + k + ".stl")
import FreeCADGui as Gui
d = App.newDocument("h")
wood, petg, steel, glass = (0.72, 0.55, 0.36), (0.20, 0.45, 0.70), (0.70, 0.71, 0.74), (0.25, 0.45, 0.30)
cols = {"base": wood, "standard": wood, "shoulder": petg, "rack7": petg, "plates": petg, "bracket": petg, "collar": petg,
"bolts": steel, "plunger": petg, "wheel": petg, "axle+handle": petg, "bottle": glass}
st = {"rest": (0, 0, 0, 0)}["rest"]
parts = {"base": base, "standard": std, "shoulder": shoulder, "rack7": rack7(0), "plates": plates(0), "bracket": bracket(0), "collar": collar(0),
"bolts": bolts(0), "plunger": plunger(0, 0), "wheel": wheel_at(G.X_AXLE, G.AXLE_UP, 0), "axle+handle": axle_handle(0, 0), "bottle": bottle}
for n, sh in parts.items():
o = d.addObject("Part::Feature", n.replace("+", "_")); o.Shape = sh; d.recompute()
Gui.ActiveDocument.getObject(n.replace("+", "_")).ShapeColor = cols[n]
v = Gui.ActiveDocument.ActiveView
v.setCameraType("Orthographic"); v.setViewDirection((-0.55, -0.85, -0.25)); v.fitAll(); Gui.updateGui()
v.saveImage(OUT + "hero.png", 1200, 1600, "White"); L("hero saved")
except Exception:
import traceback; L(traceback.format_exc())
LOG.close(); os._exit(0)