Proof of concept for IFC construction documentation

This commit is contained in:
Dion Moult
2019-10-28 21:01:32 +11:00
parent cf454c6306
commit d6ef64aef4
6 changed files with 3234 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import xml.etree.ElementTree as ET
import pystache
import ntpath
import os
sheet_path = 'sheets/sheet1.svg'
sheet_filename = ntpath.basename(sheet_path)
sheet_name = sheet_filename[0:-4]
# hardcoded for testing
data = [
{'number': 'ASDF', 'revision': 'A'},
{},
{'no': '01', 'name': 'HOUSE', 'scale': '1:100'},
{},
{'no': '02', 'name': 'ELEVATION', 'scale': '1:100'},
{},
{'no': '03', 'name': 'PLAN', 'scale': '1:100'},
{},
{'no': '04', 'name': 'SECTION', 'scale': '1:100'},
]
tree = ET.parse(sheet_path)
root = tree.getroot()
embedded_svgs = root.findall('{http://www.w3.org/2000/svg}svg')
n = 0
for svg in embedded_svgs:
use = svg.findall('{http://www.w3.org/2000/svg}use')[0]
source = use.attrib.get('{http://www.w3.org/1999/xlink}href')
source_path = source.split('#')[0]
source_filename = ntpath.basename(source_path)
source_anchor = source.split('#')[1]
dest_filename = '{}-{}.svg'.format(source_filename[0:-4], n)
print(dest_filename)
os.makedirs('build/refs/{}/'.format(sheet_name), exist_ok=True)
with open('build/refs/{}/{}'.format(sheet_name, dest_filename), 'w') as out:
with open('sheets/{}'.format(source_path), 'r') as template:
out.write(pystache.render(template.read(), data[n]))
use.set('{http://www.w3.org/1999/xlink}href',
'refs/{}/{}#{}'.format(sheet_name, dest_filename, source_anchor))
n += 1
with open('build/{}'.format(sheet_filename), 'wb') as output:
tree.write(output)
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" id="root" version="1.1" height="594mm" width="841mm">
<defs />
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<use xlink:href="../templates/titleblock.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="150mm" y="50mm">
<use xlink:href="../views/house.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="150mm" y="50mm">
<use xlink:href="../templates/view-title.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="550mm" y="50mm">
<use xlink:href="../views/elevation.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="150mm" y="50mm">
<use xlink:href="../templates/view-title.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="550mm" y="50mm">
<use xlink:href="../views/plan.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="150mm" y="50mm">
<use xlink:href="../templates/view-title.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="550mm" y="50mm">
<use xlink:href="../views/section.svg#root" />
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="150mm" y="50mm">
<use xlink:href="../templates/view-title.svg#root" />
</svg>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,2 @@
.cut {fill: black; stroke: black; stroke-linecap: 'round'; stroke-width: 0.3px; }
.background { fill: white; stroke: black; stroke-linecap: 'round'; stroke-width: 0.05px; }
File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 108 KiB

@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="root"
version="1.1"
viewBox="0 0 50.222462 10"
height="10mm"
width="50.222462mm">
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(-27.82024,-96.649986)"
id="layer1">
<circle
r="4.8499999"
cy="101.64999"
cx="32.82024"
id="path853"
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.30000001;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
id="path855"
d="m 37.67024,101.64999 40.37246,-1e-5"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<text
id="text859"
y="102.19775"
x="32.820755"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58333302px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="font-size:2.11666656px;text-align:center;text-anchor:middle;stroke-width:0.26458332px"
y="102.19775"
x="32.820755"
id="tspan857">{{no}}</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58333302px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="39.368858"
y="99.525047"
id="text863"><tspan
id="tspan861"
x="39.368858"
y="99.525047"
style="font-size:2.11666656px;text-align:start;text-anchor:start;stroke-width:0.26458332px">{{name}}</tspan></text>
<text
id="text867"
y="104.66998"
x="39.368858"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58333302px;line-height:125%;font-family:Arial;-inkscape-font-specification:Arial;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
style="font-size:2.11666656px;text-align:start;text-anchor:start;stroke-width:0.26458332px"
y="104.66998"
x="39.368858"
id="tspan865">{{scale}}</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB