S
by Salamik on 13 Jun 2022, edited 17 Mar 2024
#
I have been testing ifcconvert. I managed to get .svg file out using commands suggested in previous forum post suggested here. The thing is all the storeys are in single .svg file on top of each other. My question is what is the best method to split them to their own file? For example should I split the ifc file itself so that it has only stuff related to single storey or did I miss some parameter which would allow this? I am wondering can I automate this process using ifcopenshell? Also I could probably automate this with solution like simple bim? I want to automate the process as much as possible... Thanks!
S
by Salamik on 14 Jun 2022
#
+1 votes
"Note that in the output SVG file, the elements are already grouped by their containing storey. Since SVG is in fact XML, it is absolutely trivial to write a small (say, Python) script that splits the file into separate files per storey. All it needs to do is copy the top-level <g> to empty xml documents." I found the answer, not super elegant but will work
A
by alfasst on 17 Mar 2024
#
@Salamik I tried this code. Works for most of the parts. Misses some parts.
filename = 'project.svg'
lines = open(filename).readlines()
storeys = [i for i,line in enumerate(lines) if 'IfcBuildingStorey' in line]
storeys.append(len(lines)-1)
init_parts = lines[:storeys[0]]
final_part = lines[-1]
storey_parts = [lines[storeys[i]:storeys[i+1]] for i in range(len(storeys)-1)]
for i,storey in enumerate(storey_parts):
svg_text = init_parts+storey+[final_part]
svg_text = ('').join(svg_text)
new_filename = filename.replace('.svg', f'_storey{i}.svg')
with open(new_filename, "w") as file:
file.write(svg_text)