From 7e55872ca838bb3e63f2fb8ee2d84c5dc42e29fe Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 13 Feb 2024 17:45:32 +0500 Subject: [PATCH] fix bugs in c5c7363a9 --- src/ifctester/ifctester/facet.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index 3dedb1b106..d57e56d06b 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -223,11 +223,11 @@ class Attribute(Facet): schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema) entities = {entity.name(): entity for entity in schema.entities()} - def ignore_subtypes(entity_name): - entity = entities[entity_name] - for entity in entity.subtypes(): - del entities[entity_name] - ignore_subtypes(entity) + def ignore_subtypes(entity): + for subentity in entity.subtypes(): + # entity might be already removed as .entities() order is not hierarchical + if entities.pop(subentity.name(), None): + ignore_subtypes(subentity) while entities: entity_name, entity = entities.popitem() @@ -235,8 +235,7 @@ class Attribute(Facet): if attribute.name() == self.name: results.extend(ifc_file.by_type(entity_name, include_subtypes=True)) # e.g. if IfcRoot already has .Name, it's safe not to check all it's subtypes attributes - ignore_subtypes(entity_name) - del entities[entity_name] + ignore_subtypes(entity) # TODO: perhaps we should consider value in the filter