From 17042f6f8080e4a4b7de9e0432039e258b84caac Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 11 Aug 2026 21:30:27 +1000 Subject: [PATCH] ifc4d: make ScheduleIfcGenerator's boilerplate file actually work create_boilerplate_ifc sets self.file and self.work_plan and returns nothing, but create_ifc assigned its result back over self.file, so any caller that did not supply a file got None and crashed on the next create_entity. Call it for its side effects, as csv2ifc and csv4d2ifc already do. That alone only moved the failure along: the boilerplate builds a file and a work plan but no IfcProject, and add_work_calendar looks for an IfcContext. Create one, matching csv4d2ifc's copy of the same method, which has both lines. Co-Authored-By: Claude Opus 5 (1M context) --- src/ifc4d/ifc4d/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ifc4d/ifc4d/common.py b/src/ifc4d/ifc4d/common.py index a470bc626b..d044aa8bcc 100644 --- a/src/ifc4d/ifc4d/common.py +++ b/src/ifc4d/ifc4d/common.py @@ -8,6 +8,7 @@ import ifcopenshell.api.control import ifcopenshell.api.owner import ifcopenshell.api.pset import ifcopenshell.api.resource +import ifcopenshell.api.root import ifcopenshell.api.sequence import ifcopenshell.guid import ifcopenshell.util.date @@ -107,7 +108,7 @@ class ScheduleIfcGenerator: def create_ifc(self) -> None: if not self.file: - self.file = self.create_boilerplate_ifc() + self.create_boilerplate_ifc() if not self.work_plan: self.work_plan = ifcopenshell.api.sequence.add_work_plan(self.file) work_schedule = self.create_work_schedule() @@ -491,4 +492,5 @@ class ScheduleIfcGenerator: def create_boilerplate_ifc(self) -> None: self.file = ifcopenshell.file(schema="IFC4") + ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcProject") self.work_plan = self.file.create_entity("IfcWorkPlan")