from pathlib import Path import FreeCAD as A, Part, json, os, traceback p=Path(r'C:\projects\wheel\models\symmetric_corner_18_concept') try: d=A.openDocument(str(p/'新角码_对称参数模型.FCStd'));d.recompute();o=d.getObject('SymmetricCorner');s=o.Shape;assert s.isValid() and len(s.Solids)==1 q=Part.read(str(p/'新角码_对称参数模型.step'));assert q.isValid() and len(q.Solids)==1 a=s.cut(q).Volume;b=q.cut(s).Volume;assert a<1e-5 and b<1e-5 v=s.Volume;d.getObject('Parameters').set('B5','5.1 mm');d.recompute();vv=o.Shape.Volume;assert o.Shape.isValid() and abs(v-vv)>0.01 d.getObject('Parameters').set('B5','5 mm');d.recompute();assert abs(o.Shape.Volume-v)<1e-5 (p/'角码参数模型重开验证.json').write_text(json.dumps({'fcstd_reopened':True,'step_valid':True,'volume_differences':[a,b],'hole_5_to_5_1_parameter_recompute':True,'restored_without_save':True},ensure_ascii=False,indent=2),encoding='utf-8') A.closeDocument(d.Name);os._exit(0) except: (p/'角码重开验证错误.txt').write_text(traceback.format_exc(),encoding='utf-8');os._exit(1)