Files
IfcOpenShell/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.3 KiB
Python
Raw Normal View History

import ifcopenshell.api
import ifcopenshell
2021-04-21 11:53:33 +10:00
class Usecase:
def __init__(self, file, **settings):
self.file = file
self.settings = {
"work_schedule": None,
"parent_task": None,
}
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-21 11:53:33 +10:00
name=None,
predefined_type="NOTDEFINED",
identification="none",
)
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(
2021-04-21 11:53:33 +10:00
"nest.assign_object", self.file, related_object=task, relating_object=self.settings["parent_task"]
)
return task