mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-15 13:48:09 +00:00
Start from project instead of unit assignment #5074
This commit is contained in:
@@ -697,12 +697,22 @@ void mapping::initialize_units_() {
|
|||||||
angle_unit_ = -1.;
|
angle_unit_ = -1.;
|
||||||
length_unit_name_ = "METER";
|
length_unit_name_ = "METER";
|
||||||
|
|
||||||
auto unit_assignments = file_->instances_by_type<IfcSchema::IfcUnitAssignment>();
|
#ifdef SCHEMA_HAS_IfcContext
|
||||||
if (unit_assignments->size() != 1) {
|
auto projects = file_->instances_by_type<IfcSchema::IfcContext>();
|
||||||
Logger::Warning("Not a single unit assignment in file");
|
#else
|
||||||
|
auto projects = file_->instances_by_type<IfcSchema::IfcProject>();
|
||||||
|
#endif
|
||||||
|
IfcSchema::IfcUnitAssignment* unit_assignment = nullptr;
|
||||||
|
if (projects->size() == 1) {
|
||||||
|
auto* project = *projects->begin();
|
||||||
|
unit_assignment = project->UnitsInContext();
|
||||||
|
} else {
|
||||||
|
Logger::Warning("Not a single project or context in file");
|
||||||
|
}
|
||||||
|
if (unit_assignment == nullptr) {
|
||||||
|
Logger::Warning("Unable to detect unit information");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto unit_assignment = *unit_assignments->begin();
|
|
||||||
|
|
||||||
bool length_unit_encountered = false, angle_unit_encountered = false;
|
bool length_unit_encountered = false, angle_unit_encountered = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user