Compare commits
4 Commits
d1fd830766
...
6470010da6
Author | SHA1 | Date |
---|---|---|
Leni Aniva | 6470010da6 | |
Leni Aniva | 5ab611666e | |
Leni Aniva | a6685e6779 | |
Leni Aniva | 418e6517a0 |
12
nhf/build.py
12
nhf/build.py
|
@ -90,7 +90,7 @@ class Target:
|
||||||
x = (
|
x = (
|
||||||
Cq.Workplane()
|
Cq.Workplane()
|
||||||
.add(x._faces)
|
.add(x._faces)
|
||||||
.add(x._wires)
|
.add(x.wires)
|
||||||
.add(x._edges)
|
.add(x._edges)
|
||||||
)
|
)
|
||||||
assert isinstance(x, Cq.Workplane)
|
assert isinstance(x, Cq.Workplane)
|
||||||
|
@ -214,7 +214,7 @@ class Submodel:
|
||||||
def write_to(self, obj, path: str):
|
def write_to(self, obj, path: str):
|
||||||
x = self._method(obj)
|
x = self._method(obj)
|
||||||
assert isinstance(x, Model), f"Unexpected type: {type(x)}"
|
assert isinstance(x, Model), f"Unexpected type: {type(x)}"
|
||||||
x.build_all(path)
|
x.build_all(path, prefix=False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def methods(cls, subject):
|
def methods(cls, subject):
|
||||||
|
@ -271,11 +271,17 @@ class Model:
|
||||||
total += 1
|
total += 1
|
||||||
return total
|
return total
|
||||||
|
|
||||||
def build_all(self, output_dir: Union[Path, str] = "build", verbose=1):
|
def build_all(
|
||||||
|
self,
|
||||||
|
output_dir: Union[Path, str] = "build",
|
||||||
|
prefix: bool = True,
|
||||||
|
verbose=1):
|
||||||
"""
|
"""
|
||||||
Build all targets in this model and write the results to file
|
Build all targets in this model and write the results to file
|
||||||
"""
|
"""
|
||||||
output_dir = Path(output_dir)
|
output_dir = Path(output_dir)
|
||||||
|
if prefix:
|
||||||
|
output_dir = output_dir / self.name
|
||||||
targets = Target.methods(self)
|
targets = Target.methods(self)
|
||||||
for t in targets.values():
|
for t in targets.values():
|
||||||
file_name = t.file_name
|
file_name = t.file_name
|
||||||
|
|
|
@ -14,7 +14,7 @@ class LightPanel(Model):
|
||||||
width: float = 200.0
|
width: float = 200.0
|
||||||
|
|
||||||
grid_height: float = 30.0
|
grid_height: float = 30.0
|
||||||
grid_top_height: float = 10.0
|
grid_top_height: float = 5.0
|
||||||
# Distance from grid to edge
|
# Distance from grid to edge
|
||||||
grid_margin: float = 20.0
|
grid_margin: float = 20.0
|
||||||
# Number of holes in each row of the grid
|
# Number of holes in each row of the grid
|
||||||
|
@ -23,7 +23,7 @@ class LightPanel(Model):
|
||||||
grid_hole_width: float = 15.0
|
grid_hole_width: float = 15.0
|
||||||
|
|
||||||
base_thickness: float = 25.4/16
|
base_thickness: float = 25.4/16
|
||||||
grid_thickness: float = 25.4/8
|
grid_thickness: float = 25.4/4
|
||||||
base_material: Material = Material.WOOD_BIRCH
|
base_material: Material = Material.WOOD_BIRCH
|
||||||
grid_material: Material = Material.ACRYLIC_TRANSPARENT
|
grid_material: Material = Material.ACRYLIC_TRANSPARENT
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class LightPanel(Model):
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
assert self.grid_holes >= 2
|
assert self.grid_holes >= 2
|
||||||
super().__init__(name="crown")
|
super().__init__(name="light-panel")
|
||||||
|
|
||||||
@target(name="grid", kind=TargetKind.DXF)
|
@target(name="grid", kind=TargetKind.DXF)
|
||||||
def grid_profile(self):
|
def grid_profile(self):
|
||||||
|
@ -68,9 +68,11 @@ class LightPanel(Model):
|
||||||
|
|
||||||
@submodel(name="base")
|
@submodel(name="base")
|
||||||
def base(self) -> MountingBox:
|
def base(self) -> MountingBox:
|
||||||
|
xshift = self.length / 2 - self.controller.length - self.grid_margin / 2
|
||||||
|
yshift = self.grid_margin / 2
|
||||||
holes = [
|
holes = [
|
||||||
Hole(
|
Hole(
|
||||||
x=x, y=y,
|
x=x + xshift, y=y + yshift,
|
||||||
diam=self.controller.hole_diam,
|
diam=self.controller.hole_diam,
|
||||||
tag=f"controller_conn{i}",
|
tag=f"controller_conn{i}",
|
||||||
)
|
)
|
||||||
|
@ -96,9 +98,9 @@ class LightPanel(Model):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Grid thickness t is fixed, so the spacing of the grid satisfies
|
# Grid thickness t is fixed, so the spacing of the grid satisfies
|
||||||
# margin + t + (n-1) * (t + spacing) + margin = width
|
# margin + t + (n-1) * spacing + margin = width
|
||||||
spacing = (self.width - 2 * self.grid_margin - self.grid_thickness) / (self.grid_layers - 1) - self.grid_thickness
|
spacing = (self.width - 2 * self.grid_margin - self.grid_thickness) / (self.grid_layers - 1)
|
||||||
shift = self.grid_margin + self.grid_thickness * 2
|
shift = self.grid_margin + self.grid_thickness / 2
|
||||||
for i in range(self.grid_layers):
|
for i in range(self.grid_layers):
|
||||||
assembly = assembly.addS(
|
assembly = assembly.addS(
|
||||||
self.grid(),
|
self.grid(),
|
||||||
|
|
Loading…
Reference in New Issue