bim.perform_quantity_take_off - support fallback calculator in ifc4x3 too

This commit is contained in:
Andrej730
2025-03-14 10:56:23 +05:00
parent e038f968f2
commit 8ca344259f
3 changed files with 11 additions and 7 deletions
+1 -1
View File
@@ -191,7 +191,7 @@ class PerformQuantityTakeOff(bpy.types.Operator, tool.Ifc.Operator):
not_quantified_elements = run_quantification(props.qto_rule, elements)
if props.fallback and not_quantified_elements:
alternative_rules = next(rule for rule in ifc5d.qto.rules if rule != props.qto_rule)
alternative_rules = next(rule for rule in tool.Qto.get_qto_rules() if rule != props.qto_rule)
not_quantified_elements = run_quantification(alternative_rules, not_quantified_elements)
not_quantified_message = tool.Qto.get_not_quantified_elements_message(not_quantified_elements)
+1 -5
View File
@@ -38,12 +38,8 @@ CALCULATOR_FUNCTION_ENUM_ITEMS: list[Union[tuple[str, str, str], None]] = []
def get_qto_rule(self: "BIMQtoProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]:
ifc_file = tool.Ifc.get()
is_ifc4x3 = ifc_file.schema == "IFC4X3"
results: list[tuple[str, str, str]] = []
for rule_id, rule in ifc5d.qto.rules.items():
if rule_id.startswith("IFC4X3") != is_ifc4x3:
continue
for rule_id, rule in tool.Qto.get_qto_rules().items():
results.append((rule_id, rule["name"], rule["description"]))
return results
+9 -1
View File
@@ -25,7 +25,7 @@ import ifcopenshell
import ifcopenshell.util.unit
import ifcopenshell.util.element
from mathutils import Vector
from typing import Optional, Union, Literal, TYPE_CHECKING
from typing import Optional, Union, Literal, TYPE_CHECKING, Any
if TYPE_CHECKING:
from bonsai.bim.module.qto.prop import BIMQtoProperties
@@ -168,6 +168,14 @@ class Qto(bonsai.core.tool.Qto):
)
return result
@classmethod
def get_qto_rules(cls) -> dict[str, dict[str, Any]]:
import ifc5d.qto
ifc_file = tool.Ifc.get()
is_ifc4x3 = ifc_file.schema == "IFC4X3"
return {rule_id: rule for rule_id, rule in ifc5d.qto.rules.items() if rule_id.startswith("IFC4X3") == is_ifc4x3}
@classmethod
def get_not_quantified_elements_message(cls, not_quantified_elements: set[ifcopenshell.entity_instance]) -> str:
not_quantified_message = ""