mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
New Feature to add Tasks and Task Relationships in the python ifcopenshell API (#1432)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {"name": None, "predefined_type": "NOTDEFINED", "is_milestone":False, "identification": "none", "predecessor_to":None, "successor_from":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",
|
||||
predefined_type=self.settings["predefined_type"],
|
||||
name=self.settings["name"],
|
||||
)
|
||||
task.IsMilestone = self.settings["is_milestone"]
|
||||
return task
|
||||
@@ -0,0 +1,25 @@
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"predecessor_task": None,
|
||||
"sequence_type":"FINISH_START",
|
||||
"task": None,
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
#TODO: tasks can only have one relationship between oneanother: if a relationship is already assigned, it should overide the previous one's settings.
|
||||
rel_sequence = self.file.create_entity("IfcRelSequence",**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
"RelatingProcess": self.settings["predecessor_task"],
|
||||
"SequenceType": self.settings["sequence_type"],
|
||||
"RelatedProcess": self.settings["task"],
|
||||
})
|
||||
return rel_sequence
|
||||
@@ -0,0 +1,25 @@
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"task": None,
|
||||
"sequence_type":"FINISH_START",
|
||||
"successor_task": None,
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
#TODO: tasks can only have one relationship between oneanother: if a relationship is already assigned, it should overide the previous one's settings.
|
||||
rel_sequence = self.file.create_entity("IfcRelSequence",**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file),
|
||||
"RelatingProcess": self.settings["task"],
|
||||
"SequenceType": self.settings["sequence_type"],
|
||||
"RelatedProcess": self.settings["successor_task"],
|
||||
})
|
||||
return rel_sequence
|
||||
Reference in New Issue
Block a user