mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
bim.perform_quantity_take_off - support fallback calculator in ifc4x3 too
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 = ""
|
||||
|
||||
Reference in New Issue
Block a user