mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
#2244 file.add() Don't fail on project without unit info
This commit is contained in:
@@ -1858,8 +1858,12 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
|||||||
we->setArgument(i, copy);
|
we->setArgument(i, copy);
|
||||||
} else if (decl && decl->is(*schema()->declaration_by_name("IfcLengthMeasure"))) {
|
} else if (decl && decl->is(*schema()->declaration_by_name("IfcLengthMeasure"))) {
|
||||||
if (boost::math::isnan(conversion_factor)) {
|
if (boost::math::isnan(conversion_factor)) {
|
||||||
const std::pair<IfcUtil::IfcBaseClass*, double> this_file_unit = getUnit("LENGTHUNIT");
|
std::pair<IfcUtil::IfcBaseClass*, double> this_file_unit = { nullptr, 1.0 };
|
||||||
const std::pair<IfcUtil::IfcBaseClass*, double> other_file_unit = other_file->getUnit("LENGTHUNIT");
|
std::pair<IfcUtil::IfcBaseClass*, double> other_file_unit = { nullptr, 1.0 };
|
||||||
|
try {
|
||||||
|
this_file_unit = getUnit("LENGTHUNIT");
|
||||||
|
other_file_unit = other_file->getUnit("LENGTHUNIT");
|
||||||
|
} catch (IfcParse::IfcException&) {}
|
||||||
if (this_file_unit.first && other_file_unit.first) {
|
if (this_file_unit.first && other_file_unit.first) {
|
||||||
conversion_factor = other_file_unit.second / this_file_unit.second;
|
conversion_factor = other_file_unit.second / this_file_unit.second;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user