mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 05:22:06 +00:00
Scheduled dates now cascade when dependencies, lag times, and calendars are modified
This commit is contained in:
@@ -575,7 +575,7 @@ class AssignPredecessor(bpy.types.Operator):
|
|||||||
"sequence.edit_sequence", self.file, rel_sequence=rel, attributes={"SequenceType": "FINISH_START"}
|
"sequence.edit_sequence", self.file, rel_sequence=rel, attributes={"SequenceType": "FINISH_START"}
|
||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.load_task_properties(task=self.task)
|
bpy.ops.bim.load_task_properties()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -597,7 +597,7 @@ class AssignSuccessor(bpy.types.Operator):
|
|||||||
"sequence.edit_sequence", self.file, rel_sequence=rel, attributes={"SequenceType": "FINISH_START"}
|
"sequence.edit_sequence", self.file, rel_sequence=rel, attributes={"SequenceType": "FINISH_START"}
|
||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.load_task_properties(task=self.task)
|
bpy.ops.bim.load_task_properties()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -616,7 +616,7 @@ class UnassignPredecessor(bpy.types.Operator):
|
|||||||
related_process=IfcStore.get_file().by_id(props.active_task_id),
|
related_process=IfcStore.get_file().by_id(props.active_task_id),
|
||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.load_task_properties(task=self.task)
|
bpy.ops.bim.load_task_properties()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -635,7 +635,7 @@ class UnassignSuccessor(bpy.types.Operator):
|
|||||||
related_process=self.file.by_id(self.task),
|
related_process=self.file.by_id(self.task),
|
||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.load_task_properties(task=self.task)
|
bpy.ops.bim.load_task_properties()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -1166,19 +1166,18 @@ class EditTaskCalendar(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
task = self.file.by_id(self.task)
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"control.assign_control",
|
"control.assign_control",
|
||||||
self.file,
|
self.file,
|
||||||
**{
|
**{
|
||||||
"relating_control": self.file.by_id(self.work_calendar),
|
"relating_control": self.file.by_id(self.work_calendar),
|
||||||
"related_object": self.file.by_id(self.task),
|
"related_object": task,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
if Data.tasks[self.task]["RelatedObjects"]:
|
bpy.ops.bim.load_task_properties()
|
||||||
bpy.ops.bim.load_task_properties()
|
|
||||||
else:
|
|
||||||
bpy.ops.bim.load_task_properties(task=self.task)
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -1190,19 +1189,18 @@ class RemoveTaskCalendar(bpy.types.Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
task = self.file.by_id(self.task)
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"control.unassign_control",
|
"control.unassign_control",
|
||||||
self.file,
|
self.file,
|
||||||
**{
|
**{
|
||||||
"relating_control": self.file.by_id(self.work_calendar),
|
"relating_control": self.file.by_id(self.work_calendar),
|
||||||
"related_object": self.file.by_id(self.task),
|
"related_object": task,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=task)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
if Data.tasks[self.task]["RelatedObjects"]:
|
bpy.ops.bim.load_task_properties()
|
||||||
bpy.ops.bim.load_task_properties()
|
|
||||||
else:
|
|
||||||
bpy.ops.bim.load_task_properties(task=self.task)
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -1294,6 +1292,7 @@ class UnassignLagTime(bpy.types.Operator):
|
|||||||
"sequence.unassign_lag_time", self.file, **{"rel_sequence": self.file.by_id(self.sequence)}
|
"sequence.unassign_lag_time", self.file, **{"rel_sequence": self.file.by_id(self.sequence)}
|
||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
|
bpy.ops.bim.load_task_properties()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -1328,6 +1327,7 @@ class EditSequenceAttributes(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.disable_editing_sequence()
|
bpy.ops.bim.disable_editing_sequence()
|
||||||
|
bpy.ops.bim.load_task_properties()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -1347,6 +1347,7 @@ class EditSequenceTimeLag(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.disable_editing_sequence()
|
bpy.ops.bim.disable_editing_sequence()
|
||||||
|
bpy.ops.bim.load_task_properties()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ def updateTaskTimeDateTime(self, context, startfinish):
|
|||||||
**{"task_time": task_time, "attributes": {startfinish_key: startfinish_datetime}},
|
**{"task_time": task_time, "attributes": {startfinish_key: startfinish_datetime}},
|
||||||
)
|
)
|
||||||
Data.load(IfcStore.get_file())
|
Data.load(IfcStore.get_file())
|
||||||
bpy.ops.bim.load_task_properties(task=props.active_task_id)
|
bpy.ops.bim.load_task_properties()
|
||||||
setattr(self, startfinish, canonicalise_time(startfinish_datetime))
|
setattr(self, startfinish, canonicalise_time(startfinish_datetime))
|
||||||
|
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ def updateTaskduration(self, context):
|
|||||||
attribute = props.task_time_attributes.get("Duration")
|
attribute = props.task_time_attributes.get("Duration")
|
||||||
if attribute:
|
if attribute:
|
||||||
attribute.string_value = self.duration
|
attribute.string_value = self.duration
|
||||||
bpy.ops.bim.load_task_properties(task=props.active_task_id)
|
bpy.ops.bim.load_task_properties()
|
||||||
|
|
||||||
|
|
||||||
def updateVisualisationStart(self, context):
|
def updateVisualisationStart(self, context):
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ class Usecase:
|
|||||||
finishes.append(self.offset_date(start, days, duration_type, self.get_calendar(predecessor)))
|
finishes.append(self.offset_date(start, days, duration_type, self.get_calendar(predecessor)))
|
||||||
else:
|
else:
|
||||||
finishes.append(start)
|
finishes.append(start)
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
if starts and finishes:
|
if starts and finishes:
|
||||||
start = max(starts)
|
start = max(starts)
|
||||||
@@ -135,8 +133,6 @@ class Usecase:
|
|||||||
),
|
),
|
||||||
"IfcDateTime",
|
"IfcDateTime",
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
for rel in task.IsPredecessorTo:
|
for rel in task.IsPredecessorTo:
|
||||||
self.cascade_task(rel.RelatedProcess)
|
self.cascade_task(rel.RelatedProcess)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import ifcopenshell.api
|
||||||
import ifcopenshell.util.date
|
import ifcopenshell.util.date
|
||||||
|
|
||||||
|
|
||||||
@@ -16,3 +17,5 @@ class Usecase:
|
|||||||
else:
|
else:
|
||||||
value = self.file.createIfcDuration(ifcopenshell.util.date.datetime2ifc(value, "IfcDuration"))
|
value = self.file.createIfcDuration(ifcopenshell.util.date.datetime2ifc(value, "IfcDuration"))
|
||||||
setattr(self.settings["lag_time"], name, value)
|
setattr(self.settings["lag_time"], name, value)
|
||||||
|
for rel in [r for r in self.file.get_inverse(self.settings["lag_time"]) if r.is_a("IfcRelSequence")]:
|
||||||
|
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=rel.RelatedProcess)
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
import ifcopenshell
|
||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
@@ -8,3 +12,7 @@ class Usecase:
|
|||||||
def execute(self):
|
def execute(self):
|
||||||
for name, value in self.settings["attributes"].items():
|
for name, value in self.settings["attributes"].items():
|
||||||
setattr(self.settings["rel_sequence"], name, value)
|
setattr(self.settings["rel_sequence"], name, value)
|
||||||
|
if "SequenceType" in self.settings["attributes"].keys():
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"sequence.cascade_schedule", self.file, task=self.settings["rel_sequence"].RelatedProcess
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import ifcopenshell.api
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, **settings):
|
def __init__(self, file, **settings):
|
||||||
self.file = file
|
self.file = file
|
||||||
@@ -9,5 +12,9 @@ class Usecase:
|
|||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
if len(self.file.get_inverse(self.settings["rel_sequence"].TimeLag)) == 1:
|
if len(self.file.get_inverse(self.settings["rel_sequence"].TimeLag)) == 1:
|
||||||
return self.file.remove(self.settings["rel_sequence"].TimeLag)
|
self.file.remove(self.settings["rel_sequence"].TimeLag)
|
||||||
self.settings["rel_sequence"].TimeLag = None
|
else:
|
||||||
|
self.settings["rel_sequence"].TimeLag = None
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"sequence.cascade_schedule", self.file, task=self.settings["rel_sequence"].RelatedProcess
|
||||||
|
)
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ class Usecase:
|
|||||||
for rel in self.settings["related_process"].IsSuccessorFrom or []:
|
for rel in self.settings["related_process"].IsSuccessorFrom or []:
|
||||||
if rel.RelatingProcess == self.settings["relating_process"]:
|
if rel.RelatingProcess == self.settings["relating_process"]:
|
||||||
self.file.remove(rel)
|
self.file.remove(rel)
|
||||||
|
ifcopenshell.api.run("sequence.cascade_schedule", self.file, task=self.settings["related_process"])
|
||||||
|
|||||||
Reference in New Issue
Block a user