-
Notifications
You must be signed in to change notification settings - Fork 0
/
parashelf.py
196 lines (185 loc) · 8.71 KB
/
parashelf.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#! /usr/bin/env python
# -*- coding: UTF-8 -*-
from __future__ import division
import os
import sys
import re
# Assumes SolidPython is in site-packages or elsewhwere in sys.path
from solid import *
from solid.utils import *
from tabs import *
from CutPiece import *
SEGMENTS = 90
def assembly(shelfHeight, shelfWidth, shelfDepth, kickplateHeight, shelfCount, tabHeight, ply, cutterDiameter, wTabCount, hTabCount, dTabCount, explode):
rightSide_Top_Cut = CutPiece(
translation = [0,ply-tabHeight,shelfHeight-ply],
rotation = [0,0,0],
geo = squareTabCut(tabHeight, shelfDepth, tabHeight, cutterDiameter, dTabCount,alternate=True,allAround=False)
)
leftSide_Top_Cut = CutPiece(
translation = [0,shelfWidth-ply+tabHeight,shelfHeight-ply],
rotation = [0,0,0],
geo = mirror([0,1,0])(rightSide_Top_Cut.geo)
)
rightSide_Back_Cut = CutPiece(
translation = [shelfDepth-ply,ply,0],
rotation = [0,0,0],
geo = rotate([180,-90,0])(squareTabCut(tabHeight, shelfHeight-ply+tabHeight, tabHeight, cutterDiameter, hTabCount,alternate=False,allAround=False))
)
leftSide_Back_Cut = CutPiece(
translation = [shelfDepth-ply,shelfWidth-ply+tabHeight,0],
rotation = [0,0,0],
geo = rightSide_Back_Cut.geo
)
back_rightSide_Cut = CutPiece(
translation = [shelfDepth-ply+tabHeight,ply,0],
rotation = [0,0,0],
geo = rotate([90,-90,0])(squareTabCut(tabHeight, shelfHeight-ply+tabHeight, tabHeight, cutterDiameter, hTabCount,alternate=True,allAround=False))
)
back_leftSide_Cut = CutPiece(
translation = [shelfDepth-ply+tabHeight,shelfWidth-ply,0],
rotation = [0,0,0],
geo = mirror([0,1,0])(back_rightSide_Cut.geo)
)
back_top_Cut = CutPiece(
translation = [shelfDepth-ply,shelfWidth+tabHeight,shelfHeight-ply],
rotation = [0,0,-90],
geo = squareTabCut(tabHeight, shelfWidth, tabHeight, cutterDiameter, wTabCount,alternate=True,allAround=False)
)
top_rightSide_Cut = CutPiece(
translation = [0,ply,shelfHeight-ply],
rotation = [90,0,0],
geo = squareTabCut(tabHeight, shelfDepth, tabHeight, cutterDiameter, dTabCount,alternate=False,allAround=False)
)
top_leftSide_Cut = CutPiece(
translation = [0,shelfWidth-ply,shelfHeight-ply],
rotation = [-90,0,0],
geo = mirror([0,1,0])(top_rightSide_Cut.geo)
)
top_back_Cut = CutPiece(
translation = [shelfDepth-ply,shelfWidth,shelfHeight-ply+tabHeight],
rotation = [-90,0,-90],
geo = squareTabCut(tabHeight, shelfWidth, tabHeight, cutterDiameter, wTabCount,alternate=False,allAround=False)
)
rightSide = CutPiece(
translation = [0,0,0],
rotation = [0,0,0],
geo = union()(
cube([shelfDepth,ply-tabHeight,shelfHeight-ply+tabHeight]),
translate([0,ply-tabHeight,0])(cube([shelfDepth-ply+tabHeight,tabHeight,shelfHeight-ply+tabHeight]))
)
)
leftSide = CutPiece(
translation = [0,shelfWidth-ply,0],
rotation = [0,0,0],
geo = union()(
cube([shelfDepth-ply+tabHeight,tabHeight,shelfHeight-ply+tabHeight]),
translate([0,tabHeight,0])(cube([shelfDepth,ply-tabHeight,shelfHeight-ply+tabHeight]))
)
)
top = CutPiece(
translation = [0,0,shelfHeight-ply],
rotation = [0,0,0],
geo = union()(
translate([0,ply-tabHeight,0])(cube([shelfDepth-ply+tabHeight,shelfWidth - 2*(ply-tabHeight), tabHeight])),
translate([0,0,tabHeight])(cube([shelfDepth,shelfWidth, ply-tabHeight]))
)
)
kickplate = CutPiece(
translation = [0,0,0],
rotation = [0,0,0],
geo = union()(
translate([0,ply,0])(cube([ply,shelfWidth - 2*ply,kickplateHeight-ply])),
translate([ply/2,ply/2,0])(cube([ply/2,shelfWidth - ply,kickplateHeight-ply/2]))
)
)
backSide = CutPiece(
translation = [shelfDepth - ply, ply-tabHeight, 0],
rotation = [0,0,0],
geo = union()(
translate([0,0,0])(cube([ply, shelfWidth - 2 * (ply-tabHeight), shelfHeight-ply+tabHeight]))
)
)
shelfPieces = []
shelfCutouts = []
shelfStartHeight = kickplateHeight - ply
shelfSpacing = (shelfHeight - ply - shelfStartHeight) / (shelfCount)
shelfCutoutTemplate = squareTabCut(tabHeight, shelfDepth-ply+tabHeight, ply, cutterDiameter, dTabCount,alternate=False,allAround=False)
shelfBackCutoutTemplate = squareTabCut(tabHeight, shelfWidth-2*tabHeight, ply, cutterDiameter, wTabCount,alternate=False,allAround=False)
shelfTemplate = difference()(
translate([0,ply-tabHeight,0])(cube([shelfDepth-ply+tabHeight,shelfWidth-2*(ply-tabHeight), ply])),
translate([0,ply,0])(rotate([90,0,0])(shelfCutoutTemplate)),
translate([0,shelfWidth-ply,0])(rotate([-90,0,0])(mirror([0,1,0])(shelfCutoutTemplate))),
translate([shelfDepth-ply, ply, 0])(rotate([90,0,90])(shelfBackCutoutTemplate))
)
shelfSideCutoutTemplate = squareTabCut(ply, shelfDepth, tabHeight, cutterDiameter, dTabCount,alternate=True,allAround=True)
shelfCutoutTemplateForBack = squareTabCut(ply, shelfWidth-2*tabHeight, tabHeight, cutterDiameter, wTabCount,alternate=True,allAround=True)
for i in range(0,shelfCount):
shelfPieces += [CutPiece(
translation = [0,0,shelfStartHeight+i*shelfSpacing],
rotation = [0,0,0],
geo = shelfTemplate
)]
shelfCutouts += [
CutPiece(
translation = [0,ply-tabHeight,shelfStartHeight+i*shelfSpacing],
rotation = [0,0,0],
geo = shelfSideCutoutTemplate
),
CutPiece(
translation = [0,shelfWidth-ply+tabHeight,shelfStartHeight+i*shelfSpacing],
rotation = [0,0,0],
geo = mirror([0,1,0])(shelfSideCutoutTemplate)
),
CutPiece(
translation = [shelfDepth-ply+tabHeight, ply, shelfStartHeight+i*shelfSpacing],
rotation = [0,0,90],
geo = shelfCutoutTemplateForBack
)
]
renderedCutouts = union()(*[s.inPlace() for s in shelfCutouts])
rightSideRendered = rightSide.inPlace() - rightSide_Top_Cut.inPlace() - renderedCutouts - kickplate.inPlace() - rightSide_Back_Cut.inPlace()
leftSideRendered = leftSide.inPlace() - leftSide_Top_Cut.inPlace() - renderedCutouts - kickplate.inPlace() - leftSide_Back_Cut.inPlace()
backRendered = backSide.inPlace() - renderedCutouts - back_rightSide_Cut.inPlace() - back_leftSide_Cut.inPlace() - back_top_Cut.inPlace()
topRendered = top.inPlace() - top_rightSide_Cut.inPlace() - top_leftSide_Cut.inPlace() - top_back_Cut.inPlace()
shelves = [s.inPlace() - kickplate.inPlace() for s in shelfPieces]
scad_render_to_file(rightSideRendered, "rightside.scad", file_header='$fn = %s;' % SEGMENTS, include_orig_code=True)
scad_render_to_file(leftSideRendered, "leftside.scad", file_header='$fn = %s;' % SEGMENTS, include_orig_code=True)
scad_render_to_file(backRendered, "back.scad", file_header='$fn = %s;' % SEGMENTS, include_orig_code=True)
scad_render_to_file(topRendered, "top.scad", file_header='$fn = %s;' % SEGMENTS, include_orig_code=True)
for i in range(0,len(shelves)):
scad_render_to_file(shelves[i], "shelf" + str(i) + ".scad", file_header='$fn = %s;' % SEGMENTS, include_orig_code=True)
return union()(
#color("red")(back_leftSide_Cut.inPlace()),
union()(*shelves),
back(explode)(color("red")(rightSideRendered)),
forward(explode)(color("red")(leftSideRendered)),
#color("blue")( topTabCut.inPlace()),
#color("blue")( top_leftSide_Cut.inPlace()),
up(explode)(color("blue")(topRendered)),
down(explode)(color("blue")(kickplate.inPlace())),
right(explode)(color("green")(backRendered)),
#color("green")(leftPanel)
#color("red")(leftSide_Top_Cut.inPlace())
)
#top -= rightPanel
#top -= leftPanel
#intersection()(top,offset(0.001)(top))
if __name__ == '__main__':
uom = 25.4
ply = 18#11.7#23/32 * uom
a = assembly(
shelfHeight = 30 * uom,
shelfWidth = 37 * uom,
shelfDepth = 18 * uom,
kickplateHeight = 3 * uom,
shelfCount = 2,
tabHeight = ply,
ply = ply,
cutterDiameter = 7,
wTabCount = 9,
hTabCount = 9,
dTabCount = 5,
explode = 50
)
scad_render_to_file(a, file_header='$fn = %s;' % SEGMENTS, include_orig_code=True)