From ecd72912aa4412ae7ba6dfb0bec4200bc3f2b761 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 26 Jan 2025 19:07:02 +1100 Subject: [PATCH] Purge constants from PR #5257. I'm not sure I agree here, considering that types are dynamic based on schema version. --- src/ifcopenshell-python/ifcopenshell/file.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/file.py b/src/ifcopenshell-python/ifcopenshell/file.py index e4de740ee9..12b778c159 100644 --- a/src/ifcopenshell-python/ifcopenshell/file.py +++ b/src/ifcopenshell-python/ifcopenshell/file.py @@ -33,8 +33,6 @@ from typing import Union from . import ifcopenshell_wrapper from .entity_instance import entity_instance -# from .util.constants import IFC_TYPES -from .util.constants import IFC_UNIT_ASSIGNMENT from .util.unit import get_measure_unit_type if TYPE_CHECKING: @@ -743,14 +741,10 @@ class file_units: A mapping as dictionary which associates to basic UnitTypes a unit-entity in the IFC file. """ - entities = self.by_type(IFC_UNIT_ASSIGNMENT) + entities = self.by_type("IfcUnitAssignment") base = next(iter(entities), None) units = getattr(base, "Units", None) or () - units_and_types = [ - (u, getattr(u, "UnitType", None)) - for u in units - if isinstance(u, entity_instance) - ] + units_and_types = [(u, getattr(u, "UnitType", None)) for u in units if isinstance(u, entity_instance)] self._unit_assignment = {t: u for u, t in units_and_types if isinstance(t, str)} return @@ -765,4 +759,4 @@ class file_units: Returns the unit entity associated to a measure type """ t = get_measure_unit_type(t) - return self.by_type(t) \ No newline at end of file + return self.by_type(t)