mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
You can now clear all cost assignements at once
This commit is contained in:
@@ -67,6 +67,7 @@ classes = (
|
||||
operator.ExpandCostItemRate,
|
||||
operator.ContractCostItemRate,
|
||||
operator.CalculateCostItemResourceValue,
|
||||
operator.ClearCostItemAssignments,
|
||||
operator.LoadCostItemElementQuantities,
|
||||
operator.LoadCostItemTaskQuantities,
|
||||
operator.LoadCostItemResourceQuantities,
|
||||
|
||||
@@ -635,3 +635,20 @@ class ExportCostSchedules(bpy.types.Operator):
|
||||
def draw(self, context):
|
||||
self.layout.label(text="Choose a format")
|
||||
self.layout.prop(self, "format")
|
||||
|
||||
|
||||
class ClearCostItemAssignments(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.clear_cost_item_assignments"
|
||||
bl_label = "Clear Cost Item Product Assignments"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
cost_item: bpy.props.IntProperty()
|
||||
related_object_type: bpy.props.StringProperty()
|
||||
|
||||
def _execute(self, context):
|
||||
core.clear_cost_item_assignments(
|
||||
tool.Ifc,
|
||||
tool.Cost,
|
||||
cost_item=tool.Ifc.get().by_id(self.cost_item),
|
||||
related_object_type=self.related_object_type,
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -374,6 +374,11 @@ class BIM_PT_cost_item_quantities(Panel):
|
||||
"active_cost_item_product_index",
|
||||
)
|
||||
|
||||
row2 = col.row()
|
||||
op = row2.operator("bim.clear_cost_item_assignments", text="Clear assignments", icon="X")
|
||||
op.cost_item = cost_item.ifc_definition_id
|
||||
op.related_object_type = "IfcElement"
|
||||
|
||||
if has_quantity_names:
|
||||
row2 = col.row()
|
||||
row2.prop(self.props, "product_quantity_names", text="")
|
||||
@@ -414,6 +419,11 @@ class BIM_PT_cost_item_quantities(Panel):
|
||||
"active_cost_item_process_index",
|
||||
)
|
||||
|
||||
row2 = col.row()
|
||||
op = row2.operator("bim.clear_cost_item_assignments", text="Clear assignments", icon="X")
|
||||
op.cost_item = cost_item.ifc_definition_id
|
||||
op.related_object_type = "IfcProcess"
|
||||
|
||||
if has_quantity_names:
|
||||
row2 = col.row()
|
||||
row2.prop(self.props, "process_quantity_names", text="")
|
||||
@@ -457,6 +467,11 @@ class BIM_PT_cost_item_quantities(Panel):
|
||||
"active_cost_item_resource_index",
|
||||
)
|
||||
|
||||
row2 = col.row()
|
||||
op = row2.operator("bim.clear_cost_item_assignments", text="Clear assignments", icon="X")
|
||||
op.cost_item = cost_item.ifc_definition_id
|
||||
op.related_object_type = "IfcResource"
|
||||
|
||||
if has_quantity_names:
|
||||
row2 = col.row()
|
||||
row2.prop(self.props, "resource_quantity_names", text="")
|
||||
|
||||
@@ -107,8 +107,9 @@ def assign_cost_item_quantity(ifc, cost, cost_item, related_object_type, prop_na
|
||||
products = cost.get_products(related_object_type)
|
||||
if products:
|
||||
ifc.run("cost.assign_cost_item_quantity", cost_item=cost_item, products=products, prop_name=prop_name)
|
||||
cost.load_cost_item_quantities(cost_item)
|
||||
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT")
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS")
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE")
|
||||
|
||||
def load_cost_item_quantities(cost):
|
||||
cost_item = cost.get_highlighted_cost_item()
|
||||
@@ -136,7 +137,9 @@ def load_schedule_of_rates(cost, schedule_of_rates):
|
||||
|
||||
def unassign_cost_item_quantity(ifc, cost, cost_item, products):
|
||||
ifc.run("cost.unassign_cost_item_quantity", cost_item=cost_item, products=products)
|
||||
cost.load_cost_item_quantities(cost_item)
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PRODUCT")
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="PROCESS")
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type="RESOURCE")
|
||||
|
||||
def enable_editing_cost_item_quantities(cost, cost_item):
|
||||
cost.enable_editing_cost_item_quantities(cost_item)
|
||||
@@ -161,7 +164,10 @@ def edit_cost_item_quantity(ifc, cost, physical_quantity):
|
||||
attributes = cost.get_cost_item_quantity_attributes()
|
||||
ifc.run("cost.edit_cost_item_quantity", physical_quantity=physical_quantity, attributes=attributes)
|
||||
cost.disable_editing_cost_item_quantity()
|
||||
# cost.load_cost_item_quantities(cost.get_active_cost_item())
|
||||
#TODO: REVIEW usefulness
|
||||
cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="PRODUCT")
|
||||
cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="PROCESS")
|
||||
cost.load_cost_item_quantity_assignments(cost.get_highlighted_cost_item(), related_object_type="RESOURCE")
|
||||
|
||||
def add_cost_value(ifc, cost, parent, cost_type, cost_category):
|
||||
value = ifc.run("cost.add_cost_value", parent=parent)
|
||||
@@ -226,4 +232,11 @@ def calculate_cost_item_resource_value(ifc, cost_item):
|
||||
ifc.run("cost.calculate_cost_item_resource_value", cost_item=cost_item)
|
||||
|
||||
def export_cost_schedules(cost, format):
|
||||
cost.export_cost_schedules(format)
|
||||
cost.export_cost_schedules(format)
|
||||
|
||||
def clear_cost_item_assignments(ifc, cost, cost_item, related_object_type):
|
||||
products = cost.get_cost_item_assignments(cost_item, filter_by_type=related_object_type)
|
||||
if products:
|
||||
ifc.run("cost.unassign_cost_item_quantity", cost_item=cost_item, products=products)
|
||||
cost.load_cost_item_quantity_assignments(cost_item, related_object_type=related_object_type)
|
||||
cost.load_cost_schedule_tree()
|
||||
|
||||
Reference in New Issue
Block a user