-
Notifications
You must be signed in to change notification settings - Fork 0
/
htmlboxes.py
35 lines (27 loc) · 901 Bytes
/
htmlboxes.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
#!python
"""
Generates an HTML file with the contours for a list of furnitures
from the application SweetHome3D (CSV export).
The resulting HTML code/page can then be printed and used for modeling.
"""
import sys
from string import Template
__version__ = "1.0.0"
__date__ = "2017-12-16"
__updated__ = "2017-12-16"
# resizing factor
FACTOR = 1.0 / 50.0
# read CSV file
with open(sys.argv[1], "r", encoding="utf8") as fin:
lines = fin.readlines()
for i, line in enumerate(lines):
if i == 0:
# skip first/header line
continue
name,width,depth,height,visible = line.split('\t')
w = float(width.replace(',','.')) * FACTOR
h = float(depth.replace(',','.')) * FACTOR
t = float(depth.replace(',','.')) * FACTOR
tpl = Template('<div style="width:${w}cm;height:${h}cm;">$name ($breite x $hoehe x $tiefe)</div>')
s = tpl.substitute(locals())
print(s)