Skip to content

Commit

Permalink
Make cha-ching noise whenever you're checking out cost schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
Moult committed Apr 26, 2021
1 parent 389076b commit 57396e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/blenderbim/blenderbim/bim/module/cost/operator.py
@@ -1,3 +1,4 @@
import os
import bpy
import json
import ifcopenshell.api
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 11 additions & 2 deletions src/blenderbim/blenderbim/bim/ui.py
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions src/ifcopenshell-python/ifcopenshell/api/cost/data.py
Expand Up @@ -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"]

Expand Down Expand Up @@ -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):
Expand Down

1 comment on commit 57396e1

@theoryshaw
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

Please sign in to comment.