From ea9e0c9ab4ccabf46bacad71ee7772cdad4c5e9b Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 25 Oct 2025 13:55:55 +0200 Subject: [PATCH] readInstancePy() option to obtain type decls instead of strings --- src/ifcwrap/IfcParseWrapper.i | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 8ecb879022..13e34b5575 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -1003,7 +1003,7 @@ private: %} %extend IfcParse::InstanceStreamer { - PyObject* readInstancePy() { + PyObject* readInstancePy(bool type_as_declaration_instance=false) { auto simply_type_to_dictionary = [&](IfcUtil::IfcBaseClass* t) -> PyObject* { const auto& nm = t->declaration().name(); auto ifc_val = t->get_attribute_value(0); @@ -1089,7 +1089,13 @@ private: { const std::string& key_cpp = "type"; auto name_py = pythonize(key_cpp); - auto value_py = pythonize(std::get<1>(*inst)->name()); + PyObject* value_py; + if (type_as_declaration_instance) { + // @todo should this just be the default behavior? + value_py = pythonize(std::get<1>(*inst)); + } else { + value_py = pythonize(std::get<1>(*inst)->name()); + } PyDict_SetItem(d, name_py, value_py); Py_DECREF(name_py); Py_DECREF(value_py);