mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix bug where nested elements didn't show elements of the active task (only children)
This commit is contained in:
@@ -143,7 +143,7 @@ class Usecase:
|
||||
return next(e for e in self.file.get_inverse(self.task_time) if e.is_a("IfcTask"))
|
||||
|
||||
def handle_resource_calculation(self):
|
||||
resources = ifcopenshell.util.sequence.get_task_resources(self.task, is_deep=False)
|
||||
resources = ifcopenshell.util.sequence.get_task_resources(self.task, is_recursive=False)
|
||||
for resource in resources:
|
||||
if ifcopenshell.util.constraint.is_attribute_locked(resource, "Usage.ScheduleWork"):
|
||||
ifcopenshell.api.resource.calculate_resource_usage(self.file, resource=resource)
|
||||
|
||||
@@ -329,61 +329,28 @@ def guess_date_range(work_schedule: ifcopenshell.entity_instance):
|
||||
return earliest, latest
|
||||
|
||||
|
||||
def get_direct_task_outputs(task: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
|
||||
return [rel.RelatingProduct for rel in task.HasAssignments if rel.is_a("IfcRelAssignsToProduct")]
|
||||
def get_task_outputs(
|
||||
task: ifcopenshell.entity_instance, is_recursive: bool = False
|
||||
) -> set[ifcopenshell.entity_instance]:
|
||||
if is_recursive:
|
||||
return {o for subtask in [task] + list(get_all_nested_tasks(task)) for o in get_task_outputs(subtask)}
|
||||
return {rel.RelatingProduct for rel in task.HasAssignments if rel.is_a("IfcRelAssignsToProduct")}
|
||||
|
||||
|
||||
def get_task_outputs(task: ifcopenshell.entity_instance, is_deep: bool = False) -> list[ifcopenshell.entity_instance]:
|
||||
if not is_deep:
|
||||
return get_direct_task_outputs(task)
|
||||
else:
|
||||
return [output for nested_task in get_all_nested_tasks(task) for output in get_direct_task_outputs(nested_task)]
|
||||
def get_task_inputs(
|
||||
task: ifcopenshell.entity_instance, is_recursive: bool = False
|
||||
) -> set[ifcopenshell.entity_instance]:
|
||||
if is_recursive:
|
||||
return {o for subtask in [task] + list(get_all_nested_tasks(task)) for o in get_task_inputs(subtask)}
|
||||
return {o for rel in task.OperatesOn for o in rel.RelatedObjects if o.is_a("IfcProduct")}
|
||||
|
||||
|
||||
def get_task_inputs(task: ifcopenshell.entity_instance, is_deep: bool = False) -> list[ifcopenshell.entity_instance]:
|
||||
if not is_deep:
|
||||
return [
|
||||
object
|
||||
for rel in task.OperatesOn
|
||||
if rel.is_a("IfcRelAssignsToProcess")
|
||||
for object in rel.RelatedObjects
|
||||
if object.is_a("IfcProduct")
|
||||
]
|
||||
else:
|
||||
return [
|
||||
output
|
||||
for nested_task in get_all_nested_tasks(task)
|
||||
for output in [
|
||||
object
|
||||
for rel in nested_task.OperatesOn
|
||||
if rel.is_a("IfcRelAssignsToProcess")
|
||||
for object in rel.RelatedObjects
|
||||
if object.is_a("IfcProduct")
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
def get_task_resources(task: ifcopenshell.entity_instance, is_deep: bool = False) -> list[ifcopenshell.entity_instance]:
|
||||
if not is_deep:
|
||||
return [
|
||||
object
|
||||
for rel in task.OperatesOn
|
||||
if rel.is_a("IfcRelAssignsToProcess")
|
||||
for object in rel.RelatedObjects
|
||||
if object.is_a("IfcResource")
|
||||
]
|
||||
else:
|
||||
return [
|
||||
resource
|
||||
for nested_task in get_all_nested_tasks(task)
|
||||
for resource in [
|
||||
object
|
||||
for rel in nested_task.OperatesOn
|
||||
if rel.is_a("IfcRelAssignsToProcess")
|
||||
for object in rel.RelatedObjects
|
||||
if object.is_a("IfcResource")
|
||||
]
|
||||
]
|
||||
def get_task_resources(
|
||||
task: ifcopenshell.entity_instance, is_recursive: bool = False
|
||||
) -> set[ifcopenshell.entity_instance]:
|
||||
if is_recursive:
|
||||
return {r for subtask in [task] + list(get_all_nested_tasks(task)) for r in get_task_resources(subtask)}
|
||||
return {o for rel in task.OperatesOn for o in rel.RelatedObjects if o.is_a("IfcResource")}
|
||||
|
||||
|
||||
def has_task_outputs(task: ifcopenshell.entity_instance) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user