This commit is contained in:
Andrej730
2025-07-09 13:47:32 +05:00
parent 40f92d15c3
commit 5a4ad69bf7
30 changed files with 362 additions and 301 deletions
@@ -20,6 +20,7 @@ import math
import ifcopenshell
import ifcopenshell.util.unit
def station_as_string(file: ifcopenshell.file, sta: float):
"""
Returns a stringized version of a station. Example 100.0 is 1+00.00 as a stationing string.
@@ -28,18 +29,21 @@ def station_as_string(file: ifcopenshell.file, sta: float):
:param station: the station to be stringized
:return: stringized station
"""
unit_type = ifcopenshell.util.unit.get_project_unit(file,"LENGTHUNIT")
unit_type = ifcopenshell.util.unit.get_project_unit(file, "LENGTHUNIT")
if unit_type.is_a("IfcConversionBasedUnit"):
station = ifcopenshell.util.unit.convert(sta,from_unit=unit_type.Name,from_prefix=None,to_unit="foot",to_prefix=None)
station = ifcopenshell.util.unit.convert(
sta, from_unit=unit_type.Name, from_prefix=None, to_unit="foot", to_prefix=None
)
plus_seperator = 2
precision = 2
else:
station = ifcopenshell.util.unit.convert(sta,from_unit=unit_type.Name,from_prefix=unit_type.Prefix,to_unit="meter",to_prefix=None)
station = ifcopenshell.util.unit.convert(
sta, from_unit=unit_type.Name, from_prefix=unit_type.Prefix, to_unit="meter", to_prefix=None
)
plus_seperator = 3
precision = 3
value = math.fabs(station)
shifter = math.pow(10.0, plus_seperator)
@@ -48,7 +52,7 @@ def station_as_string(file: ifcopenshell.file, sta: float):
# Check to make sure that v2 is not basically the same as shifter
# If station = 69500.00000, we sometimes get 694+100.00 instead of 695+00.00
if math.isclose(v2-shifter, 0., abs_tol=5.0 * math.pow(10.0, -(precision + 1))):
if math.isclose(v2 - shifter, 0.0, abs_tol=5.0 * math.pow(10.0, -(precision + 1))):
v2 = 0.0
v1 += 1