mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
You can now review and assign currencies from the Cost Schedule Panel
This commit is contained in:
@@ -77,6 +77,7 @@ classes = (
|
|||||||
operator.LoadCostItemResourceQuantities,
|
operator.LoadCostItemResourceQuantities,
|
||||||
operator.ChangeParentCostItem,
|
operator.ChangeParentCostItem,
|
||||||
operator.CopyCostItem,
|
operator.CopyCostItem,
|
||||||
|
operator.AddCurrency,
|
||||||
prop.CostItem,
|
prop.CostItem,
|
||||||
prop.CostItemQuantity,
|
prop.CostItemQuantity,
|
||||||
prop.CostItemType,
|
prop.CostItemType,
|
||||||
|
|||||||
@@ -740,3 +740,12 @@ class ChangeParentCostItem(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if isinstance(r, str):
|
if isinstance(r, str):
|
||||||
self.report({"WARNING"}, r)
|
self.report({"WARNING"}, r)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class AddCurrency(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
|
bl_idname = "bim.add_currency"
|
||||||
|
bl_label = "Add Currency"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
core.add_currency(tool.Ifc, tool.Cost)
|
||||||
|
|||||||
@@ -115,6 +115,27 @@ def get_schedule_predefined_types(self, context):
|
|||||||
return CostSchedulesData.data["predefined_types"]
|
return CostSchedulesData.data["predefined_types"]
|
||||||
|
|
||||||
|
|
||||||
|
def get_currencies(self, context):
|
||||||
|
return [
|
||||||
|
("USD", "USD", "Dollar"),
|
||||||
|
("EUR", "EUR", "Euro"),
|
||||||
|
("GBP", "GBP", "Pound"),
|
||||||
|
("AUD", "AUD", "Australian Dollar"),
|
||||||
|
("CAD", "CAD", "Canadian Dollar"),
|
||||||
|
("CHF", "CHF", "Swiss Franc"),
|
||||||
|
("CNY", "CNY", "Chinese Yuan"),
|
||||||
|
("HKD", "HKD", "Hong Kong Dollar"),
|
||||||
|
("JPY", "JPY", "Japanese Yen"),
|
||||||
|
("NZD", "NZD", "New Zealand Dollar"),
|
||||||
|
("SEK", "SEK", "Swedish Krona"),
|
||||||
|
("KRW", "KRW", "South Korean Won"),
|
||||||
|
("SGD", "SGD", "Singapore Dollar"),
|
||||||
|
("NOK", "NOK", "Norwegian Krone"),
|
||||||
|
("MAD", "MAD", "Moroccan Dirham"),
|
||||||
|
("CUSTOM", "Custom currency", "Custom"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class CostItem(PropertyGroup):
|
class CostItem(PropertyGroup):
|
||||||
name: StringProperty(name="Name", update=update_cost_item_name)
|
name: StringProperty(name="Name", update=update_cost_item_name)
|
||||||
identification: StringProperty(name="Identification", update=update_cost_item_identification)
|
identification: StringProperty(name="Identification", update=update_cost_item_identification)
|
||||||
@@ -190,6 +211,7 @@ class BIMCostProperties(PropertyGroup):
|
|||||||
cost_value_formula: StringProperty(name="Cost Value Formula")
|
cost_value_formula: StringProperty(name="Cost Value Formula")
|
||||||
cost_column: StringProperty(name="Cost Column")
|
cost_column: StringProperty(name="Cost Column")
|
||||||
should_show_column_ui: BoolProperty(name="Should Show Column UI", default=False)
|
should_show_column_ui: BoolProperty(name="Should Show Column UI", default=False)
|
||||||
|
should_show_currency_ui: BoolProperty(name="Should Show Currency UI", default=False)
|
||||||
columns: CollectionProperty(name="Columns", type=StrProperty)
|
columns: CollectionProperty(name="Columns", type=StrProperty)
|
||||||
active_column_index: IntProperty(name="Active Column Index")
|
active_column_index: IntProperty(name="Active Column Index")
|
||||||
cost_item_products: CollectionProperty(name="Cost Item Products", type=CostItemQuantity)
|
cost_item_products: CollectionProperty(name="Cost Item Products", type=CostItemQuantity)
|
||||||
@@ -216,3 +238,7 @@ class BIMCostProperties(PropertyGroup):
|
|||||||
)
|
)
|
||||||
change_cost_item_parent: BoolProperty(name="Change Cost Item Parent", default=False, update=update_cost_item_parent)
|
change_cost_item_parent: BoolProperty(name="Change Cost Item Parent", default=False, update=update_cost_item_parent)
|
||||||
show_cost_item_operators: BoolProperty(name="Show Cost Item Operators", default=False)
|
show_cost_item_operators: BoolProperty(name="Show Cost Item Operators", default=False)
|
||||||
|
currency: EnumProperty(items=get_currencies, name="Currencies")
|
||||||
|
custom_currency: StringProperty(
|
||||||
|
name="Custom Currency", default="USD", description="Custom Currency in ISO 4217 format"
|
||||||
|
)
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ class BIM_PT_cost_schedules(Panel):
|
|||||||
row1.label(text="Settings")
|
row1.label(text="Settings")
|
||||||
row1 = col.row(align=True)
|
row1 = col.row(align=True)
|
||||||
row1.alignment = "RIGHT"
|
row1.alignment = "RIGHT"
|
||||||
|
row1.prop(self.props, "should_show_currency_ui", text="Project Currency", icon="COPY_ID")
|
||||||
row1.prop(self.props, "should_show_column_ui", text="Schedule Columns", icon="SHORTDISPLAY")
|
row1.prop(self.props, "should_show_column_ui", text="Schedule Columns", icon="SHORTDISPLAY")
|
||||||
if self.props.is_editing == "COST_SCHEDULE_ATTRIBUTES":
|
if self.props.is_editing == "COST_SCHEDULE_ATTRIBUTES":
|
||||||
row.operator("bim.edit_cost_schedule", text="", icon="CHECKMARK")
|
row.operator("bim.edit_cost_schedule", text="", icon="CHECKMARK")
|
||||||
@@ -102,6 +103,8 @@ class BIM_PT_cost_schedules(Panel):
|
|||||||
elif self.props.is_editing == "COST_ITEMS":
|
elif self.props.is_editing == "COST_ITEMS":
|
||||||
if self.props.should_show_column_ui:
|
if self.props.should_show_column_ui:
|
||||||
self.draw_column_ui()
|
self.draw_column_ui()
|
||||||
|
if self.props.should_show_currency_ui:
|
||||||
|
self.draw_currency_ui()
|
||||||
self.draw_editable_cost_item_ui()
|
self.draw_editable_cost_item_ui()
|
||||||
|
|
||||||
def draw_column_ui(self):
|
def draw_column_ui(self):
|
||||||
@@ -110,6 +113,20 @@ class BIM_PT_cost_schedules(Panel):
|
|||||||
row.operator("bim.add_cost_column", text="", icon="ADD").name = self.props.cost_column
|
row.operator("bim.add_cost_column", text="", icon="ADD").name = self.props.cost_column
|
||||||
self.layout.template_list("BIM_UL_cost_columns", "", self.props, "columns", self.props, "active_column_index")
|
self.layout.template_list("BIM_UL_cost_columns", "", self.props, "columns", self.props, "active_column_index")
|
||||||
|
|
||||||
|
def draw_currency_ui(self):
|
||||||
|
row = self.layout.row(align=True)
|
||||||
|
if CostSchedulesData.data["currency"]:
|
||||||
|
text = "Currency used: {}".format(CostSchedulesData.data["currency"]["name"])
|
||||||
|
row.label(text=text)
|
||||||
|
row.operator("bim.remove_unit", text="", icon="X").unit = CostSchedulesData.data["currency"]["id"]
|
||||||
|
else:
|
||||||
|
row.label(text="No currency set")
|
||||||
|
row.prop(self.props, "currency", text="")
|
||||||
|
if self.props.currency == "CUSTOM":
|
||||||
|
row.alignment = "RIGHT"
|
||||||
|
row.prop(self.props, "custom_currency", text="")
|
||||||
|
row.operator("bim.add_currency", text="", icon="ADD")
|
||||||
|
|
||||||
def draw_editable_cost_schedule_ui(self):
|
def draw_editable_cost_schedule_ui(self):
|
||||||
blenderbim.bim.helper.draw_attributes(self.props.cost_schedule_attributes, self.layout)
|
blenderbim.bim.helper.draw_attributes(self.props.cost_schedule_attributes, self.layout)
|
||||||
|
|
||||||
@@ -620,9 +637,9 @@ class BIM_UL_cost_items_trait:
|
|||||||
text = "{0:,.2f}".format(cost_item["TotalAppliedValue"]).replace(",", " ")
|
text = "{0:,.2f}".format(cost_item["TotalAppliedValue"]).replace(",", " ")
|
||||||
if cost_item["UnitBasisValueComponent"] not in [None, 1]:
|
if cost_item["UnitBasisValueComponent"] not in [None, 1]:
|
||||||
text = "{} / {}".format(text, round(cost_item["UnitBasisValueComponent"], 2))
|
text = "{} / {}".format(text, round(cost_item["UnitBasisValueComponent"], 2))
|
||||||
text = "{} {}".format(text, cost_item["Currency"]) if cost_item["Currency"] else text
|
|
||||||
currency = CostSchedulesData.data["currency"]
|
currency = CostSchedulesData.data["currency"]
|
||||||
layout.label(text="{} {}".format(text, currency["name"]) if currency else text)
|
text = "{} {}".format(text, currency["name"]) if currency else text
|
||||||
|
layout.label(text=text)
|
||||||
else:
|
else:
|
||||||
layout.label(text="-")
|
layout.label(text="-")
|
||||||
|
|
||||||
@@ -645,6 +662,7 @@ class BIM_UL_cost_items_trait:
|
|||||||
label = "{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}"
|
label = "{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}"
|
||||||
layout.label(text=label)
|
layout.label(text=label)
|
||||||
else:
|
else:
|
||||||
|
layout.label(text="-")
|
||||||
# if cost_item["DerivedTotalCostQuantity"] not in [None, 0]:
|
# if cost_item["DerivedTotalCostQuantity"] not in [None, 0]:
|
||||||
# layout.label(text="{0:.2f}".format(cost_item["DerivedTotalCostQuantity"]) + f" {cost_item['DerivedUnitSymbol'] or '-'}")
|
# layout.label(text="{0:.2f}".format(cost_item["DerivedTotalCostQuantity"]) + f" {cost_item['DerivedUnitSymbol'] or '-'}")
|
||||||
# else:
|
# else:
|
||||||
|
|||||||
@@ -285,3 +285,10 @@ def copy_cost_item(ifc, cost):
|
|||||||
cost_item = ifc.run("cost.copy_cost_item", cost_item=cost_item)
|
cost_item = ifc.run("cost.copy_cost_item", cost_item=cost_item)
|
||||||
cost.disable_editing_cost_item_parent()
|
cost.disable_editing_cost_item_parent()
|
||||||
cost.load_cost_schedule_tree()
|
cost.load_cost_schedule_tree()
|
||||||
|
|
||||||
|
def add_currency(ifc, cost):
|
||||||
|
unit = ifc.run("unit.add_monetary_unit")
|
||||||
|
attributes = cost.get_currency_attributes()
|
||||||
|
ifc.run("unit.edit_monetary_unit", unit=unit, attributes=attributes)
|
||||||
|
ifc.run("unit.assign_unit", units=[unit])
|
||||||
|
return unit
|
||||||
@@ -867,6 +867,8 @@ class Unit:
|
|||||||
def is_scene_unit_metric(cls): pass
|
def is_scene_unit_metric(cls): pass
|
||||||
def is_unit_class(cls, unit, ifc_class): pass
|
def is_unit_class(cls, unit, ifc_class): pass
|
||||||
def set_active_unit(cls, unit): pass
|
def set_active_unit(cls, unit): pass
|
||||||
|
def get_project_currency_unit(cls): pass
|
||||||
|
def get_currency_name(cls): pass
|
||||||
|
|
||||||
|
|
||||||
@interface
|
@interface
|
||||||
|
|||||||
@@ -692,3 +692,13 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def has_schedules(cls):
|
def has_schedules(cls):
|
||||||
return bool(tool.Ifc.get().by_type("IfcCostSchedule"))
|
return bool(tool.Ifc.get().by_type("IfcCostSchedule"))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_currency_attributes(cls):
|
||||||
|
props = bpy.context.scene.BIMCostProperties
|
||||||
|
currency = props.currency
|
||||||
|
if currency == "CUSTOM":
|
||||||
|
currency = props.custom_currency
|
||||||
|
return {
|
||||||
|
"Currency": currency,
|
||||||
|
}
|
||||||
@@ -149,3 +149,17 @@ class Unit(blenderbim.core.tool.Unit):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def set_active_unit(cls, unit):
|
def set_active_unit(cls, unit):
|
||||||
bpy.context.scene.BIMUnitProperties.active_unit_id = unit.id()
|
bpy.context.scene.BIMUnitProperties.active_unit_id = unit.id()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_project_currency_unit(cls):
|
||||||
|
unit_assignments = tool.Ifc.get().by_type("IfcUnitAssignment")
|
||||||
|
for assignment in unit_assignments:
|
||||||
|
for unit in assignment.Units:
|
||||||
|
if unit.is_a("IfcMonetaryUnit"):
|
||||||
|
return unit
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_currency_name(cls):
|
||||||
|
unit = cls.get_project_currency_unit()
|
||||||
|
if unit:
|
||||||
|
return unit.Currency
|
||||||
|
|||||||
Reference in New Issue
Block a user