Skip to content

Commit 2f0ce53

Browse files
committed
Cast to IFC value type and minor changes
1 parent 5daeb8a commit 2f0ce53

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

mvd.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ def extract_data(mvd_node, ifc_data):
7171
on_node = child.attribute[0].c
7272
on_node = on_node.replace("'", "")
7373
if isinstance(ifc_data, ifcopenshell.entity_instance):
74-
if str(ifc_data[0]) == on_node:
74+
ifc_type = type(ifc_data[0])
75+
typed_node = (ifc_type)(on_node)
76+
77+
if ifc_data[0] == typed_node:
7578
return [{mvd_node: ifc_data}]
7679

7780
elif ifc_data == on_node:
@@ -95,6 +98,7 @@ def open_mvd(filename):
9598
my_concept_object = list(ifcopenshell.mvd.concept_root.parse(filename))[0]
9699
return my_concept_object
97100

101+
98102
def format_data_from_nodes(recurse_output):
99103
"""
100104
Enable to format data collected such that the value to be exported is extracted.
@@ -256,7 +260,6 @@ def get_data(mvd_concept, ifc_file, spreadsheet_export=True):
256260
257261
"""
258262

259-
260263
# Check if IFC entities have been filtered at least once
261264
filtered = 0
262265

@@ -296,10 +299,9 @@ def get_data(mvd_concept, ifc_file, spreadsheet_export=True):
296299
val = 0
297300
if entity in not_respecting_entities:
298301
val = 1
299-
verification_matrix[entity.GlobalId].update({concept.name:val})
302+
verification_matrix[entity.GlobalId].update({concept.name: val})
300303
counter += 1
301304

302-
303305
all_data = correct_for_export(all_data)
304306

305307
if spreadsheet_export:
@@ -310,32 +312,18 @@ def get_data(mvd_concept, ifc_file, spreadsheet_export=True):
310312
export_to_xlsx(export_name + '.xlsx', concepts, all_data)
311313
export_to_csv(export_name + '.csv', concepts, all_data)
312314

313-
if filtered:
314-
filtered_entities = []
315-
for k,v in verification_matrix.items():
316-
# print("K", k)
317-
ent = ifc_file.by_id(k)
318-
# print(ent)
319-
# print("V ",v)
320-
sum_result = 0
321-
if sum(v.values()) > 0:
322-
filtered_entities.append(ent)
323-
# print(filtered_entities)
324-
325-
return (all_data, verification_matrix)
326-
327315

316+
return all_data, verification_matrix
328317

329318

330319
def get_non_respecting_entities(file, verification_matrix):
331320
non_respecting = []
332-
for k,v in verification_matrix.items():
321+
for k, v in verification_matrix.items():
333322
entity = file.by_id(k)
334323
print(list(v.values()))
335324
if sum(v.values()) != 0:
336325
non_respecting.append(entity)
337326

338-
print(non_respecting)
339327
return non_respecting
340328

341329

@@ -358,11 +346,16 @@ def visualize(file, not_respecting_entities):
358346

359347
entity_type = not_respecting_entities[0].is_a()
360348

361-
set_to_display = set(not_respecting_entities)|set(file.by_type(entity_type))
349+
other_entities = [x for x in file.by_type("IfcBuildingElement") if x.is_a() != str(entity_type)]
350+
351+
set_of_entities = set(not_respecting_entities) | set(file.by_type(entity_type))
352+
set_to_display = set_of_entities.union(set(other_entities))
362353

363354
for el in set_to_display:
364355
if el in not_respecting_entities:
365-
c = (1, 0.3, 0, 1)
356+
c = (1, 0, 0, 1)
357+
elif el in other_entities:
358+
c = (1, 1, 1, 0)
366359
else:
367360
c = (0, 1, 0.5, 1)
368361

0 commit comments

Comments
 (0)