feat: Light panel layer
This commit is contained in:
parent
8e4553311b
commit
ca437c3855
|
@ -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')
|
||||
)
|
Loading…
Reference in New Issue