You can now add cost items into a cost schedule, and as sub items to a parent cost item. Thanks myoualid and Jesusbill!

This commit is contained in:
Dion Moult
2021-04-10 20:40:35 +10:00
parent 3102dbcd44
commit df437fd3e3
7 changed files with 199 additions and 17 deletions
@@ -0,0 +1,28 @@
import ifcopenshell.api
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {"cost_schedule": None, "cost_item": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
cost_item = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcCostItem")
if self.settings["cost_schedule"]:
self.file.create_entity(
"IfcRelAssignsToControl",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
"RelatedObjects": [cost_item],
"RelatingControl": self.settings["cost_schedule"],
}
)
elif self.settings["cost_item"]:
ifcopenshell.api.run(
"nest.assign_object", self.file, object=cost_item, relating_object=self.settings["cost_item"]
)
return cost_item