mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
calculate_unit_scale - small optimization
This commit is contained in:
@@ -697,11 +697,12 @@ def calculate_unit_scale(ifc_file: ifcopenshell.file, unit_type: str = "LENGTHUN
|
|||||||
unit_scale = 1
|
unit_scale = 1
|
||||||
unit: ifcopenshell.entity_instance
|
unit: ifcopenshell.entity_instance
|
||||||
for unit in units.Units:
|
for unit in units.Units:
|
||||||
if not hasattr(unit, "UnitType") or unit.UnitType != unit_type:
|
if getattr(unit, "UnitType", ...) != unit_type:
|
||||||
continue
|
continue
|
||||||
while unit.is_a("IfcConversionBasedUnit"):
|
while unit.is_a("IfcConversionBasedUnit"):
|
||||||
unit_scale *= unit.ConversionFactor.ValueComponent.wrappedValue
|
conversion_factor = unit.ConversionFactor
|
||||||
unit = unit.ConversionFactor.UnitComponent
|
unit_scale *= conversion_factor.ValueComponent.wrappedValue
|
||||||
|
unit = conversion_factor.UnitComponent
|
||||||
if unit.is_a("IfcSIUnit"):
|
if unit.is_a("IfcSIUnit"):
|
||||||
unit_scale *= get_prefix_multiplier(unit.Prefix)
|
unit_scale *= get_prefix_multiplier(unit.Prefix)
|
||||||
return unit_scale
|
return unit_scale
|
||||||
|
|||||||
Reference in New Issue
Block a user