2021-04-14 23:40:29 +00:00
|
|
|
import ifcopenshell.api
|
2021-04-18 00:49:43 +00:00
|
|
|
import ifcopenshell
|
2021-04-14 23:40:29 +00:00
|
|
|
|
|
|
|
|
class Usecase:
|
|
|
|
|
def __init__(self, file, **settings):
|
|
|
|
|
self.file = file
|
2021-04-15 10:38:45 +10:00
|
|
|
self.settings = {
|
2021-04-18 00:49:43 +00:00
|
|
|
"work_schedule": None,
|
|
|
|
|
"parent_task": None,
|
2021-04-15 10:38:45 +10:00
|
|
|
}
|
2021-04-14 23:40:29 +00:00
|
|
|
for key, value in settings.items():
|
|
|
|
|
self.settings[key] = value
|
|
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
|
task = ifcopenshell.api.run(
|
|
|
|
|
"root.create_entity",
|
|
|
|
|
self.file,
|
|
|
|
|
ifc_class="IfcTask",
|
2021-04-18 00:49:43 +00:00
|
|
|
name= None,
|
|
|
|
|
predefined_type= "NOTDEFINED",
|
|
|
|
|
identification= "none",
|
2021-04-14 23:40:29 +00:00
|
|
|
)
|
2021-04-18 00:49:43 +00:00
|
|
|
task.IsMilestone = False
|
|
|
|
|
if self.settings["work_schedule"]:
|
|
|
|
|
self.file.create_entity(
|
|
|
|
|
"IfcRelAssignsToControl",
|
|
|
|
|
**{
|
|
|
|
|
"GlobalId": ifcopenshell.guid.new(),
|
|
|
|
|
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
|
|
|
|
"RelatedObjects": [task],
|
|
|
|
|
"RelatingControl": self.settings["work_schedule"],
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
elif self.settings["parent_task"]:
|
|
|
|
|
ifcopenshell.api.run(
|
|
|
|
|
"nest.assign_object", self.file, object=task, relating_object=self.settings["parent_task"]
|
|
|
|
|
)
|
2021-04-15 10:38:45 +10:00
|
|
|
return task
|