30 lines
1.7 KiB
Plaintext
30 lines
1.7 KiB
Plaintext
from pathlib import Path
|
|
import FreeCAD as A, Part, json, os, traceback
|
|
root=Path(r'C:\projects\wheel\models')
|
|
out=root/'kfl001_plate_v3_alt'
|
|
try:
|
|
v1=Part.read(str(root/'kfl001_plate_v1'/'KFL001_plate_V1.step'))
|
|
v3=Part.read(str(out/'KFL001_plate_V3.step'))
|
|
added=v3.cut(v1).Volume
|
|
assert abs(added)<1e-5,added
|
|
d=A.openDocument(str(out/'KFL001_plate_V3.FCStd'));d.recompute()
|
|
f=d.getObject('OutlineCornerFillets');c=d.getObject('PerimeterChamfer')
|
|
assert abs(float(f.Radius)-3)<1e-6 and abs(float(c.Size)-1)<1e-6
|
|
slotcyls=[(round(x.Surface.Center.x,5),round(x.Surface.Center.y,5),round(x.Surface.Radius,5)) for x in v3.Faces if hasattr(x.Surface,'Radius') and hasattr(x.Surface,'Center') and abs(x.Surface.Radius-2.75)<1e-6 and x.BoundBox.ZLength>7.99]
|
|
for x in (-25.5,-21.5,21.5,25.5):assert (x,9.0,2.75) in slotcyls,(x,slotcyls)
|
|
# Verify perimeter 45-degree bevel by sampling a point along the long bottom straight edge.
|
|
# At x=0 the bottom face z=0 starts at y=1; at mid-plane it starts at y=0.
|
|
# Extract planar slice footprints from solids intersected with thin boxes.
|
|
def y_min(z):
|
|
line=Part.makeLine(A.Vector(0,-2,z),A.Vector(0,5,z))
|
|
common=v3.common(line)
|
|
return common.BoundBox.YMin
|
|
yb=y_min(0); ym=y_min(4)
|
|
assert abs(yb-1)<1e-6 and abs(ym)<1e-6,(yb,ym)
|
|
p={'v3_added_over_v1_mm3':added,'native_fillet_radius_mm':float(f.Radius),'native_chamfer_mm':float(c.Size),'step_bottom_edge_at_z0_y':yb,'step_bottom_edge_at_z4_y':ym,'slot_cylinders_verified':True}
|
|
(out/'revision_validation.json').write_text(json.dumps(p,indent=2),encoding='utf8')
|
|
A.closeDocument(d.Name)
|
|
except Exception:
|
|
(out/'VERIFY_ERROR.txt').write_text(traceback.format_exc(),encoding='utf8')
|
|
os._exit(0)
|