mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 00:03:17 +00:00
Assign / unassign sequence should be specific to sequence type
I previously incorrectly believed that sequence types are mutually exclusive. E.g. you can have max 1 relationship between two tasks. Now after looking at more schedules I realise it's logically allowed to have more than one sequence relationship. For example simultaneous SS + FF.
This commit is contained in:
@@ -106,8 +106,16 @@ def assign_sequence(
|
||||
# to be 2000-01-05.
|
||||
ifcopenshell.api.sequence.cascade_schedule(model, task=formwork)
|
||||
"""
|
||||
# Matched on the type as well as the pair. Two tasks may legitimately be
|
||||
# sequenced more than once with different types — the classic case is a
|
||||
# "ladder", where a start to start lets the follower begin once the leader
|
||||
# has begun and a finish to finish stops it ending before the leader ends.
|
||||
# Both constraints are real and neither implies the other, so matching on
|
||||
# the pair alone silently hands back the wrong relationship: a caller adding
|
||||
# a second sequence would instead be handed the first, and editing the type
|
||||
# on it would destroy the constraint that was already there.
|
||||
for rel in related_process.IsSuccessorFrom or []:
|
||||
if rel.RelatingProcess == relating_process:
|
||||
if rel.RelatingProcess == relating_process and rel.SequenceType == sequence_type:
|
||||
return rel
|
||||
rel = file.create_entity(
|
||||
"IfcRelSequence",
|
||||
|
||||
@@ -156,6 +156,7 @@ class Usecase:
|
||||
self.file,
|
||||
relating_process=relating_process,
|
||||
related_process=related_process,
|
||||
sequence_type=inverse.SequenceType,
|
||||
)
|
||||
if inverse.TimeLag:
|
||||
ifcopenshell.api.sequence.assign_lag_time(
|
||||
|
||||
@@ -19,17 +19,28 @@
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.sequence
|
||||
import ifcopenshell.util.element
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def unassign_sequence(
|
||||
file: ifcopenshell.file,
|
||||
relating_process: ifcopenshell.entity_instance,
|
||||
related_process: ifcopenshell.entity_instance,
|
||||
sequence_type: Optional[str] = None,
|
||||
) -> None:
|
||||
"""Removes a sequence relationship between tasks
|
||||
|
||||
Two tasks may be sequenced more than once with different types — see
|
||||
:func:`ifcopenshell.api.sequence.assign_sequence` — so removing "the"
|
||||
relationship between a pair is ambiguous. Left unspecified, every sequence
|
||||
between the two is removed, which is what "make them unrelated" means and
|
||||
what this did before the parameter existed. Name a type to remove only that
|
||||
one and leave any others in place.
|
||||
|
||||
:param relating_process: The previous / predecessor task.
|
||||
:param related_process: The next / successor task.
|
||||
:param sequence_type: Optionally, remove only the sequence of this type.
|
||||
Choose from FINISH_START, FINISH_FINISH, START_START, or START_FINISH.
|
||||
:return: None
|
||||
|
||||
Example:
|
||||
@@ -58,9 +69,12 @@ def unassign_sequence(
|
||||
relating_process=zone1, related_process=zone2)
|
||||
"""
|
||||
for rel in related_process.IsSuccessorFrom or []:
|
||||
if rel.RelatingProcess == relating_process:
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
if rel.RelatingProcess != relating_process:
|
||||
continue
|
||||
if sequence_type is not None and rel.SequenceType != sequence_type:
|
||||
continue
|
||||
history = rel.OwnerHistory
|
||||
file.remove(rel)
|
||||
if history:
|
||||
ifcopenshell.util.element.remove_deep2(file, history)
|
||||
ifcopenshell.api.sequence.cascade_schedule(file, task=related_process)
|
||||
|
||||
Reference in New Issue
Block a user