mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-07 00:11:36 +00:00
different columns for different cost schedules #4724
though columns are still stored in .blend file and not in .ifc Example - https://imgur.com/a/N6epGZ4
This commit is contained in:
@@ -82,6 +82,7 @@ classes = (
|
||||
prop.CostItem,
|
||||
prop.CostItemQuantity,
|
||||
prop.CostItemType,
|
||||
prop.ScheduleColumn,
|
||||
prop.BIMCostProperties,
|
||||
ui.BIM_PT_cost_schedules,
|
||||
ui.BIM_PT_cost_item_quantities,
|
||||
|
||||
@@ -73,7 +73,7 @@ class RemoveCostSchedule(bpy.types.Operator, tool.Ifc.Operator):
|
||||
cost_schedule: bpy.props.IntProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
core.remove_cost_schedule(tool.Ifc, cost_schedule=tool.Ifc.get().by_id(self.cost_schedule))
|
||||
core.remove_cost_schedule(tool.Ifc, tool.Cost, cost_schedule=tool.Ifc.get().by_id(self.cost_schedule))
|
||||
|
||||
|
||||
class EnableEditingCostSchedule(bpy.types.Operator):
|
||||
|
||||
@@ -175,6 +175,10 @@ def update_active_cost_item_resources(self, context):
|
||||
bpy.ops.bim.load_cost_item_resource_quantities()
|
||||
|
||||
|
||||
class ScheduleColumn(PropertyGroup):
|
||||
schedule_id: IntProperty()
|
||||
|
||||
|
||||
class BIMCostProperties(PropertyGroup):
|
||||
cost_schedule_predefined_types: EnumProperty(
|
||||
items=get_schedule_predefined_types, name="Predefined Type", default=None
|
||||
@@ -216,7 +220,8 @@ class BIMCostProperties(PropertyGroup):
|
||||
default=False,
|
||||
)
|
||||
should_show_currency_ui: BoolProperty(name="Should Show Currency UI", default=False)
|
||||
columns: CollectionProperty(name="Columns", type=StrProperty)
|
||||
columns: CollectionProperty(name="Active Schedule Columns", type=StrProperty)
|
||||
columns_storage: CollectionProperty(name="Columns", type=ScheduleColumn)
|
||||
active_column_index: IntProperty(name="Active Column Index")
|
||||
cost_item_products: CollectionProperty(name="Cost Item Products", type=CostItemQuantity)
|
||||
active_cost_item_product_index: IntProperty(name="Active Cost Item Product Index")
|
||||
|
||||
@@ -39,8 +39,9 @@ def disable_editing_cost_schedule(cost: tool.Cost):
|
||||
cost.disable_editing_cost_schedule()
|
||||
|
||||
|
||||
def remove_cost_schedule(ifc: tool.Ifc, cost_schedule: ifcopenshell.entity_instance):
|
||||
def remove_cost_schedule(ifc: tool.Ifc, cost: tool.Cost, cost_schedule: ifcopenshell.entity_instance) -> None:
|
||||
ifc.run("cost.remove_cost_schedule", cost_schedule=cost_schedule)
|
||||
cost.remove_stored_schedule_columns(cost_schedule)
|
||||
|
||||
|
||||
def enable_editing_cost_schedule_attributes(cost: tool.Cost, cost_schedule: ifcopenshell.entity_instance):
|
||||
@@ -50,6 +51,7 @@ def enable_editing_cost_schedule_attributes(cost: tool.Cost, cost_schedule: ifco
|
||||
|
||||
def enable_editing_cost_items(cost: tool.Cost, cost_schedule: ifcopenshell.entity_instance):
|
||||
cost.enable_editing_cost_items(cost_schedule)
|
||||
cost.load_active_schedule_columns()
|
||||
cost.load_cost_schedule_tree()
|
||||
cost.play_sound()
|
||||
|
||||
|
||||
@@ -19,9 +19,59 @@ class Cost(blenderbim.core.tool.Cost):
|
||||
|
||||
@classmethod
|
||||
def disable_editing_cost_schedule(cls):
|
||||
cls.store_active_schedule_columns()
|
||||
bpy.context.scene.BIMCostProperties.active_cost_schedule_id = 0
|
||||
cls.disable_editing_cost_item()
|
||||
|
||||
@classmethod
|
||||
def load_active_schedule_columns(cls) -> None:
|
||||
props = bpy.context.scene.BIMCostProperties
|
||||
active_columns = props.columns
|
||||
storage = props.columns_storage
|
||||
active_cost_schedule_id = cls.get_active_cost_schedule().id()
|
||||
|
||||
# store column names to keep the original order
|
||||
cols_to_add = []
|
||||
|
||||
# collection property only support removal by index
|
||||
for storage_col_i, storage_col in reversed(list(enumerate(storage[:]))):
|
||||
if storage_col.schedule_id != active_cost_schedule_id:
|
||||
continue
|
||||
cols_to_add.insert(0, storage_col.name)
|
||||
# We don't store active schedule columns in storage
|
||||
# so it will be easy to edit them.
|
||||
storage.remove(storage_col_i)
|
||||
|
||||
for col_name in cols_to_add:
|
||||
col = active_columns.add()
|
||||
col.name = col_name
|
||||
|
||||
@classmethod
|
||||
def store_active_schedule_columns(cls) -> None:
|
||||
props = bpy.context.scene.BIMCostProperties
|
||||
active_columns = props.columns
|
||||
storage = props.columns_storage
|
||||
active_cost_schedule_id = cls.get_active_cost_schedule().id()
|
||||
|
||||
for col in active_columns:
|
||||
storage_col = storage.add()
|
||||
storage_col.name = col.name
|
||||
storage_col.schedule_id = active_cost_schedule_id
|
||||
|
||||
props.columns.clear()
|
||||
|
||||
@classmethod
|
||||
def remove_stored_schedule_columns(cls, cost_schedule: ifcopenshell.entity_instance) -> None:
|
||||
props = bpy.context.scene.BIMCostProperties
|
||||
storage = props.columns_storage
|
||||
active_cost_schedule_id = cost_schedule.id()
|
||||
|
||||
# collection property only support removal by index
|
||||
for storage_col_i, storage_col in reversed(list(enumerate(storage[:]))):
|
||||
if storage_col.schedule_id != active_cost_schedule_id:
|
||||
continue
|
||||
storage.remove(storage_col_i)
|
||||
|
||||
@classmethod
|
||||
def enable_editing_cost_schedule_attributes(cls, cost_schedule):
|
||||
bpy.context.scene.BIMCostProperties.active_cost_schedule_id = cost_schedule.id()
|
||||
|
||||
Reference in New Issue
Block a user