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) <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-08-11 21:30:27 +10:00
parent beb0db89e5
commit 17042f6f80
+3 -1
View File
@@ -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")