建立方向盘项目初始版本
This commit is contained in:
23
scripts/verify_fan_direct145.FCMacro
Normal file
23
scripts/verify_fan_direct145.FCMacro
Normal file
@@ -0,0 +1,23 @@
|
||||
from pathlib import Path
|
||||
import os, json, traceback
|
||||
import FreeCAD as A, Part
|
||||
root=Path(r'C:\projects\wheel\models\fan_direct_145')
|
||||
try:
|
||||
d=A.openDocument(str(root/'Assembly.FCStd'));d.recompute()
|
||||
fan=d.getObject('DirectFan');v=[]
|
||||
screws=[d.getObject('FanBolt0'),d.getObject('FanBolt1')]
|
||||
for s in screws:
|
||||
for o in d.Objects:
|
||||
if o==s or o in screws or not hasattr(o,'Shape') or o.Shape.isNull() or not o.ViewObject.Visibility:continue
|
||||
if s.Shape.BoundBox.intersect(o.Shape.BoundBox):
|
||||
n=s.Shape.common(o.Shape).Volume
|
||||
if n>1e-4:v.append([s.Name,o.Name,n])
|
||||
distances={}
|
||||
for n in ('MotorBaseCorner0','MotorBaseCorner1','NewRail0','NewRail1','OpenPillarBracket','PCB','Chip','Holder','Magnet'):
|
||||
o=d.getObject(n)
|
||||
if o and hasattr(o,'Shape') and not o.Shape.isNull():distances[n]=fan.Shape.distToShape(o.Shape)[0]
|
||||
result={'fastener_hits':v,'fan_distances_mm':distances,'warning':'Screws only modeled above rail surface; fan blades, electric hub, T slot nuts and wiring are not modeled.'}
|
||||
(root/'verify_screws.json').write_text(json.dumps(result,indent=2),encoding='utf8')
|
||||
A.closeDocument(d.Name);os._exit(0)
|
||||
except Exception:
|
||||
(root/'verify_screws_error.txt').write_text(traceback.format_exc(),encoding='utf8');os._exit(1)
|
||||
Reference in New Issue
Block a user