mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Quantity take-off - add a fallback option #5899
If current set of rules (e.g. IfcOpenShell) doesn't provide a way to quantify some type of element, then user now have an option to fallback to other calculator (Blender). Location - https://i.imgur.com/csIPOuo.png
This commit is contained in:
@@ -378,8 +378,10 @@ class BIM_PT_object_qtos(Panel):
|
||||
)
|
||||
layout = self.layout
|
||||
qtoprops = context.scene.BIMQtoProperties
|
||||
row = layout.row()
|
||||
row = layout.row(align=True)
|
||||
row.prop(qtoprops, "qto_rule", text="")
|
||||
# A bit confusing as we typically use this icon for is_null.
|
||||
row.prop(qtoprops, "fallback", text="", icon="RADIOBUT_ON" if qtoprops.fallback else "RADIOBUT_OFF")
|
||||
row = layout.row()
|
||||
row.operator("bim.perform_quantity_take_off")
|
||||
|
||||
|
||||
@@ -176,12 +176,20 @@ class PerformQuantityTakeOff(bpy.types.Operator, tool.Ifc.Operator):
|
||||
else:
|
||||
elements = set(tool.Ifc.get().by_type("IfcElement"))
|
||||
|
||||
rules = ifc5d.qto.rules[props.qto_rule]
|
||||
def run_quantification(
|
||||
rule: str, elements: set[ifcopenshell.entity_instance]
|
||||
) -> set[ifcopenshell.entity_instance]:
|
||||
rules = ifc5d.qto.rules[rule]
|
||||
ifc_file = tool.Ifc.get()
|
||||
results = ifc5d.qto.quantify(ifc_file, elements, rules)
|
||||
ifc5d.qto.edit_qtos(ifc_file, results)
|
||||
not_quantified_elements = elements - set(results.keys())
|
||||
return not_quantified_elements
|
||||
|
||||
ifc_file = tool.Ifc.get()
|
||||
results = ifc5d.qto.quantify(ifc_file, elements, rules)
|
||||
not_quantified_elements = elements - set(results.keys())
|
||||
ifc5d.qto.edit_qtos(ifc_file, results)
|
||||
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)
|
||||
not_quantified_elements = run_quantification(alternative_rules, not_quantified_elements)
|
||||
|
||||
not_quantified_message = ""
|
||||
if not_quantified_elements:
|
||||
|
||||
@@ -67,3 +67,11 @@ class BIMQtoProperties(PropertyGroup):
|
||||
qto_result: StringProperty(default="", name="Qto Result")
|
||||
qto_name: StringProperty(name="Qto Name", default="My_Qto")
|
||||
prop_name: StringProperty(name="Prop Name", default="MyDimension")
|
||||
fallback: BoolProperty(
|
||||
name="Fallback To Other Calculators",
|
||||
description=(
|
||||
"If currently selected calculator does not support quantitication "
|
||||
"of some class/property, to try other available calculators."
|
||||
),
|
||||
default=False,
|
||||
)
|
||||
|
||||
@@ -41,6 +41,7 @@ class BIM_PT_qto(bpy.types.Panel):
|
||||
row.label(text="Quantifying All Objects", icon="MOD_EDGESPLIT")
|
||||
row = layout.row()
|
||||
row.prop(props, "qto_rule", text="")
|
||||
row.prop(props, "fallback", text="", icon="RADIOBUT_ON" if props.fallback else "RADIOBUT_OFF")
|
||||
row = layout.row()
|
||||
row.operator("bim.perform_quantity_take_off")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user