mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
black .
This commit is contained in:
@@ -316,9 +316,7 @@ class ScheduleIfcGenerator:
|
||||
# from are ordinary relationships, and they are written out as
|
||||
# IfcRelSequence like any other, so a scheduler can recompute
|
||||
# the span the same way P6 did.
|
||||
"PredefinedType": (
|
||||
"ATTENDANCE" if activity.get("Type") == "Level of Effort" else "CONSTRUCTION"
|
||||
),
|
||||
"PredefinedType": ("ATTENDANCE" if activity.get("Type") == "Level of Effort" else "CONSTRUCTION"),
|
||||
},
|
||||
)
|
||||
self.create_udf_pset(activity)
|
||||
@@ -351,12 +349,8 @@ class ScheduleIfcGenerator:
|
||||
task_time.ScheduleFinish = date(activity["FinishDate"], "IfcDateTime")
|
||||
task_time.DurationType = "WORKTIME"
|
||||
planned = activity["PlannedDuration"]
|
||||
if planned is not None and (
|
||||
float(planned) or activity["StartDate"] == activity["FinishDate"]
|
||||
):
|
||||
task_time.ScheduleDuration = date(
|
||||
timedelta(days=float(planned) / hours_per_day), "IfcDuration"
|
||||
)
|
||||
if planned is not None and (float(planned) or activity["StartDate"] == activity["FinishDate"]):
|
||||
task_time.ScheduleDuration = date(timedelta(days=float(planned) / hours_per_day), "IfcDuration")
|
||||
|
||||
for attribute, value in (
|
||||
("ActualStart", activity.get("ActualStartDate")),
|
||||
@@ -396,10 +390,7 @@ class ScheduleIfcGenerator:
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
title: self.file.create_entity(ifc_type, value)
|
||||
for title, (ifc_type, value) in udfs.items()
|
||||
},
|
||||
properties={title: self.file.create_entity(ifc_type, value) for title, (ifc_type, value) in udfs.items()},
|
||||
)
|
||||
|
||||
def create_code_pset(self, activity: Activity) -> None:
|
||||
@@ -408,14 +399,11 @@ class ScheduleIfcGenerator:
|
||||
codes = activity.get("Codes")
|
||||
if not codes:
|
||||
return
|
||||
pset = ifcopenshell.api.pset.add_pset(
|
||||
self.file, product=activity["ifc"], name="P6_ActivityCodes"
|
||||
)
|
||||
pset = ifcopenshell.api.pset.add_pset(self.file, product=activity["ifc"], name="P6_ActivityCodes")
|
||||
ifcopenshell.api.pset.edit_pset(
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={name: self.file.create_entity("IfcLabel", value)
|
||||
for name, (value, _) in codes.items()},
|
||||
properties={name: self.file.create_entity("IfcLabel", value) for name, (value, _) in codes.items()},
|
||||
)
|
||||
# A P6 code carries a short value and a readable description — "SO" and
|
||||
# "Start on Site Milestone". Both matter to a reader, and IfcProperty
|
||||
@@ -441,8 +429,7 @@ class ScheduleIfcGenerator:
|
||||
(
|
||||
rel
|
||||
for rel in successor.IsSuccessorFrom or []
|
||||
if rel.RelatingProcess == predecessor
|
||||
and rel.SequenceType == relationship["Type"]
|
||||
if rel.RelatingProcess == predecessor and rel.SequenceType == relationship["Type"]
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
@@ -229,8 +229,8 @@ class P62Ifc:
|
||||
name and value live up here.
|
||||
"""
|
||||
for code_type in root.findall("pr:ActivityCodeType", self.ns):
|
||||
self.code_types[code_type.findtext("pr:ObjectId", namespaces=self.ns)] = (
|
||||
code_type.findtext("pr:Name", namespaces=self.ns)
|
||||
self.code_types[code_type.findtext("pr:ObjectId", namespaces=self.ns)] = code_type.findtext(
|
||||
"pr:Name", namespaces=self.ns
|
||||
)
|
||||
for code in root.findall("pr:ActivityCode", self.ns):
|
||||
self.code_values[code.findtext("pr:ObjectId", namespaces=self.ns)] = (
|
||||
|
||||
@@ -85,11 +85,7 @@ class TestAssignSequence(test.bootstrap.IFC4):
|
||||
def test_not_confusing_the_two_directions_of_a_pair(self):
|
||||
task1 = ifcopenshell.api.sequence.add_task(self.file)
|
||||
task2 = ifcopenshell.api.sequence.add_task(self.file)
|
||||
forwards = ifcopenshell.api.sequence.assign_sequence(
|
||||
self.file, relating_process=task1, related_process=task2
|
||||
)
|
||||
backwards = ifcopenshell.api.sequence.assign_sequence(
|
||||
self.file, relating_process=task2, related_process=task1
|
||||
)
|
||||
forwards = ifcopenshell.api.sequence.assign_sequence(self.file, relating_process=task1, related_process=task2)
|
||||
backwards = ifcopenshell.api.sequence.assign_sequence(self.file, relating_process=task2, related_process=task1)
|
||||
assert forwards != backwards
|
||||
assert len(self.file.by_type("IfcRelSequence")) == 2
|
||||
|
||||
@@ -31,19 +31,13 @@ class TestUnassignSequence(test.bootstrap.IFC4):
|
||||
|
||||
def test_unassigning_a_sequence(self):
|
||||
predecessor, successor = self._pair()
|
||||
ifcopenshell.api.sequence.assign_sequence(
|
||||
self.file, relating_process=predecessor, related_process=successor
|
||||
)
|
||||
ifcopenshell.api.sequence.unassign_sequence(
|
||||
self.file, relating_process=predecessor, related_process=successor
|
||||
)
|
||||
ifcopenshell.api.sequence.assign_sequence(self.file, relating_process=predecessor, related_process=successor)
|
||||
ifcopenshell.api.sequence.unassign_sequence(self.file, relating_process=predecessor, related_process=successor)
|
||||
assert len(self.file.by_type("IfcRelSequence")) == 0
|
||||
|
||||
def test_doing_nothing_if_the_tasks_are_not_sequenced(self):
|
||||
predecessor, successor = self._pair()
|
||||
ifcopenshell.api.sequence.unassign_sequence(
|
||||
self.file, relating_process=predecessor, related_process=successor
|
||||
)
|
||||
ifcopenshell.api.sequence.unassign_sequence(self.file, relating_process=predecessor, related_process=successor)
|
||||
assert len(self.file.by_type("IfcRelSequence")) == 0
|
||||
|
||||
def test_unassigning_every_sequence_between_the_pair_by_default(self):
|
||||
@@ -55,9 +49,7 @@ class TestUnassignSequence(test.bootstrap.IFC4):
|
||||
related_process=successor,
|
||||
sequence_type=sequence_type,
|
||||
)
|
||||
ifcopenshell.api.sequence.unassign_sequence(
|
||||
self.file, relating_process=predecessor, related_process=successor
|
||||
)
|
||||
ifcopenshell.api.sequence.unassign_sequence(self.file, relating_process=predecessor, related_process=successor)
|
||||
assert len(self.file.by_type("IfcRelSequence")) == 0
|
||||
|
||||
def test_unassigning_only_the_named_type(self):
|
||||
@@ -97,15 +89,9 @@ class TestUnassignSequence(test.bootstrap.IFC4):
|
||||
|
||||
def test_leaving_the_other_direction_alone(self):
|
||||
task1, task2 = self._pair()
|
||||
ifcopenshell.api.sequence.assign_sequence(
|
||||
self.file, relating_process=task1, related_process=task2
|
||||
)
|
||||
ifcopenshell.api.sequence.assign_sequence(
|
||||
self.file, relating_process=task2, related_process=task1
|
||||
)
|
||||
ifcopenshell.api.sequence.unassign_sequence(
|
||||
self.file, relating_process=task1, related_process=task2
|
||||
)
|
||||
ifcopenshell.api.sequence.assign_sequence(self.file, relating_process=task1, related_process=task2)
|
||||
ifcopenshell.api.sequence.assign_sequence(self.file, relating_process=task2, related_process=task1)
|
||||
ifcopenshell.api.sequence.unassign_sequence(self.file, relating_process=task1, related_process=task2)
|
||||
rels = self.file.by_type("IfcRelSequence")
|
||||
assert len(rels) == 1
|
||||
assert rels[0].RelatingProcess == task2
|
||||
|
||||
Reference in New Issue
Block a user