From 596311f326805c3b723d79079927837d7ce29486 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Thu, 23 Jan 2025 13:52:37 -0800 Subject: [PATCH] feat: Improve spacing --- nhf/tool/light_panel.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nhf/tool/light_panel.py b/nhf/tool/light_panel.py index 44c7920..82d7e5f 100644 --- a/nhf/tool/light_panel.py +++ b/nhf/tool/light_panel.py @@ -13,7 +13,7 @@ class LightPanel(Model): length: float = 300.0 width: float = 200.0 - grid_height: float = 30.0 + grid_height: float = 20.0 grid_top_height: float = 5.0 # Distance from grid to edge grid_margin: float = 20.0 @@ -33,6 +33,10 @@ class LightPanel(Model): assert self.grid_holes >= 2 super().__init__(name="light-panel") + @property + def grid_spacing_y(self) -> float: + return (self.width - 2 * self.grid_margin - self.grid_thickness) / (self.grid_layers - 1) + @target(name="grid", kind=TargetKind.DXF) def grid_profile(self): w = self.length - self.grid_margin * 2 @@ -99,7 +103,7 @@ class LightPanel(Model): ) # Grid thickness t is fixed, so the spacing of the grid satisfies # margin + t + (n-1) * spacing + margin = width - spacing = (self.width - 2 * self.grid_margin - self.grid_thickness) / (self.grid_layers - 1) + spacing = self.grid_spacing_y shift = self.grid_margin + self.grid_thickness / 2 for i in range(self.grid_layers): assembly = assembly.addS( @@ -116,6 +120,8 @@ if __name__ == '__main__': import sys p = LightPanel() + print(p.grid_spacing_y) + if len(sys.argv) == 1: p.build_all() sys.exit(0)