Skip to content

Commit f6645b1

Browse files
elmiraothms
authored andcommitted
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: IfcOpenShell#10=IFCMEASUREWITHUNIT(IfcOpenShell#9=IFCPLANEANGLEMEASURE(0.017453293),IfcOpenShell#8); The correct way to serialze is: IfcOpenShell#10=IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(0.017453293),IfcOpenShell#8);
1 parent f2dbf7d commit f6645b1

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

src/ifcparse/IfcParse.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,24 +1603,26 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
16031603
}
16041604
}
16051605

1606-
int new_id = -1;
1607-
if (!new_entity->entity->file) {
1608-
// For newly created entities ensure a valid ENTITY_INSTANCE_NAME is set
1609-
new_entity->entity->file = this;
1610-
new_id = new_entity->entity->set_id();
1611-
} else {
1612-
new_id = new_entity->entity->id();
1613-
}
1606+
if (!IfcSchema::Type::IsSimple(new_entity->entity->type())) {
1607+
int new_id = -1;
1608+
if (!new_entity->entity->file) {
1609+
// For newly created entities ensure a valid ENTITY_INSTANCE_NAME is set
1610+
new_entity->entity->file = this;
1611+
new_id = new_entity->entity->set_id();
1612+
} else {
1613+
new_id = new_entity->entity->id();
1614+
}
16141615

1615-
if (byid.find(new_id) != byid.end()) {
1616-
// This should not happen
1617-
std::stringstream ss;
1618-
ss << "Overwriting entity with id " << new_id;
1619-
Logger::Message(Logger::LOG_WARNING, ss.str());
1620-
}
1616+
if (byid.find(new_id) != byid.end()) {
1617+
// This should not happen
1618+
std::stringstream ss;
1619+
ss << "Overwriting entity with id " << new_id;
1620+
Logger::Message(Logger::LOG_WARNING, ss.str());
1621+
}
16211622

1622-
// The mapping by entity instance name is updated.
1623-
byid[new_id] = new_entity;
1623+
// The mapping by entity instance name is updated.
1624+
byid[new_id] = new_entity;
1625+
}
16241626

16251627
// The mapping by reference is updated.
16261628
IfcEntityList::ptr entity_attributes(new IfcEntityList);

0 commit comments

Comments
 (0)