mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
* Disable task editing if task was deleted as a result of deleting its parent * Optimize logic for bigger number of tasks * Don't try to disable editing if not editing in the first place
This commit is contained in:
@@ -513,13 +513,25 @@ class RemoveTask(bpy.types.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
props = context.scene.BIMWorkScheduleProperties
|
props = context.scene.BIMWorkScheduleProperties
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
edited_task_ifc = self.file.by_id(props.active_task_id) if props.active_task_id else None
|
||||||
|
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"sequence.remove_task",
|
"sequence.remove_task",
|
||||||
self.file,
|
self.file,
|
||||||
task=IfcStore.get_file().by_id(self.task),
|
task=self.file.by_id(self.task),
|
||||||
)
|
)
|
||||||
Data.load(self.file)
|
Data.load(self.file)
|
||||||
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
bpy.ops.bim.enable_editing_tasks(work_schedule=props.active_work_schedule_id)
|
||||||
|
|
||||||
|
if edited_task_ifc:
|
||||||
|
if not any(
|
||||||
|
task
|
||||||
|
for task in context.scene.BIMTaskTreeProperties.tasks
|
||||||
|
if task.ifc_definition_id == props.active_task_id
|
||||||
|
and self.file.by_id(props.active_task_id) == edited_task_ifc
|
||||||
|
): # Task was deleted
|
||||||
|
bpy.ops.bim.disable_editing_task()
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user