From f61738112ece5a14f6f8679d9f85457abc2b8660 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 13 Feb 2024 12:25:32 +0500 Subject: [PATCH] ifctester Attribute.filter not to check subtypes attributes if attribute is already found in the super type --- src/ifctester/ifctester/facet.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index 4920b919d6..3dedb1b106 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -221,10 +221,22 @@ class Attribute(Facet): results = [] schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(ifc_file.schema) - for entity in schema.entities(): + 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) + + while entities: + entity_name, entity = entities.popitem() for attribute in entity.attributes(): if attribute.name() == self.name: - results.extend(ifc_file.by_type(entity.name(), include_subtypes=True)) + 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] # TODO: perhaps we should consider value in the filter