diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index 54aab0e68c..696d3839af 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -1544,6 +1544,13 @@ class Sequence(blenderbim.core.tool.Sequence): def generate_gantt_browser_chart( cls, task_json: list[dict[str, Any]], work_schedule: ifcopenshell.entity_instance ) -> None: + # with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f: + # with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t: + # task_b64 = base64.b64encode(bytes(json.dumps(task_json), "utf-8")).decode("utf-8") + # f.write( + # pystache.render(t.read(), {"json_data": task_b64, "data": json.dumps(work_schedule.get_info())}) + # ) + # webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html")) gantt_data = {"tasks": task_json, "work_schedule": work_schedule.get_info(recursive=True)} tool.Web.send_webui_data(extra_data=gantt_data, extra_data_key="gantt_data", event="gantt_data") diff --git a/src/blenderbim/blenderbim/tool/web.py b/src/blenderbim/blenderbim/tool/web.py index 3d7649dac7..1b38949ccc 100644 --- a/src/blenderbim/blenderbim/tool/web.py +++ b/src/blenderbim/blenderbim/tool/web.py @@ -39,7 +39,7 @@ web_operator_queue = queue.Queue() IFC_TASK_ATTRIBUTE_MAP = { "pStart": "ScheduleStart", "pEnd": "ScheduleFinish", - "pName": "", + "pName": "Name", "pRes": "", } @@ -175,17 +175,22 @@ class Web(blenderbim.core.tool.Web): ifc_file = tool.Ifc.get() if operator_data["type"] == "editTask": task_id = int(operator_data["taskId"]) - task_time = ifc_file.by_id(task_id).TaskTime + task = ifc_file.by_id(task_id) + task_time = task.TaskTime column = operator_data["column"] new_value = operator_data["value"] - # editing a parent task time will throw an exception try: + ifcopenshell.api.sequence.edit_task( + ifc_file, task, attributes={IFC_TASK_ATTRIBUTE_MAP[column]: str(new_value)} + ) + except AttributeError: + if task_time is None: + ifcopenshell.api.sequence.add_task_time(ifc_file, task) + task_time = task.TaskTime ifcopenshell.api.sequence.edit_task_time( ifc_file, task_time=task_time, attributes={IFC_TASK_ATTRIBUTE_MAP[column]: str(new_value)} ) - except AttributeError: - pass bpy.ops.bim.load_task_properties()