trayinsert.py: Separating walls for dividing up drawers

A very much simpliefied version of typetray
This commit is contained in:
Florian Festi 2014-04-06 17:05:41 +02:00
parent ade81f9e64
commit b73a7d788f
2 changed files with 74 additions and 0 deletions

10
examples/trayinsert.svg Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="312mm" height="428mm" viewBox="0 0 312 428" version="1.1">
<g id="surface1">
<path style="fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 2.199219 2.199219 L 2.199219 2.199219 M 2.199219 2.199219 L 74.199219 2.199219 C 74.253906 2.199219 74.300781 2.242188 74.300781 2.300781 M 74.300781 2.300781 L 74.300781 42.300781 C 74.300781 42.246094 74.257812 42.199219 74.199219 42.199219 M 74.199219 42.199219 L 78.199219 42.199219 C 78.144531 42.199219 78.097656 42.242188 78.097656 42.300781 M 78.097656 42.300781 L 78.097656 2.300781 C 78.097656 2.246094 78.140625 2.199219 78.199219 2.199219 M 78.199219 2.199219 L 150.199219 2.199219 C 150.253906 2.199219 150.300781 2.242188 150.300781 2.300781 M 150.300781 2.300781 L 150.300781 42.300781 C 150.300781 42.246094 150.257812 42.199219 150.199219 42.199219 M 150.199219 42.199219 L 154.199219 42.199219 C 154.144531 42.199219 154.097656 42.242188 154.097656 42.300781 M 154.097656 42.300781 L 154.097656 2.300781 C 154.097656 2.246094 154.140625 2.199219 154.199219 2.199219 M 154.199219 2.199219 L 226.199219 2.199219 C 226.253906 2.199219 226.300781 2.242188 226.300781 2.300781 M 226.300781 2.300781 L 226.300781 42.300781 C 226.300781 42.246094 226.257812 42.199219 226.199219 42.199219 M 226.199219 42.199219 L 230.199219 42.199219 C 230.144531 42.199219 230.097656 42.242188 230.097656 42.300781 M 230.097656 42.300781 L 230.097656 2.300781 C 230.097656 2.246094 230.140625 2.199219 230.199219 2.199219 M 230.199219 2.199219 L 302.199219 2.199219 M 302.199219 2.199219 C 302.253906 2.199219 302.300781 2.242188 302.300781 2.300781 M 302.300781 2.300781 L 302.300781 2.300781 M 302.300781 2.300781 L 302.300781 82.300781 M 302.300781 82.300781 C 302.300781 82.355469 302.257812 82.402344 302.199219 82.402344 M 302.199219 82.402344 L 302.199219 82.402344 M 302.199219 82.402344 L 2.199219 82.402344 M 2.199219 82.402344 C 2.144531 82.402344 2.097656 82.359375 2.097656 82.300781 M 2.097656 82.300781 L 2.097656 82.300781 M 2.097656 82.300781 L 2.097656 2.300781 M 2.097656 2.300781 C 2.097656 2.246094 2.140625 2.199219 2.199219 2.199219 " transform="matrix(1,0,0,-1,4,424)"/>
<path style="fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 2.199219 2.201563 L 2.199219 2.201563 M 2.199219 2.201563 L 74.199219 2.201563 C 74.253906 2.201563 74.300781 2.244531 74.300781 2.303125 M 74.300781 2.303125 L 74.300781 42.303125 C 74.300781 42.248438 74.257812 42.201563 74.199219 42.201563 M 74.199219 42.201563 L 78.199219 42.201563 C 78.144531 42.201563 78.097656 42.244531 78.097656 42.303125 M 78.097656 42.303125 L 78.097656 2.303125 C 78.097656 2.248438 78.140625 2.201563 78.199219 2.201563 M 78.199219 2.201563 L 150.199219 2.201563 C 150.253906 2.201563 150.300781 2.244531 150.300781 2.303125 M 150.300781 2.303125 L 150.300781 42.303125 C 150.300781 42.248438 150.257812 42.201563 150.199219 42.201563 M 150.199219 42.201563 L 154.199219 42.201563 C 154.144531 42.201563 154.097656 42.244531 154.097656 42.303125 M 154.097656 42.303125 L 154.097656 2.303125 C 154.097656 2.248438 154.140625 2.201563 154.199219 2.201563 M 154.199219 2.201563 L 226.199219 2.201563 C 226.253906 2.201563 226.300781 2.244531 226.300781 2.303125 M 226.300781 2.303125 L 226.300781 42.303125 C 226.300781 42.248438 226.257812 42.201563 226.199219 42.201563 M 226.199219 42.201563 L 230.199219 42.201563 C 230.144531 42.201563 230.097656 42.244531 230.097656 42.303125 M 230.097656 42.303125 L 230.097656 2.303125 C 230.097656 2.248438 230.140625 2.201563 230.199219 2.201563 M 230.199219 2.201563 L 302.199219 2.201563 M 302.199219 2.201563 C 302.253906 2.201563 302.300781 2.244531 302.300781 2.303125 M 302.300781 2.303125 L 302.300781 2.303125 M 302.300781 2.303125 L 302.300781 82.303125 M 302.300781 82.303125 C 302.300781 82.357813 302.257812 82.404688 302.199219 82.404688 M 302.199219 82.404688 L 302.199219 82.404688 M 302.199219 82.404688 L 2.199219 82.404688 M 2.199219 82.404688 C 2.144531 82.404688 2.097656 82.361719 2.097656 82.303125 M 2.097656 82.303125 L 2.097656 82.303125 M 2.097656 82.303125 L 2.097656 2.303125 M 2.097656 2.303125 C 2.097656 2.248438 2.140625 2.201563 2.199219 2.201563 " transform="matrix(1,0,0,-1,4,339.6)"/>
<path style="fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 2.199219 2.2 L 2.199219 2.2 M 2.199219 2.2 L 262.199219 2.2 M 262.199219 2.2 C 262.253906 2.2 262.300781 2.242969 262.300781 2.301563 M 262.300781 2.301563 L 262.300781 2.301563 M 262.300781 2.301563 L 262.300781 82.301563 M 262.300781 82.301563 C 262.300781 82.35625 262.257812 82.403125 262.199219 82.403125 M 262.199219 82.403125 L 262.199219 82.403125 M 262.199219 82.403125 L 178.199219 82.403125 C 178.144531 82.403125 178.097656 82.360156 178.097656 82.301563 M 178.097656 82.301563 L 178.097656 42.301563 C 178.097656 42.35625 178.140625 42.403125 178.199219 42.403125 M 178.199219 42.403125 L 174.199219 42.403125 C 174.253906 42.403125 174.300781 42.360156 174.300781 42.301563 M 174.300781 42.301563 L 174.300781 82.301563 C 174.300781 82.35625 174.257812 82.403125 174.199219 82.403125 M 174.199219 82.403125 L 90.199219 82.403125 C 90.144531 82.403125 90.097656 82.360156 90.097656 82.301563 M 90.097656 82.301563 L 90.097656 42.301563 C 90.097656 42.35625 90.140625 42.403125 90.199219 42.403125 M 90.199219 42.403125 L 86.199219 42.403125 C 86.253906 42.403125 86.300781 42.360156 86.300781 42.301563 M 86.300781 42.301563 L 86.300781 82.301563 C 86.300781 82.35625 86.257812 82.403125 86.199219 82.403125 M 86.199219 82.403125 L 2.199219 82.403125 M 2.199219 82.403125 C 2.144531 82.403125 2.097656 82.360156 2.097656 82.301563 M 2.097656 82.301563 L 2.097656 82.301563 M 2.097656 82.301563 L 2.097656 2.301563 M 2.097656 2.301563 C 2.097656 2.246875 2.140625 2.2 2.199219 2.2 " transform="matrix(1,0,0,-1,4,255.2)"/>
<path style="fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 2.199219 2.198438 L 2.199219 2.198438 M 2.199219 2.198438 L 262.199219 2.198438 M 262.199219 2.198438 C 262.253906 2.198438 262.300781 2.241406 262.300781 2.3 M 262.300781 2.3 L 262.300781 2.3 M 262.300781 2.3 L 262.300781 82.3 M 262.300781 82.3 C 262.300781 82.354688 262.257812 82.401563 262.199219 82.401563 M 262.199219 82.401563 L 262.199219 82.401563 M 262.199219 82.401563 L 178.199219 82.401563 C 178.144531 82.401563 178.097656 82.358594 178.097656 82.3 M 178.097656 82.3 L 178.097656 42.3 C 178.097656 42.354688 178.140625 42.401563 178.199219 42.401563 M 178.199219 42.401563 L 174.199219 42.401563 C 174.253906 42.401563 174.300781 42.358594 174.300781 42.3 M 174.300781 42.3 L 174.300781 82.3 C 174.300781 82.354688 174.257812 82.401563 174.199219 82.401563 M 174.199219 82.401563 L 90.199219 82.401563 C 90.144531 82.401563 90.097656 82.358594 90.097656 82.3 M 90.097656 82.3 L 90.097656 42.3 C 90.097656 42.354688 90.140625 42.401563 90.199219 42.401563 M 90.199219 42.401563 L 86.199219 42.401563 C 86.253906 42.401563 86.300781 42.358594 86.300781 42.3 M 86.300781 42.3 L 86.300781 82.3 C 86.300781 82.354688 86.257812 82.401563 86.199219 82.401563 M 86.199219 82.401563 L 2.199219 82.401563 M 2.199219 82.401563 C 2.144531 82.401563 2.097656 82.358594 2.097656 82.3 M 2.097656 82.3 L 2.097656 82.3 M 2.097656 82.3 L 2.097656 2.3 M 2.097656 2.3 C 2.097656 2.245313 2.140625 2.198438 2.199219 2.198438 " transform="matrix(1,0,0,-1,4,170.8)"/>
<path style="fill:none;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 2.199219 2.200781 L 2.199219 2.200781 M 2.199219 2.200781 L 262.199219 2.200781 M 262.199219 2.200781 C 262.253906 2.200781 262.300781 2.24375 262.300781 2.302344 M 262.300781 2.302344 L 262.300781 2.302344 M 262.300781 2.302344 L 262.300781 82.302344 M 262.300781 82.302344 C 262.300781 82.357031 262.257812 82.403906 262.199219 82.403906 M 262.199219 82.403906 L 262.199219 82.403906 M 262.199219 82.403906 L 178.199219 82.403906 C 178.144531 82.403906 178.097656 82.360938 178.097656 82.302344 M 178.097656 82.302344 L 178.097656 42.302344 C 178.097656 42.357031 178.140625 42.403906 178.199219 42.403906 M 178.199219 42.403906 L 174.199219 42.403906 C 174.253906 42.403906 174.300781 42.360938 174.300781 42.302344 M 174.300781 42.302344 L 174.300781 82.302344 C 174.300781 82.357031 174.257812 82.403906 174.199219 82.403906 M 174.199219 82.403906 L 90.199219 82.403906 C 90.144531 82.403906 90.097656 82.360938 90.097656 82.302344 M 90.097656 82.302344 L 90.097656 42.302344 C 90.097656 42.357031 90.140625 42.403906 90.199219 42.403906 M 90.199219 42.403906 L 86.199219 42.403906 C 86.253906 42.403906 86.300781 42.360938 86.300781 42.302344 M 86.300781 42.302344 L 86.300781 82.302344 C 86.300781 82.357031 86.257812 82.403906 86.199219 82.403906 M 86.199219 82.403906 L 2.199219 82.403906 M 2.199219 82.403906 C 2.144531 82.403906 2.097656 82.360938 2.097656 82.302344 M 2.097656 82.302344 L 2.097656 82.302344 M 2.097656 82.302344 L 2.097656 2.302344 M 2.097656 2.302344 C 2.097656 2.247656 2.140625 2.200781 2.199219 2.200781 " transform="matrix(1,0,0,-1,4,86.4)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.3 KiB

