from pathlib import Path import os, traceback import FreeCAD as A, Part R=Path(r'C:\projects\wheel');O=R/'models'/'switch_2020_concept' ok=False try: d=A.openDocument(str(O/'Assembly.FCStd'));d.recompute() names=['SwitchCross2020','SwitchAngleA','SwitchAngleB','SwitchCrossJoint0','SwitchCrossJoint1'] lines=[] for name in names: o=d.getObject(name);lines.append('%s valid=%s volume=%.6f'%(name,o.Shape.isValid(),o.Shape.Volume)) assert not o.Shape.isNull() and o.Shape.isValid() A.closeDocument(d.Name) s=Part.read(str(O/'Assembly.step')) assert not s.isNull() and s.isValid() lines.append('STEP valid=%s solids=%d'%(s.isValid(),len(s.Solids))) (O/'validation.txt').write_text('\n'.join(lines)+'\n',encoding='utf8');ok=True except Exception:(O/'VERIFY_ERROR.txt').write_text(traceback.format_exc(),encoding='utf8') finally:os._exit(0 if ok else 1)