-
Notifications
You must be signed in to change notification settings - Fork 139
/
customizable_box.py
55 lines (50 loc) · 1.41 KB
/
customizable_box.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from sdf import *
WIDTH = 12
HEIGHT = 6
DEPTH = 2
ROWS = 3
COLS = 5
WALL_THICKNESS = 0.25
WALL_RADIUS = 0.5
BOTTOM_RADIUS = 0.25
TOP_FILLET = 0.125
DIVIDER_THICKNESS = 0.2
ROW_DIVIDER_DEPTH = 1.75
COL_DIVIDER_DEPTH = 1.5
DIVIDER_FILLET = 0.1
LID_THICKNESS = 0.25
LID_DEPTH = 0.75
LID_RADIUS = 0.125
SAMPLES = 2 ** 24
def dividers():
col_spacing = WIDTH / COLS
row_spacing = HEIGHT / ROWS
c = rounded_box((DIVIDER_THICKNESS, 1e9, COL_DIVIDER_DEPTH), DIVIDER_FILLET)
c = c.translate(Z * COL_DIVIDER_DEPTH / 2)
c = c.repeat((col_spacing, 0, 0))
r = rounded_box((1e9, DIVIDER_THICKNESS, ROW_DIVIDER_DEPTH), DIVIDER_FILLET)
r = r.translate(Z * ROW_DIVIDER_DEPTH / 2)
r = r.repeat((0, row_spacing, 0))
if COLS % 2 != 0:
c = c.translate((col_spacing / 2, 0, 0))
if ROWS % 2 != 0:
r = r.translate((0, row_spacing / 2, 0))
return c | r
def box():
d = dividers()
p = WALL_THICKNESS
f = rounded_box((WIDTH - p, HEIGHT - p, 1e9), WALL_RADIUS)
f &= slab(z0=p/2).k(BOTTOM_RADIUS)
d &= f
f = f.shell(WALL_THICKNESS)
f &= slab(z1=DEPTH).k(TOP_FILLET)
return f | d
def lid():
p = WALL_THICKNESS
f = rounded_box((WIDTH + p, HEIGHT + p, 1e9), WALL_RADIUS)
f &= slab(z0=p/2).k(LID_RADIUS)
f = f.shell(LID_THICKNESS)
f &= slab(z1=LID_DEPTH).k(TOP_FILLET)
return f
box().save('box.stl', samples=SAMPLES)
lid().save('lid.stl', samples=SAMPLES)