From 8c2e1226c9e884ccc0117a260c8af7e48ed53d42 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 15 Jan 2026 15:38:32 +0100 Subject: [PATCH] declaration property --- src/ifcopenshell-python/ifcopenshell/entity_instance.py | 4 +--- src/ifcwrap/IfcParseWrapper.i | 1 + src/ifcwrap/utils/typemaps_out.i | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index 6fe24baf15..121d0c6884 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -223,9 +223,7 @@ class entity_instance_mixin: :return: True if the instance is an entity """ - schema_name = self.is_a(True).split(".")[0] - decl = ifcopenshell_wrapper.schema_by_name(schema_name).declaration_by_name(self.is_a()) - return isinstance(decl, ifcopenshell_wrapper.entity) + return isinstance(self.declaration, ifcopenshell_wrapper.entity) def compare(self, other, op, reverse=False): """Compares with another instance. diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 9ad3fdf835..e7039b0f29 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -884,6 +884,7 @@ private: %pythoncode %{ file = property(file_py) + declaration = property(declaration) %} } diff --git a/src/ifcwrap/utils/typemaps_out.i b/src/ifcwrap/utils/typemaps_out.i index 8e9b8f1f0a..fe730d350c 100644 --- a/src/ifcwrap/utils/typemaps_out.i +++ b/src/ifcwrap/utils/typemaps_out.i @@ -6,6 +6,10 @@ $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), declaration_type_to_swig($1), 0); } +%typemap(out) const IfcParse::declaration& { + $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), declaration_type_to_swig($1), 0); +} + %typemap(out) IfcParse::parameter_type* { if ($1->as_named_type()) { $result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_named_type()), SWIGTYPE_p_IfcParse__named_type, 0);