You can now assign rates from a schedule of rates to a cost plan

This commit is contained in:
Dion Moult
2021-08-17 12:22:57 +10:00
parent 899a0c6fb5
commit 912699e63c
5 changed files with 82 additions and 21 deletions
@@ -0,0 +1,17 @@
import ifcopenshell.api
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {"cost_item": None, "cost_rate": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
for cost_value in self.settings["cost_item"].CostValues:
ifcopenshell.api.run(
"cost.remove_cost_item_value", self.file, parent=self.settings["cost_item"], cost_value=cost_value
)
# This is an assumption, and not part of the official IFC documentation
self.settings["cost_item"].CostValues = self.settings["cost_rate"].CostValues
@@ -1,9 +1,19 @@
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {"cost_value": None}
self.settings = {"parent": None, "cost_value": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
self.file.remove(self.settings["cost_value"])
if len(self.file.get_inverse(self.settings["cost_value"])) == 1:
self.file.remove(self.settings["cost_value"])
# TODO deep purge
elif self.settings["parent"].is_a("IfcCostItem"):
values = list(self.settings["parent"].CostValues)
values.remove(self.settings["cost_value"])
self.settings["parent"].CostValues = values if values else None
elif self.settings["parent"].is_a("IfcCostValue"):
components = list(self.settings["parent"].Components)
components.remove(self.settings["cost_value"])
self.settings["parent"].Components = components if components else None