mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
run black
This commit is contained in:
@@ -60,8 +60,14 @@ class Usecase:
|
|||||||
self.settings = {"resource": resource}
|
self.settings = {"resource": resource}
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
metrics= ifcopenshell.util.constraint.has_metric_constraints(self.settings["resource"], "Usage.ScheduleWork")
|
metrics = ifcopenshell.util.constraint.has_metric_constraints(
|
||||||
if metrics and metrics[0].ConstraintGrade == "HARD" and metrics[0].Benchmark == "EQUALTO":
|
self.settings["resource"], "Usage.ScheduleWork"
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
metrics
|
||||||
|
and metrics[0].ConstraintGrade == "HARD"
|
||||||
|
and metrics[0].Benchmark == "EQUALTO"
|
||||||
|
):
|
||||||
return
|
return
|
||||||
amount_worked = ifcopenshell.util.resource.get_resource_required_work(
|
amount_worked = ifcopenshell.util.resource.get_resource_required_work(
|
||||||
self.settings["resource"]
|
self.settings["resource"]
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
def __init__(self, file, resource_time=None, attributes=None):
|
def __init__(self, file, resource_time=None, attributes=None):
|
||||||
"""Edits the attributes of an IfcResourceTime
|
"""Edits the attributes of an IfcResourceTime
|
||||||
@@ -76,7 +77,9 @@ class Usecase:
|
|||||||
del self.settings["attributes"]["ActualFinish"]
|
del self.settings["attributes"]["ActualFinish"]
|
||||||
|
|
||||||
for name, value in self.settings["attributes"].items():
|
for name, value in self.settings["attributes"].items():
|
||||||
metrics = ifcopenshell.util.constraint.has_metric_constraints(self.resource, "Usage." + name)
|
metrics = ifcopenshell.util.constraint.has_metric_constraints(
|
||||||
|
self.resource, "Usage." + name
|
||||||
|
)
|
||||||
if metrics and self.is_hard_constraint(metrics[0]):
|
if metrics and self.is_hard_constraint(metrics[0]):
|
||||||
continue
|
continue
|
||||||
if value:
|
if value:
|
||||||
@@ -89,12 +92,17 @@ class Usecase:
|
|||||||
):
|
):
|
||||||
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration")
|
value = ifcopenshell.util.date.datetime2ifc(value, "IfcDuration")
|
||||||
setattr(self.settings["resource_time"], name, value)
|
setattr(self.settings["resource_time"], name, value)
|
||||||
if name == "ScheduleUsage" and ifcopenshell.util.constraint.has_metric_constraints(self.resource, "Usage.ScheduleWork"):
|
if (
|
||||||
for rel in self.resource.HasAssignments or []:
|
name == "ScheduleUsage"
|
||||||
if not rel.is_a("IfcRelAssignsToProcess"):
|
and ifcopenshell.util.constraint.has_metric_constraints(
|
||||||
continue
|
self.resource, "Usage.ScheduleWork"
|
||||||
task = rel.RelatingProcess
|
)
|
||||||
ifcopenshell.api.run("sequence.calculate_task_duration", self.file, task=task)
|
):
|
||||||
|
task = ifcopenshell.util.resource.get_task_assignments(self.resource)
|
||||||
|
if task:
|
||||||
|
ifcopenshell.api.run(
|
||||||
|
"sequence.calculate_task_duration", self.file, task=task
|
||||||
|
)
|
||||||
|
|
||||||
def is_hard_constraint(self, metric):
|
def is_hard_constraint(self, metric):
|
||||||
return bool(metric.ConstraintGrade == "HARD" and metric.Benchmark == "EQUALTO")
|
return bool(metric.ConstraintGrade == "HARD" and metric.Benchmark == "EQUALTO")
|
||||||
|
|||||||
Reference in New Issue
Block a user