64
trayinsert.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/python
# Copyright (C) 2013-2014 Florian Festi
#
# 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 boxes import *
class TrayInsert(Boxes):
def __init__(self, x, y, h, **kw):
self.x, self.y, self.h = x, y, h
t = kw.get("thickness", 4.0)
Boxes.__init__(self, width=max(sum(x)+len(x)*t, sum(y)+len(y)*t)+2*t,
height=(len(x)+len(y)-2)*(h+t)+2*t, **kw)
def render(self):
x = sum(self.x) + self.thickness * (len(self.x)-1)
y = sum(self.y) + self.thickness * (len(self.y)-1)
h = self.h
t = self.thickness
self.moveTo(t, t)
# Inner walls
for i in range(len(self.x)-1):
e = [SlottedEdge(self, self.y, slots=0.5*h), "e", "e", "e"]
self.rectangularWall(y, h, e,
move="up")
for i in range(len(self.y)-1):
e = ["e", "e",
SlottedEdge(self, self.x[::-1], "e", slots=0.5*h), "e"]
self.rectangularWall(x, h, e,
move="up")
self.close()
# Calculate equidistant section
x = 260 # width
nx = 3
y = 300 # depth
ny = 4
thickness=4.0
dx = (x+thickness)/nx-thickness
dy = (y+thickness)/ny-thickness
sx = [dx] * nx
sy = [dy] * ny
# Or give sections by hand
#sx = [80, 100, 80]
#sy = [80, 120, 200]
b = TrayInsert(sx, sy, 80, thickness=thickness, burn=0.1)
b.render()