20 lines
1.2 KiB
Plaintext
20 lines
1.2 KiB
Plaintext
from pathlib import Path
|
|
import os,json,traceback
|
|
import FreeCAD as A, Part, Mesh
|
|
O=Path(r'C:\projects\wheel\models\fan120_integer_v2')
|
|
try:
|
|
d=A.openDocument(str(O/'Fan120Mount.FCStd'));d.recompute()
|
|
shape=d.getObject('FanMount').Shape
|
|
step=Part.read(str(O/'Fan120Mount.step'))
|
|
assert shape.isValid() and step.isValid() and len(shape.Solids)==len(step.Solids)==1
|
|
difference=[shape.cut(step).Volume,step.cut(shape).Volume]
|
|
(O/'verify_difference.json').write_text(json.dumps({'difference':difference,'volumes':[shape.Volume,step.Volume], 'shape_bounds':str(shape.BoundBox), 'step_bounds':str(step.BoundBox)},indent=2),encoding='utf8')
|
|
assert max(difference)<1e-4
|
|
mesh=Mesh.Mesh(str(O/'Fan120Mount.stl'));assert mesh.isSolid() and abs(mesh.BoundBox.ZMin)<1e-3
|
|
data=json.loads((O/'validation.json').read_text(encoding='utf8'))
|
|
data.update({'fcstd_reopened':True,'step_reopened':True,'step_fcstd_mutual_difference_mm3':[shape.cut(step).Volume,step.cut(shape).Volume]})
|
|
(O/'validation.json').write_text(json.dumps(data,indent=2),encoding='utf8')
|
|
A.closeDocument(d.Name);(O/'VERIFIED.txt').write_text('ok',encoding='utf8');os._exit(0)
|
|
except Exception:
|
|
(O/'VERIFY_ERROR.txt').write_text(traceback.format_exc(),encoding='utf8');os._exit(1)
|