This commit is contained in:
Andrej730
2024-10-28 11:11:39 +05:00
parent 92b63a0ef2
commit 7fef81c0b9
2 changed files with 9 additions and 10 deletions
+5 -3
View File
@@ -103,9 +103,7 @@ def draw_psetqto_ui(
filter_keyword: str = "",
) -> None:
active_operator = context.active_operator
filter_keyword = filter_keyword.lower()
box = layout.box()
@@ -204,7 +202,11 @@ def draw_psetqto_ui(
if active_operator:
if active_operator.bl_idname == "BIM_OT_select_similar":
calculated_sum = getattr(active_operator, "calculated_sum", 0.0)
if op.key == active_operator.key and calculated_sum != 0 and isinstance(float(nominal_value), (int, float)):
if (
op.key == active_operator.key
and calculated_sum != 0
and isinstance(float(nominal_value), (int, float))
):
row.label(text=f"(Sum: {calculated_sum})")
if not has_props_displayed:
row = box.row()
@@ -696,13 +696,12 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
bl_idname = "bim.select_similar"
bl_label = "Select Similar"
bl_options = {"REGISTER", "UNDO"}
bl_description = (
"Select objects with a similar value\n\n"
+ "SHIFT+CLICK display the sum of all selected objects"
)
bl_description = "Select objects with a similar value\n\n" + "SHIFT+CLICK display the sum of all selected objects"
key: bpy.props.StringProperty()
calculate_sum: bpy.props.BoolProperty(name="Calculate Sum of Selected Objects", default=False, options={"SKIP_SAVE"})
calculate_sum: bpy.props.BoolProperty(
name="Calculate Sum of Selected Objects", default=False, options={"SKIP_SAVE"}
)
calculated_sum: bpy.props.FloatProperty(name="Calculated Sum", default=0.0)
def invoke(self, context, event):
@@ -719,7 +718,6 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
key = "predefined_type"
value = ifcopenshell.util.selector.get_element_value(element, key)
if self.calculate_sum and isinstance(value, (int, float)):
total = 0
for obj in context.selected_objects:
@@ -740,4 +738,3 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
continue
if ifcopenshell.util.selector.get_element_value(element, key) == value:
obj.select_set(True)