From 780ea707b02310f0ec07f749207bd32b8a0c6871 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 17 Feb 2021 21:17:02 +1100 Subject: [PATCH] Highly experimental script to convert from IFC task trees into a Gantt chart JSON for jsgantt-improved --- src/ifcblenderexport/ifc_to_gantt.py | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/ifcblenderexport/ifc_to_gantt.py diff --git a/src/ifcblenderexport/ifc_to_gantt.py b/src/ifcblenderexport/ifc_to_gantt.py new file mode 100644 index 0000000000..1359805a02 --- /dev/null +++ b/src/ifcblenderexport/ifc_to_gantt.py @@ -0,0 +1,33 @@ +import json +import ifcopenshell + +class IfcToGantt: + def __init__(self): + self.json = [] + + def execute(self): + self.file = ifcopenshell.open("p6.ifc") + self.root = self.file.by_type("IfcTask")[0] + task = self.root + for task in self.file.by_type("IfcTask"): + self.json.append({ + "pID": task.id(), + "pName": task.Name, + "pStart": task.TaskTime.ScheduleStart if task.TaskTime else "", + "pEnd": task.TaskTime.ScheduleFinish if task.TaskTime else "", + "pPlanStart": task.TaskTime.ScheduleStart if task.TaskTime else "", + "pPlanEnd": task.TaskTime.ScheduleFinish if task.TaskTime else "", + "pClass": "ggroupblack", + "pMile": 1 if task.IsMilestone else 0, + "pComp": 0, + "pGroup": 1, + "pParent": task.Nests[0].RelatingObject.id() if task.Nests else 0, + "pOpen": 1, + "pCost": 1 + }) + with open("p6.json", "w") as f: + json.dump(self.json, f) + +ifc_to_gantt = IfcToGantt() +ifc_to_gantt.execute() +