mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Fix bug in work schedule cascading where some cascades wouldn't work and non-working dates would lead to an infinite recursion
This commit is contained in:
@@ -117,7 +117,6 @@ def updateTaskTimeDateTime(self, context, startfinish):
|
|||||||
return "-"
|
return "-"
|
||||||
return time.strftime("%d/%m/%y")
|
return time.strftime("%d/%m/%y")
|
||||||
|
|
||||||
startfinish_key = "Schedule" + startfinish.capitalize()
|
|
||||||
startfinish_value = getattr(self, startfinish)
|
startfinish_value = getattr(self, startfinish)
|
||||||
|
|
||||||
if startfinish_value == "-":
|
if startfinish_value == "-":
|
||||||
@@ -141,6 +140,7 @@ def updateTaskTimeDateTime(self, context, startfinish):
|
|||||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
|
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
|
|
||||||
|
startfinish_key = "Schedule" + startfinish.capitalize()
|
||||||
if Data.task_times[task_time.id()][startfinish_key] == startfinish_datetime:
|
if Data.task_times[task_time.id()][startfinish_key] == startfinish_datetime:
|
||||||
canonical_startfinish_value = canonicalise_time(startfinish_datetime)
|
canonical_startfinish_value = canonicalise_time(startfinish_datetime)
|
||||||
if startfinish_value != canonical_startfinish_value:
|
if startfinish_value != canonical_startfinish_value:
|
||||||
@@ -154,10 +154,9 @@ def updateTaskTimeDateTime(self, context, startfinish):
|
|||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_task_properties()
|
bpy.ops.bim.load_task_properties()
|
||||||
setattr(self, startfinish, canonicalise_time(startfinish_datetime))
|
|
||||||
|
|
||||||
|
|
||||||
def updateTaskduration(self, context):
|
def updateTaskDuration(self, context):
|
||||||
props = context.scene.BIMWorkScheduleProperties
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
if not props.is_task_update_enabled:
|
if not props.is_task_update_enabled:
|
||||||
return
|
return
|
||||||
@@ -224,7 +223,7 @@ class Task(PropertyGroup):
|
|||||||
is_selected: BoolProperty(name="Is Selected")
|
is_selected: BoolProperty(name="Is Selected")
|
||||||
is_expanded: BoolProperty(name="Is Expanded")
|
is_expanded: BoolProperty(name="Is Expanded")
|
||||||
level_index: IntProperty(name="Level Index")
|
level_index: IntProperty(name="Level Index")
|
||||||
duration: StringProperty(name="Duration", update=updateTaskduration)
|
duration: StringProperty(name="Duration", update=updateTaskDuration)
|
||||||
start: StringProperty(name="Start", update=updateTaskTimeStart)
|
start: StringProperty(name="Start", update=updateTaskTimeStart)
|
||||||
finish: StringProperty(name="Finish", update=updateTaskTimeFinish)
|
finish: StringProperty(name="Finish", update=updateTaskTimeFinish)
|
||||||
calendar: StringProperty(name="Calendar")
|
calendar: StringProperty(name="Calendar")
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ class Usecase:
|
|||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
self.calendar_cache = {}
|
self.calendar_cache = {}
|
||||||
self.cascade_task(self.settings["task"])
|
self.cascade_task(self.settings["task"], is_first_task=True)
|
||||||
|
|
||||||
def cascade_task(self, task):
|
def cascade_task(self, task, is_first_task=False):
|
||||||
if not task.TaskTime:
|
if not task.TaskTime:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -88,13 +88,13 @@ class Usecase:
|
|||||||
)
|
)
|
||||||
if potential_finish > finish:
|
if potential_finish > finish:
|
||||||
start_ifc = ifcopenshell.util.date.datetime2ifc(start, "IfcDateTime")
|
start_ifc = ifcopenshell.util.date.datetime2ifc(start, "IfcDateTime")
|
||||||
if task.TaskTime.ScheduleStart == start_ifc:
|
if task.TaskTime.ScheduleStart == start_ifc and not is_first_task:
|
||||||
return
|
return
|
||||||
task.TaskTime.ScheduleStart = start_ifc
|
task.TaskTime.ScheduleStart = start_ifc
|
||||||
task.TaskTime.ScheduleFinish = ifcopenshell.util.date.datetime2ifc(potential_finish, "IfcDateTime")
|
task.TaskTime.ScheduleFinish = ifcopenshell.util.date.datetime2ifc(potential_finish, "IfcDateTime")
|
||||||
else:
|
else:
|
||||||
finish_ifc = ifcopenshell.util.date.datetime2ifc(finish, "IfcDateTime")
|
finish_ifc = ifcopenshell.util.date.datetime2ifc(finish, "IfcDateTime")
|
||||||
if task.TaskTime.ScheduleFinish == finish_ifc:
|
if task.TaskTime.ScheduleFinish == finish_ifc and not is_first_task:
|
||||||
return
|
return
|
||||||
task.TaskTime.ScheduleFinish = finish_ifc
|
task.TaskTime.ScheduleFinish = finish_ifc
|
||||||
task.TaskTime.ScheduleStart = ifcopenshell.util.date.datetime2ifc(
|
task.TaskTime.ScheduleStart = ifcopenshell.util.date.datetime2ifc(
|
||||||
@@ -109,7 +109,7 @@ class Usecase:
|
|||||||
elif finishes:
|
elif finishes:
|
||||||
finish = max(finishes)
|
finish = max(finishes)
|
||||||
finish_ifc = ifcopenshell.util.date.datetime2ifc(finish, "IfcDateTime")
|
finish_ifc = ifcopenshell.util.date.datetime2ifc(finish, "IfcDateTime")
|
||||||
if task.TaskTime.ScheduleFinish == finish_ifc:
|
if task.TaskTime.ScheduleFinish == finish_ifc and not is_first_task:
|
||||||
return
|
return
|
||||||
task.TaskTime.ScheduleFinish = finish_ifc
|
task.TaskTime.ScheduleFinish = finish_ifc
|
||||||
task.TaskTime.ScheduleStart = ifcopenshell.util.date.datetime2ifc(
|
task.TaskTime.ScheduleStart = ifcopenshell.util.date.datetime2ifc(
|
||||||
@@ -124,7 +124,7 @@ class Usecase:
|
|||||||
elif starts:
|
elif starts:
|
||||||
start = max(starts)
|
start = max(starts)
|
||||||
start_ifc = ifcopenshell.util.date.datetime2ifc(start, "IfcDateTime")
|
start_ifc = ifcopenshell.util.date.datetime2ifc(start, "IfcDateTime")
|
||||||
if task.TaskTime.ScheduleStart == start_ifc:
|
if task.TaskTime.ScheduleStart == start_ifc and not is_first_task:
|
||||||
return
|
return
|
||||||
task.TaskTime.ScheduleStart = start_ifc
|
task.TaskTime.ScheduleStart = start_ifc
|
||||||
task.TaskTime.ScheduleFinish = ifcopenshell.util.date.datetime2ifc(
|
task.TaskTime.ScheduleFinish = ifcopenshell.util.date.datetime2ifc(
|
||||||
|
|||||||
Reference in New Issue
Block a user