From 57396e1bb993c690d26c64b861a09bce6787bf23 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 26 Apr 2021 18:46:35 +1000 Subject: [PATCH] Make cha-ching noise whenever you're checking out cost schedules --- .../blenderbim/bim/module/cost/operator.py | 16 ++++++++++++++++ src/blenderbim/blenderbim/bim/ui.py | 13 +++++++++++-- .../ifcopenshell/api/cost/data.py | 2 -- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/cost/operator.py b/src/blenderbim/blenderbim/bim/module/cost/operator.py index c40f70d0e3a..6c3c96660f0 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/operator.py +++ b/src/blenderbim/blenderbim/bim/module/cost/operator.py @@ -1,3 +1,4 @@ +import os import bpy import json import ifcopenshell.api @@ -98,6 +99,21 @@ class EnableEditingCostItems(bpy.types.Operator): cost_schedule: bpy.props.IntProperty() def execute(self, context): + if context.preferences.addons["blenderbim"].preferences.should_play_chaching_sound: + # lol + # TODO: make pitch higher as costs rise + try: + import aud + + device = aud.Device() + sound = aud.Sound(os.path.join(context.scene.BIMProperties.data_dir, "chaching.mp3")) + handle = device.play(sound) + sound_buffered = aud.Sound.buffer(sound) + handle_buffered = device.play(sound_buffered) + handle.stop() + handle_buffered.stop() + except: + pass # ah well self.props = context.scene.BIMCostProperties self.props.active_cost_schedule_id = self.cost_schedule while len(self.props.cost_items) > 0: diff --git a/src/blenderbim/blenderbim/bim/ui.py b/src/blenderbim/blenderbim/bim/ui.py index 903f1788c4b..c156781431f 100644 --- a/src/blenderbim/blenderbim/bim/ui.py +++ b/src/blenderbim/blenderbim/bim/ui.py @@ -190,13 +190,22 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences): svg_command: StringProperty(name="SVG Command", description="E.g. [['firefox-bin', path]]") pdf_command: StringProperty(name="PDF Command", description="E.g. [['firefox-bin', path]]") should_hide_empty_props: BoolProperty(name="Should Hide Empty Properties", default=True) + should_play_chaching_sound: BoolProperty( + name="Should Make A Cha-Ching Sound When Project Costs Updates", default=False + ) def draw(self, context): layout = self.layout row = layout.row() - row.label(text="To upgrade, first uninstall your current BlenderBIM Add-on, then install the new version.", icon="ERROR") + row.label( + text="To upgrade, first uninstall your current BlenderBIM Add-on, then install the new version.", + icon="ERROR", + ) row = layout.row() - row.label(text="To uninstall, first disable the add-on. Then restart Blender before pressing the 'Remove' button.", icon="ERROR") + row.label( + text="To uninstall, first disable the add-on. Then restart Blender before pressing the 'Remove' button.", + icon="ERROR", + ) row = layout.row() row.operator("bim.open_upstream", text="Visit Homepage").page = "home" row.operator("bim.open_upstream", text="Visit Documentation").page = "docs" diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/data.py b/src/ifcopenshell-python/ifcopenshell/api/cost/data.py index 79c63ec76aa..3fe3ff51cc3 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/data.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/data.py @@ -72,7 +72,6 @@ def load_cost_item_values(cls, cost_item, data): for cost_value in cost_item.CostValues or []: cls.load_cost_item_value(cost_item, cost_value) data["CostValues"].append(cost_value.id()) - print('applied value is', cls.cost_values[cost_value.id()]["AppliedValue"]) data["TotalAppliedValue"] += cls.cost_values[cost_value.id()]["AppliedValue"] data["TotalCostValue"] = data["TotalCostQuantity"] * data["TotalAppliedValue"] @@ -127,7 +126,6 @@ def get_total_quantity(cls, cost_item): @classmethod def get_primitive_applied_value(cls, applied_value): - print('applied value is ', applied_value) if not applied_value: return 0.0 elif isinstance(applied_value, float):