From 605a29786c05adecf24a3056c19e1c086b430ad0 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 22 Jan 2025 18:24:47 +0500 Subject: [PATCH] Fix tests after 7b62b03 Since calculate_unit_scale now requires a project. def calculate_unit_scale(ifc_file: ifcopenshell.file, unit_type: str = "LENGTHUNIT") -> float: """Returns a unit scale factor to convert to and from IFC project units and SI units. Example: .. code:: python ifc_project_length * unit_scale = si_meters si_meters / unit_scale = ifc_project_length :param ifc_file: The IFC file. :param unit_type: The type of SI unit, defaults to "LENGTHUNIT" :returns: The scale factor """ > if not (units := ifc_file.by_type("IfcProject")[0].UnitsInContext): E IndexError: list index out of range --- src/ifcopenshell-python/test/api/project/test_append_asset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ifcopenshell-python/test/api/project/test_append_asset.py b/src/ifcopenshell-python/test/api/project/test_append_asset.py index e0402f75e5..07679888a0 100644 --- a/src/ifcopenshell-python/test/api/project/test_append_asset.py +++ b/src/ifcopenshell-python/test/api/project/test_append_asset.py @@ -115,6 +115,7 @@ class TestAppendAssetIFC2X3(test.bootstrap.IFC2X3): def test_append_two_type_products_sharing_the_same_material_indirectly_via_a_material_set(self): library = ifcopenshell.api.project.create_file(version=self.file.schema) + ifcopenshell.api.root.create_entity(library, "IfcProject") element1 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType") element2 = ifcopenshell.api.root.create_entity(library, ifc_class="IfcWallType") material = ifcopenshell.api.material.add_material(library, name="Material")