From 2336f299f742401c02a91e497bba8eda6bf005f2 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 11 Jan 2023 12:47:40 +0100 Subject: [PATCH] Implement typeof() on simple types --- .../ifcopenshell/express/rule_compiler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py b/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py index bbc66674fd..d20554a1b8 100644 --- a/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py +++ b/src/ifcopenshell-python/ifcopenshell/express/rule_compiler.py @@ -658,7 +658,14 @@ def typeof(inst): decl = ifcopenshell.ifcopenshell_wrapper.schema_by_name(schema_name).declaration_by_name(inst.is_a()) while decl: yield '.'.join((schema_name, decl.name().lower())) - decl = decl.supertype() + if isinstance(decl, ifcopenshell.ifcopenshell_wrapper.entity): + decl = decl.supertype() + else: + decl = decl.declared_type() + while isinstance(decl, ifcopenshell.ifcopenshell_wrapper.named_type): + decl = decl.declared_type() + if not isinstance(decl, ifcopenshell.ifcopenshell_wrapper.type_declaration): + break return express_set(inner()) """, file=output, sep='\n')