mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Implement rounding of elevation (#5532)
* Implement rounding of elevation Implement rounding of elevation based on precision stored in IfcGeometricRepresentationContext * Move formating function to tool
This commit is contained in:
@@ -35,6 +35,7 @@ import bonsai.core.tool
|
|||||||
import bonsai.core.root
|
import bonsai.core.root
|
||||||
import bonsai.core.spatial
|
import bonsai.core.spatial
|
||||||
import bonsai.core.geometry
|
import bonsai.core.geometry
|
||||||
|
import bonsai.core.unit
|
||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
import json
|
import json
|
||||||
from math import pi
|
from math import pi
|
||||||
@@ -452,7 +453,8 @@ class Spatial(bonsai.core.tool.Spatial):
|
|||||||
new.description = element.Description or ""
|
new.description = element.Description or ""
|
||||||
new.long_name = element.LongName or ""
|
new.long_name = element.LongName or ""
|
||||||
if not element.is_a("IfcProject"):
|
if not element.is_a("IfcProject"):
|
||||||
new["elevation"] = str(ifcopenshell.util.placement.get_storey_elevation(element))
|
elevation = ifcopenshell.util.placement.get_storey_elevation(element)
|
||||||
|
new["elevation"] = tool.Unit.format_value(elevation)
|
||||||
new.is_expanded = element.id() not in cls.contracted_containers
|
new.is_expanded = element.id() not in cls.contracted_containers
|
||||||
new.level_index = level_index
|
new.level_index = level_index
|
||||||
children = ifcopenshell.util.element.get_parts(element)
|
children = ifcopenshell.util.element.get_parts(element)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import json
|
import json
|
||||||
|
import math
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import bonsai.bim.helper
|
import bonsai.bim.helper
|
||||||
import bonsai.core.tool
|
import bonsai.core.tool
|
||||||
@@ -182,3 +183,13 @@ class Unit(bonsai.core.tool.Unit):
|
|||||||
precision=4,
|
precision=4,
|
||||||
split_unit=bpy.context.scene.unit_settings.system == "IMPERIAL",
|
split_unit=bpy.context.scene.unit_settings.system == "IMPERIAL",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def format_value(cls, value: float) -> str:
|
||||||
|
precision = tool.Ifc.get().by_type("IfcGeometricRepresentationContext")[0].Precision
|
||||||
|
if precision:
|
||||||
|
decimal_places = math.ceil(math.log10(1/precision))
|
||||||
|
else:
|
||||||
|
precision = 1e-5
|
||||||
|
decimal_places = 5
|
||||||
|
return str(round(precision * round(value / precision), decimal_places))
|
||||||
|
|||||||
Reference in New Issue
Block a user