MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / svg_split

Function svg_split

src/ifcquery/ifcquery/plot.py:228–242  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

226 register_namespace("", "http://www.w3.org/2000/svg")
227
228 def svg_split(f):
229 x = ElementTree(file=f)
230 svg = x.getroot()
231 resources = []
232 for child in svg:
233 if child.tag == "{http://www.w3.org/2000/svg}g":
234 root = Element(svg.tag, svg.attrib)
235 n = ElementTree(root)
236 for r in resources + [child]:
237 root.append(r)
238 b = BytesIO()
239 n.write(b, xml_declaration=True, encoding="utf-8", method="xml")
240 yield b.getvalue()
241 else:
242 resources.append(child)
243
244 if output_format == "svg":
245 return svg_bytes

Callers 1

plotFunction · 0.85

Calls 3

ElementClass · 0.50
appendMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected