diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index 88bed3c065..e88c637e17 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -122,9 +122,9 @@ public: static bool guid_map() { return guid_map_; } static void guid_map(bool b) { guid_map_ = b; } -private: typedef std::map entity_entity_map_t; +private: bool parsing_complete_; file_open_status good_ = file_open_status::SUCCESS; @@ -276,6 +276,8 @@ public: void recalculate_id_counter(); + entity_entity_map_t getEntityFileMapCopy() const; + IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity, int id=-1); void addEntities(aggregate_of_instance::ptr es); diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index d0ccb44aa6..d9d49fe164 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1839,6 +1839,14 @@ void IfcFile::addEntities(aggregate_of_instance::ptr es) { } } +IfcFile::entity_entity_map_t IfcFile::getEntityFileMapCopy() const { + std::map copy_map; + for (const auto& pair : entity_file_map) { + copy_map[pair.first] = pair.second; + } + return copy_map; +} + IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id) { if (id != -1 && byid.find((unsigned)id) != byid.end()) { throw IfcParse::IfcException("An instance with id " + boost::lexical_cast(id) + " is already part of this file"); diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index b9fcd5aadd..308f334772 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -593,6 +593,15 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas return f; } + PyObject* get_identity_mapping(IfcParse::IfcFile* f) { + PyObject* pyDict = PyDict_New(); + for (const auto& pair : f->getEntityFileMapCopy()) { + PyDict_SetItem(pyDict, pythonize(pair.first), pythonize(pair.second)); + } + + return pyDict; + } + const char* version() { return IFCOPENSHELL_VERSION; }