MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / ScheduleIfcGenerator

Class ScheduleIfcGenerator

src/ifc4d/ifc4d/common.py:58–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57
58class ScheduleIfcGenerator:
59 file: Union[ifcopenshell.file, None]
60 calendars: dict[int, Calendar]
61
62 def __init__(self, file: Union[ifcopenshell.file, None], output, settings):
63 self.file = file
64 self.work_plan = settings["work_plan"]
65 self.project = settings["project"]
66 self.calendars = settings["calendars"]
67 self.wbs = settings["wbs"]
68 self.root_activites = settings["root_activities"]
69 self.activities = settings["activities"]
70 self.relationships = settings["relationships"]
71 self.resources = settings["resources"]
72 self.output = output
73 self.day_map = {
74 "Monday": 1,
75 "Tuesday": 2,
76 "Wednesday": 3,
77 "Thursday": 4,
78 "Friday": 5,
79 "Saturday": 6,
80 "Sunday": 7,
81 }
82
83 def create_ifc(self) -> None:
84 if not self.file:
85 self.file = self.create_boilerplate_ifc()
86 if not self.work_plan:
87 self.work_plan = ifcopenshell.api.sequence.add_work_plan(self.file)
88 work_schedule = self.create_work_schedule()
89 self.create_calendars()
90 self.create_tasks(work_schedule)
91 self.create_rel_sequences()
92 self.create_resources()
93 if self.output:
94 self.file.write(self.output)
95
96 def create_work_schedule(self) -> ifcopenshell.entity_instance:
97 return ifcopenshell.api.sequence.add_work_schedule(
98 self.file, name=self.project["Name"], work_plan=self.work_plan
99 )
100
101 def create_calendars(self) -> None:
102 for calendar_id, calendar in self.calendars.items():
103 calendar["ifc"] = ifcopenshell.api.sequence.add_work_calendar(self.file, name=calendar["Name"])
104 calendar["ifc"].Identification = str(calendar_id)
105 self.process_working_week(calendar["StandardWorkWeek"], calendar["ifc"])
106 self.process_exceptions(calendar.get("HolidayOrExceptions"), calendar["ifc"])
107
108 def process_working_week(self, week: list[WorkSlot], calendar: ifcopenshell.entity_instance) -> None:
109 for day in week:
110 if day["ifc"] or not day.get("WorkTimes"):
111 continue
112
113 day["ifc"] = ifcopenshell.api.sequence.add_work_time(
114 self.file, work_calendar=calendar, time_type="WorkingTimes"
115 )

Callers 3

executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected