-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathLasercut_box.py
More file actions
528 lines (490 loc) · 25.6 KB
/
Lasercut_box.py
File metadata and controls
528 lines (490 loc) · 25.6 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
#!/usr/bin/env/python
'''
Copyright (C)2011 Mark Schafer <neon.mark(a)gmaildotcom>
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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
# Build a tabbed box for lasercutting with tight fit, and minimal material use options.
# User defines:
# - internal or external dimensions,
# - number of tabs,
# - amount lost to laser (kerf),
# - include corner cubes or not,
# - dimples, or perfect fit (accounting for kerf).
# If zero kerf - will be perfectly packed for minimal laser cuts and material size.
### Todo
# add option to pack multiple boxes (if zero kerf) - new tab maybe?
# add option for little circles at sharp corners for acrylic
# annotations: - add overlap value as markup - Ponoko annotation color
# choose colours from a dictionary
### Versions
# 0.1 February 2011 - basic lasercut box with dimples etc
# 0.2 changes to unittouu for Inkscape 0.91
# 0.3 Option to avoid half-sized tabs at corners. <juergen@fabmail.org>
__version__ = "0.3"
#from math import *
import sys
import inkex
from simplepath import *
from lxml import etree
class LasercutBox(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.arg_parser.add_argument("-i", "--int_ext",
type=inkex.Boolean,
dest="int_ext", default=False,
help="Are the Dimensions for External or Internal sizing.")
self.arg_parser.add_argument("-x", "--width",
type=float,
dest="width", default=50.0,
help="The Box Width - in the X dimension")
self.arg_parser.add_argument("-y", "--height",
type=float,
dest="height", default=30.0,
help="The Box Height - in the Y dimension")
self.arg_parser.add_argument("-z", "--depth",
type=float,
dest="depth", default=15.0,
help="The Box Depth - in the Z dimension")
self.arg_parser.add_argument("-t", "--thickness",
type=float,
dest="thickness", default=3.0,
help="Material Thickness - critical to know")
self.arg_parser.add_argument("-u", "--units",
type=str,
dest="units", default="cm",
help="The unit of the box dimensions")
self.arg_parser.add_argument("-c", "--corners",
type=inkex.Boolean,
dest="corners", default=True,
help="The corner cubes can be removed for a different look")
self.arg_parser.add_argument("-H", "--halftabs",
type=inkex.Boolean,
dest="halftabs", default=True,
help="Start/End with half-sized tabs - Avoid with very small tabs")
self.arg_parser.add_argument("-p", "--ntab_W",
type=int,
dest="ntab_W", default=11,
help="Number of tabs in Width")
self.arg_parser.add_argument("-q", "--ntab_H",
type=int,
dest="ntab_H", default=11,
help="Number of tabs in Height")
self.arg_parser.add_argument("-r", "--ntab_D",
type=int,
dest="ntab_D", default=6,
help="Number of tabs in Depth")
self.arg_parser.add_argument("-k", "--kerf_size",
type=float,
dest="kerf_size", default=0.0,
help="Kerf size - amount lost to laser for this material. 0 = loose fit")
self.arg_parser.add_argument("-d", "--dimples",
type=inkex.Boolean,
dest="dimples", default=False,
help="Add dimples for press fitting wooden materials")
self.arg_parser.add_argument("-s", "--dstyle",
type=inkex.Boolean,
dest="dstyle", default=False,
help="Dimples can be triangles(cheaper) or half rounds(better)")
self.arg_parser.add_argument("-g", "--linewidth",
type=inkex.Boolean,
dest="linewidth", default=False,
help="Use the kerf value as the drawn line width")
# self.arg_parser.add_argument("-j", "--annotation",
# type=inkex.Boolean,
# dest="annotation", default=True,
# help="Show Kerf value as annotation")
#dummy for the doc tab - which is named
self.arg_parser.add_argument("--tab",
type=str,
dest="tab", default="use",
help="The selected UI-tab when OK was pressed")
#internal useful variables
self.stroke_width = 0.1 #default for visiblity
self.line_style = {'stroke': '#0000FF', # Ponoko blue
'fill': 'none',
'stroke-width': self.stroke_width,
'stroke-linecap': 'butt',
'stroke-linejoin': 'miter'}
def annotation(self, x, y, text):
""" Draw text at this location
- change to path
- use annotation color """
pass
def thickness_line(self, dimple, vert_horiz, pos_neg):
""" called to draw dimples (also draws simple lines if no dimple)
- pos_neg is 1, -1 for direction
- vert_horiz is v or h """
if dimple and self.kerf > 0.0: # we need a dimple
# size is radius = kerf
# short line, half circle, short line
#[ 'C', [x1,y1, x2,y2, x,y] ] x1 is first handle, x2 is second
lines = []
radius = self.kerf
if self.thick - 2 * radius < 0.2: # correct for large dimples(kerf) on small thicknesses
radius = (self.thick - 0.2) / 2
short = 0.1
else:
short = self.thick/2 - radius
if vert_horiz == 'v': # vertical line
# first short line
lines.append(['v', [pos_neg*short]])
# half circle
if pos_neg == 1: # only the DH_sides need reversed tabs to interlock
if self.dimple_tri:
lines.append(['l', [radius, pos_neg*radius]])
lines.append(['l', [-radius, pos_neg*radius]])
else:
lines.append(['c', [radius, 0, radius, pos_neg*2*radius, 0, pos_neg*2*radius]])
else:
if self.dimple_tri:
lines.append(['l', [-radius, pos_neg*radius]])
lines.append(['l', [radius, pos_neg*radius]])
else:
lines.append(['c', [-radius, 0, -radius, pos_neg*2*radius, 0, pos_neg*2*radius]])
# last short line
lines.append(['v', [pos_neg*short]])
else: # horizontal line
# first short line
lines.append(['h', [pos_neg*short]])
# half circle
if self.dimple_tri:
lines.append(['l', [pos_neg*radius, radius]])
lines.append(['l', [pos_neg*radius, -radius]])
else:
lines.append(['c', [0, radius, pos_neg*2*radius, radius, pos_neg*2*radius, 0]])
# last short line
lines.append(['h', [pos_neg*short]])
return lines
# No dimple - so much easier
else: # return a straight v or h line same as thickness
if vert_horiz == 'v':
return [ ['v', [pos_neg*self.thick]] ]
else:
return [ ['h', [pos_neg*self.thick]] ]
def draw_WH_lid(self, startx, starty, masktop=False):
""" Return an SVG path for the top or bottom of box
- the Width * Height dimension """
line_path = []
line_path.append(['M', [startx, starty]])
# top row of tabs
if masktop and self.kerf ==0.0: # don't draw top for packing with no extra cuts
line_path.append(['m', [self.boxW, 0]])
else:
if not self.ht: line_path.append(['l', [self.boxW/self.Wtabs/4 - self.pf/2, 0]])
for i in range(int(self.Wtabs)):
line_path.append(['h', [self.boxW/self.Wtabs/4 - self.pf/2]])
#line_path.append(['v', [0, -thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'v', -1):
line_path.append(l)
line_path.append(['h', [self.boxW/self.Wtabs/2 + self.pf]])
line_path.append(['v', [self.thick]])
line_path.append(['h', [self.boxW/self.Wtabs/4 - self.pf/2]])
if not self.ht: line_path.append(['l', [self.boxW/self.Wtabs/4 - self.pf/2, 0]])
# right hand vertical drop
if not self.ht: line_path.append(['l', [0, self.boxH/self.Htabs/4 - self.pf/2]])
for i in range(int(self.Htabs)):
line_path.append(['v', [self.boxH/self.Htabs/4 - self.pf/2]])
line_path.append(['h', [self.thick]])
line_path.append(['v', [self.boxH/self.Htabs/2 + self.pf]])
#line_path.append(['h', [-thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'h', -1):
line_path.append(l)
line_path.append(['v', [self.boxH/self.Htabs/4 - self.pf/2]])
if not self.ht: line_path.append(['l', [0, self.boxH/self.Htabs/4 - self.pf/2]])
# bottom row (in reverse)
if not self.ht: line_path.append(['l', [-self.boxW/self.Wtabs/4 + self.pf/2, 0]])
for i in range(int(self.Wtabs)):
line_path.append(['h', [-self.boxW/self.Wtabs/4 + self.pf/2]])
line_path.append(['v', [self.thick]])
line_path.append(['h', [-self.boxW/self.Wtabs/2 - self.pf]])
#line_path.append(['v', [0, -thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'v', -1):
line_path.append(l)
line_path.append(['h', [-self.boxW/self.Wtabs/4 + self.pf/2]])
if not self.ht: line_path.append(['l', [-self.boxW/self.Wtabs/4 + self.pf/2, 0]])
# up the left hand side
if not self.ht: line_path.append(['l', [0, -self.boxH/self.Htabs/4 + self.pf/2]])
for i in range(int(self.Htabs)):
line_path.append(['v', [-self.boxH/self.Htabs/4 + self.pf/2]])
#line_path.append(['h', [-thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'h', -1):
line_path.append(l)
line_path.append(['v', [-self.boxH/self.Htabs/2 - self.pf]])
line_path.append(['h', [self.thick]])
line_path.append(['v', [-self.boxH/self.Htabs/4 + self.pf/2]])
if not self.ht: line_path.append(['l', [0, -self.boxH/self.Htabs/4 + self.pf/2]])
return line_path
def draw_WD_side(self, startx, starty, mask=False, corners=True):
""" Return an SVG path for the long side of box
- the Width * Depth dimension """
# Draw side of the box (placed below the lid)
line_path = []
# top row of tabs
if corners:
line_path.append(['M', [startx - self.thick, starty]])
line_path.append(['v', [-self.thick]])
line_path.append(['h', [self.thick]])
else:
line_path.append(['M', [startx, starty]])
line_path.append(['v', [-self.thick]])
#
if self.kerf > 0.0: # if fit perfectly - don't draw double line
if not self.ht: line_path.append(['l', [self.boxW/self.Wtabs/4 + self.pf/2, 0]])
for i in range(int(self.Wtabs)):
line_path.append(['h', [self.boxW/self.Wtabs/4 + self.pf/2]])
line_path.append(['v', [self.thick]])
line_path.append(['h', [self.boxW/self.Wtabs/2 - self.pf]])
#line_path.append(['v', [0, -thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'v', -1):
line_path.append(l)
line_path.append(['h', [self.boxW/self.Wtabs/4 + self.pf/2]])
if not self.ht: line_path.append(['l', [self.boxW/self.Wtabs/4 + self.pf/2, 0]])
if corners: line_path.append(['h', [self.thick]])
else: # move to skipped drawn lines
if corners:
line_path.append(['m', [self.boxW + self.thick, 0]])
else:
line_path.append(['m', [self.boxW, 0]])
#
line_path.append(['v', [self.thick]])
if not corners: line_path.append(['h', [self.thick]])
# RHS
if not self.ht: line_path.append(['l', [0, self.boxD/self.Dtabs/4 + self.pf/2]])
for i in range(int(self.Dtabs)):
line_path.append(['v', [self.boxD/self.Dtabs/4 + self.pf/2]])
#line_path.append(['h', [-thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'h', -1):
line_path.append(l)
line_path.append(['v', [self.boxD/self.Dtabs/2 - self.pf]])
line_path.append(['h', [self.thick]])
line_path.append(['v', [self.boxD/self.Dtabs/4 + self.pf/2]])
if not self.ht: line_path.append(['l', [0, self.boxD/self.Dtabs/4 + self.pf/2]])
#
if corners:
line_path.append(['v', [self.thick]])
line_path.append(['h', [-self.thick]])
else:
line_path.append(['h', [-self.thick]])
line_path.append(['v', [self.thick]])
# base
if not self.ht: line_path.append(['l', [-self.boxW/self.Wtabs/4 - self.pf/2, 0]])
for i in range(int(self.Wtabs)):
line_path.append(['h', [-self.boxW/self.Wtabs/4 - self.pf/2]])
#line_path.append(['v', [0, -thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'v', -1):
line_path.append(l)
line_path.append(['h', [-self.boxW/self.Wtabs/2 + self.pf]])
line_path.append(['v', [self.thick]])
line_path.append(['h', [-self.boxW/self.Wtabs/4 - self.pf/2]])
if not self.ht: line_path.append(['l', [-self.boxW/self.Wtabs/4 - self.pf/2, 0]])
#
if corners:
line_path.append(['h', [-self.thick]])
line_path.append(['v', [-self.thick]])
else:
line_path.append(['v', [-self.thick]])
line_path.append(['h', [-self.thick]])
# LHS
if not self.ht: line_path.append(['l', [0, -self.boxD/self.Dtabs/4 - self.pf/2]])
for i in range(int(self.Dtabs)):
line_path.append(['v', [-self.boxD/self.Dtabs/4 - self.pf/2]])
line_path.append(['h', [self.thick]])
line_path.append(['v', [-self.boxD/self.Dtabs/2 + self.pf]])
#line_path.append(['h', [-thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'h', -1):
line_path.append(l)
line_path.append(['v', [-self.boxD/self.Dtabs/4 - self.pf/2]])
if not self.ht: line_path.append(['l', [0, -self.boxD/self.Dtabs/4 - self.pf/2]])
#
if not corners: line_path.append(['h', [self.thick]])
return line_path
def draw_HD_side(self, startx, starty, corners, mask=False):
""" Return an SVG path for the short side of box
- the Height * Depth dimension """
line_path = []
# top row of tabs
line_path.append(['M', [startx, starty]])
if not(mask and corners and self.kerf == 0.0):
line_path.append(['h', [self.thick]])
else:
line_path.append(['m', [self.thick, 0]])
if not self.ht: line_path.append(['l', [self.boxD/self.Dtabs/4 - self.pf/2, 0]])
for i in range(int(self.Dtabs)):
line_path.append(['h', [self.boxD/self.Dtabs/4 - self.pf/2]])
line_path.append(['v', [-self.thick]])
line_path.append(['h', [self.boxD/self.Dtabs/2 + self.pf]])
#line_path.append(['v', [0, thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'v', 1):
line_path.append(l)
line_path.append(['h', [self.boxD/self.Dtabs/4 - self.pf/2]])
if not self.ht: line_path.append(['l', [self.boxD/self.Dtabs/4 - self.pf/2, 0]])
line_path.append(['h', [self.thick]])
#
if not self.ht: line_path.append(['l', [0, self.boxH/self.Htabs/4 + self.pf/2]])
for i in range(int(self.Htabs)):
line_path.append(['v', [self.boxH/self.Htabs/4 + self.pf/2]])
#line_path.append(['h', [-thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'h', -1):
line_path.append(l)
line_path.append(['v', [self.boxH/self.Htabs/2 - self.pf]])
line_path.append(['h', [self.thick]])
line_path.append(['v', [self.boxH/self.Htabs/4 + self.pf/2]])
if not self.ht: line_path.append(['l', [0, self.boxH/self.Htabs/4 + self.pf/2]])
line_path.append(['h', [-self.thick]])
#
if not self.ht: line_path.append(['l', [-self.boxD/self.Dtabs/4 + self.pf/2, 0]])
for i in range(int(self.Dtabs)):
line_path.append(['h', [-self.boxD/self.Dtabs/4 + self.pf/2]])
#line_path.append(['v', [0, thick]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'v', 1): # this is the weird +1 instead of -1 dimple
line_path.append(l)
line_path.append(['h', [-self.boxD/self.Dtabs/2 - self.pf]])
line_path.append(['v', [-self.thick]])
line_path.append(['h', [-self.boxD/self.Dtabs/4 + self.pf/2]])
if not self.ht: line_path.append(['l', [-self.boxD/self.Dtabs/4 + self.pf/2, 0]])
line_path.append(['h', [-self.thick]])
#
if self.kerf > 0.0: # if fit perfectly - don't draw double line
if not self.ht: line_path.append(['l', [0, -self.boxH/self.Htabs/4 - self.pf/2]])
for i in range(int(self.Htabs)):
line_path.append(['v', [-self.boxH/self.Htabs/4 - self.pf/2]])
line_path.append(['h', [self.thick]])
line_path.append(['v', [-self.boxH/self.Htabs/2 + self.pf]])
#line_path.append(['h', [-thick, 0]]) # replaced with dimpled version
for l in self.thickness_line(self.dimple, 'h', -1):
line_path.append(l)
line_path.append(['v', [-self.boxH/self.Htabs/4 - self.pf/2]])
if not self.ht: line_path.append(['l', [0, -self.boxH/self.Htabs/4 - self.pf/2]])
return line_path
###--------------------------------------------
### The main function called by the inkscape UI
def effect(self):
# document dimensions (for centering)
docW = self.svg.unittouu(self.document.getroot().get('width'))
docH = self.svg.unittouu(self.document.getroot().get('height'))
# extract fields from UI
self.boxW = self.svg.unittouu(str(self.options.width) + self.options.units)
self.boxH = self.svg.unittouu(str(self.options.height) + self.options.units)
self.boxD = self.svg.unittouu(str(self.options.depth) + self.options.units)
self.thick = self.svg.unittouu(str(self.options.thickness) + self.options.units)
self.kerf = self.svg.unittouu(str(self.options.kerf_size) + self.options.units)
if self.kerf < 0.01: self.kerf = 0.0 # snap to 0 for UI error when setting spinner to 0.0
self.Wtabs = self.options.ntab_W
self.Htabs = self.options.ntab_H
self.Dtabs = self.options.ntab_D
self.dimple = self.options.dimples
line_width = self.options.linewidth
corners = self.options.corners
self.dimple_tri = self.options.dstyle
# self.annotation = self.options.annotation
self.ht = self.options.halftabs
if not self.ht:
self.Wtabs += 0.5
self.Htabs += 0.5
self.Dtabs += 0.5
# Correct for thickness in dimensions
if self.options.int_ext: # external so add thickness
self.boxW -= self.thick*2
self.boxH -= self.thick*2
self.boxD -= self.thick*2
# adjust for laser kerf (precise measurement)
self.boxW += self.kerf
self.boxH += self.kerf
self.boxD += self.kerf
# Precise fit or dimples (if kerf > 0.0)
if self.dimple == False: # and kerf > 0.0:
self.pf = self.kerf
else:
self.pf = 0.0
# set the stroke width and line style
sw = self.kerf
if self.kerf == 0.0: sw = self.stroke_width
ls = self.line_style
if line_width: # user wants drawn line width to be same as kerf size
ls['stroke-width'] = sw
line_style = str(inkex.Style(ls))
###---------------------------
### create the inkscape object
box_id = self.svg.get_unique_id('box')
self.box = g = etree.SubElement(self.svg.get_current_layer(), 'g', {'id':box_id})
#Set local position for drawing (will transform to center of doc at end)
lower_pos = 0
left_pos = 0
# Draw Lid (using SVG path definitions)
line_path = self.draw_WH_lid(left_pos, lower_pos)
#print(str(line_path), file=sys.stderr)
# Add to scene
line_atts = { 'style':line_style, 'id':box_id+'-lid', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts)
# draw the side of the box directly below
if self.kerf > 0.0:
lower_pos += self.boxH + (3*self.thick)
else: # kerf = 0 so don't draw extra lines and fit perfectly
lower_pos += self.boxH + self.thick # at lower edge of lid
left_pos += 0
# Draw side of the box (placed below the lid)
line_path = self.draw_WD_side(left_pos, lower_pos, corners=corners)
# Add to scene
line_atts = { 'style':line_style, 'id':box_id+'-longside1', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts)
# draw the bottom of the box directly below
if self.kerf > 0.0:
lower_pos += self.boxD + (3*self.thick)
else: # kerf = 0 so don't draw extra lines and fit perfectly
lower_pos += self.boxD + self.thick # at lower edge
left_pos += 0
# Draw base of the box
line_path = self.draw_WH_lid(left_pos, lower_pos, True)
# Add to scene
line_atts = { 'style':line_style, 'id':box_id+'-base', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts)
# draw the second side of the box directly below
if self.kerf > 0.0:
lower_pos += self.boxH + (3*self.thick)
else: # kerf = 0 so don't draw extra lines and fit perfectly
lower_pos += self.boxH + self.thick # at lower edge of lid
left_pos += 0
# Draw side of the box (placed below the lid)
line_path = self.draw_WD_side(left_pos, lower_pos, corners=corners)
# Add to scene
line_atts = { 'style':line_style, 'id':box_id+'-longside2', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts)
# draw next on RHS of lid
if self.kerf > 0.0:
left_pos += self.boxW + (2*self.thick) # adequate space (could be a param for separation when kerf > 0)
else:
left_pos += self.boxW # right at right edge of lid
lower_pos = 0
# Side of the box (placed next to the lid)
line_path = self.draw_HD_side(left_pos, lower_pos, corners)
# Add to scene
line_atts = { 'style':line_style, 'id':box_id+'-endface2', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts)
# draw next on RHS of base
if self.kerf > 0.0:
lower_pos += self.boxH + self.boxD + 6*self.thick
else:
lower_pos += self.boxH +self.boxD + 2*self.thick
# Side of the box (placed next to the lid)
line_path = self.draw_HD_side(left_pos, lower_pos, corners, True)
# Add to scene
line_atts = { 'style':line_style, 'id':box_id+'-endface1', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts)
###----------------------------------------
# Transform entire drawing to center of doc
lower_pos += self.boxH*2 + self.boxD*2 + 2*self.thick
left_pos += self.boxH + 2*self.thick
g.set( 'transform', 'translate(%f,%f)' % ( (docW-left_pos)/2, (docH-lower_pos)/2))
###
if __name__ == '__main__':
e = LasercutBox()
e.run()