"""PP-270 frozen plate. Run: python plate-cadquery.py LENGTH OUTPUT.stl"""
import sys
import cadquery as cq

length = float(sys.argv[1])
output = sys.argv[2]
width = 24.0
thickness = 5.0
edge_to_center = 6.0
diameter = 4.0
x = length / 2 - edge_to_center
y = width / 2 - edge_to_center
centers = [(sx * x, sy * y) for sx in (-1, 1) for sy in (-1, 1)]
plate = cq.Workplane("XY").box(length, width, thickness, centered=(True, True, False))
plate = plate.faces(">Z").workplane().pushPoints(centers).hole(diameter)
plate.val().exportStl(output)
print(f"CadQuery {cq.__version__}; source length={length}; solid volume={plate.val().Volume():.9f}; export={output}")
