2021-05-08 12:18:27 +10:00
|
|
|
class Usecase:
|
|
|
|
|
def __init__(self, file, **settings):
|
|
|
|
|
self.file = file
|
|
|
|
|
self.settings = {"parent": None}
|
|
|
|
|
for key, value in settings.items():
|
|
|
|
|
self.settings[key] = value
|
|
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
|
value = self.file.create_entity("IfcCostValue")
|
|
|
|
|
if self.settings["parent"].is_a("IfcCostItem"):
|
|
|
|
|
values = list(self.settings["parent"].CostValues or [])
|
|
|
|
|
values.append(value)
|
|
|
|
|
self.settings["parent"].CostValues = values
|
2021-08-27 17:12:21 +10:00
|
|
|
elif self.settings["parent"].is_a("IfcConstructionResource"):
|
|
|
|
|
values = list(self.settings["parent"].BaseCosts or [])
|
|
|
|
|
values.append(value)
|
|
|
|
|
self.settings["parent"].BaseCosts = values
|
2021-05-08 12:18:27 +10:00
|
|
|
elif self.settings["parent"].is_a("IfcCostValue"):
|
|
|
|
|
values = list(self.settings["parent"].Components or [])
|
|
|
|
|
values.append(value)
|
|
|
|
|
self.settings["parent"].Components = values
|
|
|
|
|
return value
|