add to https://github.com/IfcOpenShell/IfcOpenShell/commit/57bc709b6fef6381bbb2810da15e568290c4a77a: Fix elevation display by converting from project units to meters on import

When importing spatial decomposition, get_storey_elevation() returns values in the project's unit system (e.g., feet), but format_distance() expects values in meters. Added unit_scale conversion (elevation * unit_scale) before formatting to ensure elevations display correctly regardless of project units.
This commit is contained in:
Ryan Schultz
2025-11-22 16:53:28 -06:00
parent 0d0b6cc6b2
commit bfd5b1bede
+3 -1
View File
@@ -496,7 +496,9 @@ class Spatial(bonsai.core.tool.Spatial):
new.long_name = element.LongName or ""
if not element.is_a("IfcProject"):
elevation = ifcopenshell.util.placement.get_storey_elevation(element)
new["elevation"] = tool.Unit.format_distance(elevation)
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
elevation_in_meters = elevation * unit_scale
new.elevation = tool.Unit.format_distance(elevation_in_meters)
new.is_expanded = element.id() not in cls.contracted_containers
new.level_index = level_index
children = ifcopenshell.util.element.get_parts(element)