forked from jakeson21/boxmaker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
my_box.py
141 lines (106 loc) · 5.09 KB
/
my_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
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
# -*- coding: utf-8 -*-
'''
Generates Inkscape SVG file containing box components needed to
laser cut a tabbed construction box taking kerf and clearance into account
Copyright (C) 2016 Apple Muncy [email protected]
Copyright (C) 2011 elliot white [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
from my_panel import Panel
import inkex
class Box:
'''
a box class
'''
def __init__(self, my_dict):
'''
all variables are passed in the dictionary my_dict.
"spacing" is the from zero to positive distance separating panels from
each other. It plays no other role.
'''
space = my_dict['spacing']
'''
Extract the dimensions of the 3d box.
Length normally the longest side as the left to right dimension.
Width normally next longest edge as front to back.
Depth as the shortest dimension from bottom to top.
The user may choose differently.
'''
length = my_dict['length']
width = my_dict['width']
depth = my_dict['depth']
if my_dict['debug']:
inkex.errormsg('length = {0} width = {1} depth = {2} '.format( length, width,depth ))
inkex.errormsg('s = {0}'.format(space ))
'''
Here figure out the layout of the sides of the box.
We transform to 2 dimensional space to have this layout when drawn
calculating absolute coordinates starting point in 2d space for each panel
Width
space
space width space length space width space length
space
width
space
passing abs_x and abs_y as coordinates bottom left starting origin.
Left to right is:
s z s x s z s
Bottom to top is
s
y
s
z
s
'''
left_x = space
top_x = divider_x = front_x = bottom_x = space + width + space
right_x = space + width + space + length + space
back_x = space + width + space + length + space + width + space
divider_y = space + width + space + depth +space + width + space
top_y = space + width + space + depth +space
left_y = front_y = right_y = back_y = space + width + space
bottom_y = space
'''
(a,b,c,d) hold information that gets translated to where edges start and end.
In order that edges mesh together, "zero" edges mesh with "one" edges.
'''
(a,b,c,d) = 0,0,0,0
self.front_panel = Panel( 'front_panel', front_x, front_y, (a,b,c,d), length, depth,
my_dict)
#if my_dict['debug'] : return
self.back_panel = Panel( 'back_panel', back_x, back_y, (a,b,c,d), length, depth,
my_dict)
(a,b,c,d) = 1,1,1,1
self.top_panel = Panel( 'top_panel', top_x, top_y, (a,b,c,d), length, width,
my_dict)
if my_dict['has_divider']:
self.divider_panel =Panel('divider_panel',divider_x, divider_y,(a,b,c,d), length, width,
my_dict)
self.bottom_panel = Panel('bottom_panel', bottom_x, bottom_y,(a,b,c,d), length, width,
my_dict)
(a,b,c,d) = 0,1,0,1
self.left_panel = Panel ( 'left_panel', left_x, left_y, (a,b,c,d), width, depth, my_dict)
self.right_panel =Panel( 'right_panel', right_x, right_y, (a,b,c,d), width, depth, my_dict)
if my_dict['front_panel_cutout'] : self.front_panel.do_cutout()
if my_dict['back_panel_cutout'] : self.back_panel.do_cutout()
if my_dict['right_panel_cutout'] : self.right_panel.do_cutout()
if my_dict['left_panel_cutout'] : self.left_panel.do_cutout()
if my_dict['top_panel_cutout'] : self.top_panel.do_cutout()
if my_dict['divider_panel_cutout'] and my_dict['has_divider'] : self.divider_panel.do_cutout()
if my_dict['bottom_panel_cutout'] : self.bottom_panel.do_cutout()
if my_dict['add_bearings'] : self.back_panel.do_nema()
if my_dict['add_bearings'] : self.left_panel.do_nema()
if my_dict['add_bearings'] : self.front_panel.do_bearing()
if my_dict['add_bearings'] : self.back_panel.do_bearing()
if my_dict['add_bearings'] : self.right_panel.do_bearing()
if my_dict['add_bearings'] : self.left_panel.do_bearing()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99