Compare commits

...

16 Commits

Author SHA1 Message Date
Leni Aniva 6b0b604ae1
Merge branch 'main' into touhou/shiki-eiki 2025-02-12 22:31:03 -08:00
Leni Aniva 9ff3e72474 Merge pull request 'tool: Light panel' (#9) from tool/lighting into main
Reviewed-on: #9
2025-01-28 17:56:20 -08:00
Leni Aniva 9d78bf604a
feat: Add tripod attachment point 2025-01-28 17:15:38 -08:00
Leni Aniva 596311f326
feat: Improve spacing 2025-01-23 13:52:37 -08:00
Leni Aniva 6384d326c1 Merge pull request 'feat: Add model name prefix to build path' (#10) from lib/build into main
Reviewed-on: #10
2025-01-20 21:47:32 -08:00
Leni Aniva 6470010da6
fix: Model name 2024-12-07 13:47:32 -08:00
Leni Aniva 5ab611666e
Merge branch 'lib/build' into tool/lighting 2024-12-07 13:47:06 -08:00
Leni Aniva a6685e6779
feat: Add model name prefix to build path 2024-12-07 13:46:23 -08:00
Leni Aniva 418e6517a0
fix: Sketch object attribute 2024-12-07 13:44:35 -08:00
Leni Aniva 9563501327 Merge pull request 'feat: Add cq-editor as dev dependency' (#8) from chore/version into main
Reviewed-on: #8
2024-12-07 13:38:04 -08:00
Leni Aniva d1fd830766
feat: Light panel assembly 2024-12-07 12:09:41 -08:00
Leni Aniva 3884d75f1c
chore: Add build function 2024-12-06 16:43:12 -08:00
Leni Aniva ca437c3855
feat: Light panel layer 2024-12-06 16:40:07 -08:00
Leni Aniva 8e4553311b
doc: Instructions for using cq-editor 2024-12-06 12:42:26 -08:00
Leni Aniva 016b717b41
feat: Add cq-editor in dev dependencies 2024-12-06 12:40:57 -08:00
Leni Aniva eace8745f3
chore: Update cadquery 2024-12-06 12:27:26 -08:00
6 changed files with 3656 additions and 358 deletions

View File

@ -1,6 +1,7 @@
# Cosplay # Cosplay
This is the design repository for NorCal Hakkero Factory No. 1. This is the design repository for NorCal Hakkero Factory No. 1, where we use
parametric CAD to make cosplay props.
## Development ## Development
@ -15,6 +16,12 @@ and this should succeed
python3 -c "import nhf" python3 -c "import nhf"
``` ```
To visualize an object, create a file `visualize.py`, and run `cq-editor`:
``` sh
python3 -m cq_editor visualize.py
```
## Testing ## Testing
Run all tests with Run all tests with

View File

@ -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)

0
nhf/tool/__init__.py Normal file
View File

146
nhf/tool/light_panel.py Normal file
View File

@ -0,0 +1,146 @@
from dataclasses import dataclass
import cadquery as Cq
from nhf import Material, Role
from nhf.build import Model, target, assembly, TargetKind, submodel
from nhf.parts.box import MountingBox, Hole
from nhf.parts.electronics import ArduinoUnoR3
import nhf.utils
@dataclass
class LightPanel(Model):
# Dimensions of the base panel
length: float = 300.0
width: float = 200.0
attach_height: float = 20.0
attach_diam: float = 8.0
attach_depth: float = 12.7
grid_height: float = 20.0
grid_top_height: float = 5.0
# Distance from grid to edge
grid_margin: float = 20.0
# Number of holes in each row of the grid
grid_holes: int = 9
grid_layers: int = 6
grid_hole_width: float = 15.0
base_thickness: float = 25.4/16
grid_thickness: float = 25.4/4
base_material: Material = Material.WOOD_BIRCH
grid_material: Material = Material.ACRYLIC_TRANSPARENT
controller: ArduinoUnoR3 = ArduinoUnoR3()
def __post_init__(self):
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
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 `margin`
# 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')
)
def grid(self) -> Cq.Workplane:
return (
Cq.Workplane('XY')
.placeSketch(self.grid_profile())
.extrude(self.grid_thickness)
)
@submodel(name="base")
def base(self) -> MountingBox:
xshift = self.length / 2 - self.controller.length - self.grid_margin / 2
yshift = self.grid_margin / 2
holes = [
Hole(
x=x + xshift, y=y + yshift,
diam=self.controller.hole_diam,
tag=f"controller_conn{i}",
)
for i, (x, y) in enumerate(self.controller.holes)
]
return MountingBox(
holes=holes,
hole_diam=self.controller.hole_diam,
length=self.length,
width=self.width,
centred=(True, False),
thickness=self.base_thickness,
)
@target(name="attachment")
def attachment(self) -> Cq.Workplane:
l = self.length / 2
w = self.width / 2
return (
Cq.Workplane('XY')
.box(
l, w, self.attach_height,
centered=(True, True, False),
)
.faces(">Z")
.hole(self.attach_diam, self.attach_depth)
)
def assembly(self) -> Cq.Assembly:
assembly = (
Cq.Assembly()
.addS(
self.base().generate(),
name="base",
role=Role.STRUCTURE,
material=self.base_material,
)
)
# Grid thickness t is fixed, so the spacing of the grid satisfies
# margin + t + (n-1) * spacing + margin = width
spacing = self.grid_spacing_y
shift = self.grid_margin + self.grid_thickness / 2
for i in range(self.grid_layers):
assembly = assembly.addS(
self.grid(),
name=f"grid_{i}",
role=Role.STRUCTURE,
material=self.grid_material,
loc=Cq.Location(0, spacing * i + shift, self.base_thickness, 90, 0, 0),
)
return assembly
if __name__ == '__main__':
import sys
p = LightPanel()
print(p.grid_spacing_y)
if len(sys.argv) == 1:
p.build_all()
sys.exit(0)

3845
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -8,13 +8,21 @@ readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.10" python = "^3.10"
cadquery = {git = "https://github.com/CadQuery/cadquery.git"} cadquery = {git = "https://github.com/CadQuery/cadquery.git"}
build123d = "^0.5.0" #build123d = "^0.5.0"
numpy = "^1.26.4" numpy = ">=2,<3"
colorama = "^0.4.6" colorama = "^0.4.6"
# cadquery dependency # cadquery dependency
multimethod = "^1.12" multimethod = "^1.12"
scipy = "^1.14.0" scipy = "^1.14.0"
typish = "^1.9.3"
[tool.poetry.group.dev.dependencies]
cq-editor = {git = "https://github.com/CadQuery/CQ-editor.git"}
pyqt5 = "^5.15.11"
logbook = "^1.8.0"
spyder = "^5"
pyqtgraph = "^0.13.7"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]