Files
wheel/scripts/build_kfl_150_switch60.py

31 lines
2.1 KiB
Python

from pathlib import Path
root = Path(r'C:\projects\wheel')
source = root / 'scripts' / 'build_kfl_125_switch60.py'
text = source.read_text(encoding='utf8')
replacements = [
("shaftlen=125; O=R/'models'/'kfl_125_switch60_concept'", "shaftlen=150; O=R/'models'/'kfl_150_switch60_concept'"),
("-108 if n=='Shaft' else -118", "-108 if n=='Shaft' else -130.5"),
("V(-2.05,4,-125)", "V(-2.05,4,-137.5)"),
("KFL125_Switch60_Schematic", "KFL150_Switch60_Schematic"),
("Part.makeBox(20,20,200,V(x-10,-75,-180))", "Part.makeBox(20,20,225,V(x-10,-75,-205))"),
("enumerate([-84,-162])", "enumerate([-84,-187])"),
("[(-84,-88.5,1),(-162,-165,-1)]", "[(-84,-88.5,1),(-187,-190,-1)]"),
("cy(15,20,0,0,-188).cut(cy(6.2,20.02,0,0,-188.01))", "cy(15,20,0,0,-213).cut(cy(6.2,20.02,0,0,-213.01))"),
("cy(28.5,4,0,0,-192).cut(cy(6.2,4.02,0,0,-192.01))", "cy(28.5,4,0,0,-217).cut(cy(6.2,4.02,0,0,-217.01))"),
("24*math.sin(a),-192.01", "24*math.sin(a),-217.01"),
("wheel70.translate(V(0,0,-192))", "wheel70.translate(V(0,0,-217))"),
("Part.makeBox(110,80,60,V(-55,-40,-149.5)).cut(cy(23.5,60.02,0,0,-149.51))", "Part.makeBox(110,80,60,V(-55,-40,-162)).cut(cy(23.5,60.02,0,0,-162.01))"),
("24*math.sin(a),-200)", "24*math.sin(a),-225)"),
("min(-168,-56.5)-max(-188,z_end)", "min(-193,-56.5)-max(-213,z_end)"),
("min(-188,-56.5)-max(-192,z_end)", "min(-213,-56.5)-max(-217,z_end)"),
("Wheel hub z=-188..-168, front plate z=-192..-188", "Wheel hub z=-213..-193, front plate z=-217..-213"),
("Rear bearing retained; front bearing shifted 12mm to wheel; switch 60mm with 1mm nominal gap on each side, cam shifted 6mm;", "Rear bearing retained; front bearing shifted 25mm forward from the 125mm layout; switch 60mm with 13.5mm nominal gap on each side, cam shifted 12.5mm;"),
]
for old, new in replacements:
count = text.count(old)
if count != 1:
raise RuntimeError('Expected one occurrence, got %d: %r' % (count, old))
text = text.replace(old, new)
exec(compile(text, str(source), 'exec'), {'__name__': '__main__', '__file__': str(source)})