diff --git a/src/blenderbim/blenderbim/tool/qto.py b/src/blenderbim/blenderbim/tool/qto.py index 68893fa661..7132618401 100644 --- a/src/blenderbim/blenderbim/tool/qto.py +++ b/src/blenderbim/blenderbim/tool/qto.py @@ -79,7 +79,16 @@ class Qto(blenderbim.core.tool.Qto): product.is_a(), ifcopenshell.util.element.get_predefined_type(product), qto_only=True ) # See https://github.com/buildingSMART/IFC4.3.x-development/issues/851 for anomalies in Qto naming - return next((qto_name for qto_name in applicable_qto_names if "Qto_" in qto_name), None) + applicable_qto: Union[str, None] = None + for qto_name in applicable_qto_names: + # No need for "Qto_" check since we use qto_only=True. + if "Base" in qto_name: + return qto_name + # Prioritize anomaly named base quantities over Qto_BodyGeometryValidation. + if applicable_qto and "BodyGeometryValidation" not in applicable_qto: + continue + applicable_qto = qto_name + return applicable_qto @classmethod def get_new_calculated_quantity(cls, qto_name: str, quantity_name: str, obj: bpy.types.Object) -> float: diff --git a/src/blenderbim/test/tool/test_qto.py b/src/blenderbim/test/tool/test_qto.py index e00f74618d..93a998e5e7 100644 --- a/src/blenderbim/test/tool/test_qto.py +++ b/src/blenderbim/test/tool/test_qto.py @@ -65,13 +65,26 @@ class TestGetApplicableBaseQuantityName(test.bim.bootstrap.NewFile): wall = ifc.createIfcWall() assert subject.get_applicable_base_quantity_name(wall) == "Qto_WallBaseQuantities" - def test_no_base_quantity(self): + def test_no_quantities(self): ifc = ifcopenshell.file() tool.Ifc.set(ifc) ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject") product = ifc.by_type("IfcProject")[0] assert subject.get_applicable_base_quantity_name(product) == None + def test_anomaly_named_quantities(self): + ifc = ifcopenshell.file() + tool.Ifc.set(ifc) + product = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcBuildingElementProxy") + # Prioritized over Qto_BodyGeometryValidation. + assert subject.get_applicable_base_quantity_name(product) == "Qto_BuildingElementProxyQuantities" + + def test_prioritize_base_over_other_qto(self): + ifc = ifcopenshell.file(schema="IFC4X3") + tool.Ifc.set(ifc) + product = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall") + assert subject.get_applicable_base_quantity_name(product) == "Qto_WallBaseQuantities" + class TestGetRoundedValue(test.bim.bootstrap.NewFile): def test_run(self):