From ca437c385531cfb205ca06bf3a14d8a1ded2b826 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Fri, 6 Dec 2024 16:40:07 -0800 Subject: [PATCH] feat: Light panel layer --- nhf/tool/__init__.py | 0 nhf/tool/light_panel.py | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 nhf/tool/__init__.py create mode 100644 nhf/tool/light_panel.py diff --git a/nhf/tool/__init__.py b/nhf/tool/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nhf/tool/light_panel.py b/nhf/tool/light_panel.py new file mode 100644 index 0000000..81c2942 --- /dev/null +++ b/nhf/tool/light_panel.py @@ -0,0 +1,54 @@ +from dataclasses import dataclass +import cadquery as Cq +from nhf import Material, Role +from nhf.build import Model, target, assembly, TargetKind +import nhf.utils + +@dataclass +class LightPanel(Model): + + # Dimensions of the base panel + length: float = 300.0 + width: float = 200.0 + + grid_height: float = 30.0 + grid_top_height: float = 10.0 + # Distance from grid to edge + grid_margin: float = 20.0 + # Number of holes in each row of the grid + grid_holes: int = 5 + grid_layers: int = 10 + grid_hole_width: float = 10.0 + + base_thickness: float = 25.4/16 + grid_thickness: float = 25.4/8 + + def __post_init__(self): + assert self.grid_holes >= 2 + super().__init__(name="crown") + + @target(name="grid", kind=TargetKind.DXF) + def grid_profile(self): + w = self.length - self.grid_margin * 2 + h = self.grid_height + self.grid_top_height + + # The width of one hole (w0) satisfies + # n * w0 + (n+1) t = w + # where t is the thickness of the edge + n = self.grid_holes + w0 = self.grid_hole_width + t = (w - n * w0) / (n + 1) + # The spacing is such that the first and last holes are a distance `t` + # away from the edges, so it satisfies + # t + w0/2 + (n-1) * s + w0/2 + t = w + step = (w - t*2 - w0) / (n - 1) + return ( + Cq.Sketch() + .push([(0, h/2)]) + .rect(w, h) + .push([ + (i * step + t + w0/2 - w/2, self.grid_height/2) + for i in range(0, n) + ]) + .rect(w0, self.grid_height, mode='s') + )