mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 08:13:14 +00:00
don't assign ID to Simple types
When adding entities, don't assign ID to Simple types. Otherwise that type will be serialized incorrectly. This fixes the issue with IFCPLANEANGLEMEASURE being serilzed incorrectly when used as attribute to IFCMEASUREWITHUNIT. With ID assigned, it will look like this: #10=IFCMEASUREWITHUNIT(#9=IFCPLANEANGLEMEASURE(0.017453293),#8); The correct way to serialze is: #10=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.017453293),#8);
This commit is contained in:
+18
-16
@@ -1603,24 +1603,26 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int new_id = -1;
|
if (!IfcSchema::Type::IsSimple(new_entity->entity->type())) {
|
||||||
if (!new_entity->entity->file) {
|
int new_id = -1;
|
||||||
// For newly created entities ensure a valid ENTITY_INSTANCE_NAME is set
|
if (!new_entity->entity->file) {
|
||||||
new_entity->entity->file = this;
|
// For newly created entities ensure a valid ENTITY_INSTANCE_NAME is set
|
||||||
new_id = new_entity->entity->set_id();
|
new_entity->entity->file = this;
|
||||||
} else {
|
new_id = new_entity->entity->set_id();
|
||||||
new_id = new_entity->entity->id();
|
} else {
|
||||||
}
|
new_id = new_entity->entity->id();
|
||||||
|
}
|
||||||
|
|
||||||
if (byid.find(new_id) != byid.end()) {
|
if (byid.find(new_id) != byid.end()) {
|
||||||
// This should not happen
|
// This should not happen
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Overwriting entity with id " << new_id;
|
ss << "Overwriting entity with id " << new_id;
|
||||||
Logger::Message(Logger::LOG_WARNING, ss.str());
|
Logger::Message(Logger::LOG_WARNING, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// The mapping by entity instance name is updated.
|
// The mapping by entity instance name is updated.
|
||||||
byid[new_id] = new_entity;
|
byid[new_id] = new_entity;
|
||||||
|
}
|
||||||
|
|
||||||
// The mapping by reference is updated.
|
// The mapping by reference is updated.
|
||||||
IfcEntityList::ptr entity_attributes(new IfcEntityList);
|
IfcEntityList::ptr entity_attributes(new IfcEntityList);
|
||||||
|
|||||||
Reference in New Issue
Block a user