mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Feature edit work plan (#1418)
* ifcopenshell.api modules Persons and Organisations account for IFC4 SCHEMA CHANGE * New Feature to Edit Workplans
This commit is contained in:
@@ -14,18 +14,30 @@ class Data:
|
||||
|
||||
@classmethod
|
||||
def load(cls, file):
|
||||
cls._file = file
|
||||
if not cls._file:
|
||||
return
|
||||
cls.load_work_plans()
|
||||
cls.load_work_schedules()
|
||||
cls.load_tasks()
|
||||
cls.is_loaded=True
|
||||
|
||||
@classmethod
|
||||
def load_work_plans(cls):
|
||||
cls.work_plans = {}
|
||||
cls.tasks = {}
|
||||
for work_plan in file.by_type("IfcWorkPlan"):
|
||||
for work_plan in cls._file.by_type("IfcWorkPlan"):
|
||||
data = work_plan.get_info()
|
||||
del data["OwnerHistory"]
|
||||
if data["Creators"]:
|
||||
data["Creators"] = [p.id() for p in data["Creators"]]
|
||||
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"])
|
||||
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"])
|
||||
data["CreationDate"] = ifcopenshell.util.date.ifc2datetime(data["CreationDate"]).isoformat()
|
||||
data["StartTime"] = ifcopenshell.util.date.ifc2datetime(data["StartTime"]).isoformat()
|
||||
if data["FinishTime"]:
|
||||
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"])
|
||||
data["FinishTime"] = ifcopenshell.util.date.ifc2datetime(data["FinishTime"]).isoformat()
|
||||
cls.work_plans[work_plan.id()] = data
|
||||
for task in file.by_type("IfcTask"):
|
||||
|
||||
@classmethod
|
||||
def load_tasks(cls):
|
||||
cls.tasks = {}
|
||||
for task in cls._file.by_type("IfcTask"):
|
||||
cls.tasks[task.id()] = {"Name": task.Name, "Identification": task.Identification or ""}
|
||||
cls.is_loaded=True
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
self.file = file
|
||||
self.settings = {
|
||||
"work_plan": None,
|
||||
"attributes": {}
|
||||
}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
|
||||
def execute(self):
|
||||
for name, value in self.settings["attributes"].items():
|
||||
setattr(self.settings["work_plan"], name, value)
|
||||
Reference in New Issue
Block a user