# Locking pliers after Petersen, US 1,489,458 (1924): parts as side profiles (mm), extruded through their thickness.
# Run in FreeCAD: freecadcmd pliers.py (env OUT = folder for STEP/JSON; NOSAVE=1 for the clash check only)
# Origin = jaw pivot pin (Petersen's pin 8). x runs along the handle toward the adjusting screw, y up (handle web on top),
# z across the tool. Every size here is OURS: the patent gives the parts and how they work, not their sizes.
import os, sys, json, math
from shapely.geometry import Polygon, Point, LineString
from shapely.ops import unary_union
from shapely import affinity
OUT = os.environ.get("OUT", ".")
O = (0.0, 0.0)
J0 = (8.0, -26.0) # moving jaw 10 / lever section 11 pivot, jaws shut
L11, L12 = 40.0, 75.0 # lever section 11 (J to P), link 12 (P to screw point S)
SY = -3.0 # screw axis height
PIN = 3.0 # pin radius (6 mm pins)
def circ(c, r): return Point(c).buffer(r, 64)
def bar(a, b, w): return LineString([a, b]).buffer(w / 2, 64)
# handle A: two side walls (2 mm sheet) + web on top, inside gap 10 mm
wall = unary_union([
Polygon([(-62, 18), (-14, 18), (-6, 12), (162, 12), (162, -10), (85, -10), (80, -7), (40, -7), (35, -10), (14, -10),
(-14, -4), (-60, -1)]), # relief 35-85 mm: room for the link pin at the widest setting
circ(O, 16), # Petersen's enlarged portion 7, edge concentric with pin 8
]).difference(unary_union([circ(O, PIN), circ((-44, 12), 2.5), circ((-22, 14), 2.5), circ((45, 0), 2.0),
circ((148, 6), 2.5), circ((157, 6), 2.5), circ((98, 7.5), 2.5), circ((108, 7.5), 2.5),
Polygon([(-6, 12), (170, 12), (170, 30), (-6, 30)])])) # no wall above the web line where the web is
# OURS, not Petersen's bent channel: two flat side plates riveted around 10 mm spacers (fixed jaw, nut block, this one)
spacer = Polygon([(94, 3), (112, 3), (112, 12), (94, 12)]).difference(unary_union([circ((98, 7.5), 2.5), circ((108, 7.5), 2.5)]))
# fixed jaw 6: 10 mm bar between the walls, face at 22.5 degrees to the handle (Petersen: "approximately 22 1/2 degrees")
t = math.tan(math.radians(22.5))
fixed = Polygon([(-58, -3.0), (-26, -3.0 + 32 * t), (-14, -3.0 + 32 * t), (-14, 18), (-60, 18), (-61, 4)]
).difference(unary_union([circ((-44, 12), 2.5), circ((-22, 14), 2.5)]))
# moving jaw 10: 10 mm bar, hub round pin 8, tail down to J; spring hole near the hub's rear edge (pulls it open)
moving = unary_union([
Polygon([(-58, -3.6), (-24, -1.0), (-6, -1.0), (-6, -14), (-30, -15), (-56, -9)]),
circ(O, 11), bar(O, J0, 14), circ(J0, 7),
]).difference(unary_union([circ(O, PIN), circ(J0, PIN), circ((4, -12), 1.6)]))
# link 12: 6 mm flat bar 12 wide, hole at P, seat for the screw point at S
def link_profile(P, S):
u = ((S[0] - P[0]) / L12, (S[1] - P[1]) / L12)
back = (P[0] - 7 * u[0], P[1] - 7 * u[1])
return bar(back, S, 12).difference(circ(P, PIN))
# lever 11 + operating handle 14: channel, side walls 2 mm, grip continues 110 mm past P, bent 12 degrees down
GRIP_RIVETS = []
def lever_profiles(J, P):
a = math.atan2(P[1] - J[1], P[0] - J[0]) - math.radians(12)
G = (P[0] + 110 * math.cos(a), P[1] + 110 * math.sin(a))
side = unary_union([bar(J, P, 18), bar(P, G, 18), circ(J, 9), circ(P, 9)]).difference(
unary_union([circ(J, PIN), circ(P, PIN), circ(stop_pin(J, P), 2.0)]))
# grip spacer (OURS): 14 mm thick block between the plates near the grip end, two rivets
e = (math.cos(a), math.sin(a)); A = (G[0] - 32 * e[0], G[1] - 32 * e[1]); B = (G[0] - 6 * e[0], G[1] - 6 * e[1])
GRIP_RIVETS[:] = [(A[0] + 6 * e[0], A[1] + 6 * e[1]), (B[0] - 6 * e[0], B[1] - 6 * e[1])]
webp = bar(A, B, 10).difference(unary_union([circ((A[0] + 6 * e[0], A[1] + 6 * e[1]), 2.5), circ((B[0] - 6 * e[0], B[1] - 6 * e[1]), 2.5)]))
side = side.difference(unary_union([circ((A[0] + 6 * e[0], A[1] + 6 * e[1]), 2.5), circ((B[0] - 6 * e[0], B[1] - 6 * e[1]), 2.5)]))
return side, webp
STOP_R, STOP_EPS = 20.0, math.radians(2.5) # stop pin 20 mm past P along the link; toggle stops 2.5 deg past straight
def stop_pin(J, P):
"""Centre of the 4 mm stop pin, under the link (the side the link swings to once the lever passes centre)."""
u = ((P[0] - J[0]) / L11, (P[1] - J[1]) / L11); n = (u[1], -u[0]) # n points to the link's lower side
c = STOP_R * math.tan(STOP_EPS) # clearance at straight
d = 6.0 + c + 2.0 # half link width + clearance + pin radius
return (P[0] + STOP_R * u[0] + d * n[0], P[1] + STOP_R * u[1] + d * n[1])
block = Polygon([(144, -10), (162, -10), (162, 12), (144, 12)]).difference(
unary_union([circ((148, 6), 2.5), circ((157, 6), 2.5)])) # tapped M8 along x at y = -3
def rot(p, a):
c, s = math.cos(a), math.sin(a); return (c * p[0] - s * p[1], s * p[0] + c * p[1])
def solve_P(J, S, up=True):
d = math.dist(J, S); a = (L11**2 - L12**2 + d * d) / (2 * d); h = math.sqrt(max(L11**2 - a * a, 0.0))
ex = ((S[0] - J[0]) / d, (S[1] - J[1]) / d); m = (J[0] + a * ex[0], J[1] + a * ex[1])
s = 1 if up else -1
return (m[0] - s * h * ex[1], m[1] + s * h * ex[0])
def lock_angle(xs):
S = (xs, SY); lo, hi = 0.0, 1.2
for _ in range(80): # J-S distance falls as the jaw opens
mid = (lo + hi) / 2
if math.dist(rot(J0, mid), S) > L11 + L12: lo = mid
else: hi = mid
return (lo + hi) / 2
POSES = {"shut_locked": (121.3, None), "wide_locked": (136.0, None), "open": (128.5, math.radians(40))}
if os.environ.get("SWEEP"): POSES.update({f"lock_{x}": (float(x), None) for x in (124, 127, 130, 133)})
def pose(name):
xs, ang = POSES[name]; S = (xs, SY)
if ang is None:
ang = lock_angle(xs); J = rot(J0, ang); P = solve_P(J, S, up=True)
else:
J = rot(J0, ang); P = solve_P(J, S, up=False)
side, webp = lever_profiles(J, P)
return {"ang": ang, "J": J, "P": P, "S": S,
"parts": [("wall_L", wall, 5, 7), ("wall_R", wall, -7, -5), ("spacer", spacer, -5, 5), ("fixed_jaw", fixed, -5, 5),
("moving_jaw", affinity.rotate(moving, ang, origin=O, use_radians=True), -5, 5),
("link", link_profile(P, S), -3, 3), ("lever_L", side, 7, 9), ("lever_R", side, -9, -7),
("grip_spacer", webp, -7, 7), ("nut_block", block, -5, 5)]}
FLAT = {"handle_wall_x2": wall, "fixed_jaw": fixed, "moving_jaw": moving, "nut_block": block,
"link": link_profile((0.0, 0.0), (L12, 0.0)), "middle_spacer": spacer}
_lev = lever_profiles((0.0, 0.0), (L11, 0.0))
FLAT["lever_plate_x2"] = _lev[0]; FLAT["grip_spacer"] = _lev[1]
if not os.environ.get("IMPORT_ONLY"):
import FreeCAD, Part
from FreeCAD import Vector as V
def solid(poly, z0, z1):
polys = list(poly.geoms) if poly.geom_type == "MultiPolygon" else [poly]
out = []
for pg in polys:
ring = lambda r: Part.makePolygon([V(x, y, z0) for x, y in list(r.coords)])
f = Part.Face([Part.Wire(ring(pg.exterior))] + [Part.Wire(ring(i)) for i in pg.interiors])
out.append(f.extrude(V(0, 0, z1 - z0)))
return out[0] if len(out) == 1 else Part.makeCompound(out)
may_touch = {frozenset(p) for p in [("fixed_jaw", "moving_jaw"), ("screw", "nut_block"), ("screw", "link"),
("pin_O", "moving_jaw"), ("pin_J", "moving_jaw"), ("pin_P", "link"), ("rivet0", "fixed_jaw"), ("rivet1", "fixed_jaw"),
("rivet2", "nut_block"), ("rivet3", "nut_block"), ("rivet4", "spacer"), ("rivet5", "spacer")]}
report = {}
for name in POSES:
ps = pose(name); sol = [(n, solid(pg, a, b)) for n, pg, a, b in ps["parts"]]
def pin(nm, c, r, z0, z1, head=0.0):
p = Part.makeCylinder(r, z1 - z0, V(c[0], c[1], z0))
if head: # peened rivet heads, 1.5 mm proud, radius 1.5 x pin
p = p.fuse(Part.makeCylinder(r * 1.5, 1.5, V(c[0], c[1], z1))).fuse(Part.makeCylinder(r * 1.5, 1.5, V(c[0], c[1], z0 - 1.5)))
sol.append((nm, p))
J, P, S = ps["J"], ps["P"], ps["S"]
pin("pin_O", O, PIN, -7, 7, 1); pin("pin_J", J, PIN, -9, 9, 1); pin("pin_P", P, PIN, -9, 9, 1)
pin("stop_pin", stop_pin(J, P), 2.0, -9, 9, 1); pin("spring_pin", (45, 0), 2.0, -7, 7, 1)
for i, c in enumerate([(-44, 12), (-22, 14), (148, 6), (157, 6), (98, 7.5), (108, 7.5)]): pin(f"rivet{i}", c, 2.5, -7, 7, 1)
scr = Part.makeCylinder(4.0, 190 - S[0], V(S[0], SY, 0), V(1, 0, 0)).fuse(Part.makeCylinder(7.0, 6, V(190, SY, 0), V(1, 0, 0)))
sol.append(("screw", scr))
hits = []
for i in range(len(sol)):
for k in range(i + 1, len(sol)):
(na, sa), (nb, sb) = sol[i], sol[k]
if not sa.BoundBox.intersect(sb.BoundBox): continue
v = sa.common(sb).Volume
if v > 0.01 and frozenset((na, nb)) not in may_touch: hits.append((na, nb, round(v, 2)))
tip_gap = math.dist(rot((-58, -3.6), ps["ang"]), (-58, -3.0))
over = None
print(f"{name}: jaw {math.degrees(ps['ang']):.1f} deg, tip gap {tip_gap:.1f} mm, P {ps['P'][0]:.1f},{ps['P'][1]:.1f}, clashes {hits}")
report[name] = {"jaw_deg": math.degrees(ps["ang"]), "tip_gap": tip_gap, "clashes": hits}
if not os.environ.get("NOSAVE"):
Part.makeCompound([s for _, s in sol]).exportStep(os.path.join(OUT, f"locking-pliers-{name}.step"))
json.dump({"report": report, "flat": {k: [list(v.exterior.coords)] + [list(i.coords) for i in v.interiors]
for k, v in FLAT.items()}}, open(os.path.join(OUT, "pliers.json"), "w"))
sys.stdout.flush(); os._exit(0)