mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-06 04:16:25 +00:00
Be a bit more forgiving in calculate unit scale to not glitch out on models with no project.
It's technically invalid but useful for small snippets.
This commit is contained in:
@@ -692,7 +692,7 @@ def calculate_unit_scale(ifc_file: ifcopenshell.file, unit_type: str = "LENGTHUN
|
|||||||
:returns: The scale factor
|
:returns: The scale factor
|
||||||
"""
|
"""
|
||||||
# Currently we assume that all ifc projects must have IfcProject.
|
# Currently we assume that all ifc projects must have IfcProject.
|
||||||
if not (units := ifc_file.by_type("IfcProject")[0].UnitsInContext):
|
if not (projects := ifc_file.by_type("IfcProject")) or not (units := projects[0].UnitsInContext):
|
||||||
return 1
|
return 1
|
||||||
unit_scale = 1
|
unit_scale = 1
|
||||||
for unit in units.Units:
|
for unit in units.Units:
|
||||||
|
|||||||
Reference in New Issue
Block a user