建立方向盘项目初始版本

This commit is contained in:
2026-10-29 22:04:55 +08:00
commit 9962cbfbce
834 changed files with 1519203 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
"""Rebuild a distinct 70 mm adapter with 24 plain M4 tap-drill holes.
Run through rebuild_70_m4_drill_plain.FCMacro in FreeCAD. The existing source
builder is used to retain its native editable PCD features and source contour.
"""
import os
from pathlib import Path
import FreeCAD as App
import FreeCADGui as Gui
import Part, Import
root = Path(r'C:\projects\wheel')
out = root / 'models' / '70_m4_drill_plain'
out.mkdir(parents=True, exist_ok=True)
src = root / 'scripts' / 'build_70.py'
code = src.read_text(encoding='utf-8')
old_target = "target = os.path.join(root, 'models', '\\u0037\\u0030\\u8f6c\\u63a5\\u677f_\\u53c2\\u6570\\u5316.FCStd')"
new_target = "target = os.path.join(root, 'models', '70_m4_drill_plain', '70_M4_drill_plain.FCStd')"
assert old_target in code
code = code.replace(old_target, new_target)
code = code.replace("('HoleDiameter', '4.234 mm', 'Through hole diameter (all 24 holes)')", "('HoleDiameter', '3.3 mm', 'M4x0.7 tap drill, all 24 holes')")
code = code.replace(" ('CountersinkDiameter', '6.8 mm', 'Countersink at bottom face'),\n", '')
begin = code.index("sheet.set('A16', 'CountersinkDepth')")
end = code.index("sheet.set('A17', 'OuterChamfer')", begin)
code = code[:begin] + code[end:]
begin = code.index('cones = []')
end = code.index('prior = set(doc.Objects)', begin)
code = code[:begin] + "final = current\nfinal.Label = '70 adapter - 24 plain M4 tap-drill holes'\ndoc.recompute()\nassert final.Shape.isValid() and len(final.Shape.Solids)==1\n\n" + code[end:]
os.chdir(str(root))
ns = {'__name__': '__main__', '__file__': str(src)}
exec(compile(code, str(src), 'exec'), ns)
doc, final = ns['doc'], ns['final']
assert abs(doc.getObject('Parameters').get('B4').Value-3.3) < 1e-8
Import.export([final], str(out / '70_M4_drill_plain.step'))
Gui.activeDocument().activeView().viewAxonometric()
Gui.activeDocument().activeView().fitAll()
Gui.activeDocument().activeView().saveImage(str(out / '70_M4_drill_plain.png'), 1600, 1200, 'White')
doc.save()