Add ifcopenshell.util.unit.mm_to_m helper

Centralises the millimetre-to-metre conversion shortcut that
add_door_representation and add_window_representation each defined
locally. Subsequent commits in this PR switch both call sites to
import this from util.unit, removing the duplicate definitions.

Generated with the assistance of an AI coding tool.
This commit is contained in:
Gorgious56
2026-05-26 16:57:49 +02:00
parent 45ea5eb07a
commit 936526b41b
2 changed files with 16 additions and 0 deletions
@@ -644,6 +644,11 @@ def convert_unit(value: float, from_unit: ifcopenshell.entity_instance, to_unit:
)
def mm_to_m(value: float) -> float:
"""Convert a millimetre value to metres."""
return value / 1000
def convert(value: float, from_prefix: Optional[str], from_unit: str, to_prefix: Optional[str], to_unit: str) -> float:
"""Converts between length, area, and volume units