mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-07 04:46:25 +00:00
consolidate constraint utilities into ifcopenshell.util.constraint and refactor
This commit is contained in:
@@ -56,7 +56,7 @@ class ResourceData:
|
||||
"type": resource.is_a(),
|
||||
"BaseQuantity": base_quantity,
|
||||
}
|
||||
results[resource.id()]["Benchmarks"] = tool.Resource.get_resource_benchmarks(resource)
|
||||
results[resource.id()]["Benchmarks"] = cls.get_resource_benchmarks(resource)
|
||||
if resource.is_a() in ["IfcLaborResource", "IfcConstructionEquipmentResource"]:
|
||||
results[resource.id()]["Productivity"] = {}
|
||||
results[resource.id()]["InheritedProductivity"] = {}
|
||||
@@ -87,6 +87,22 @@ class ResourceData:
|
||||
)
|
||||
return results
|
||||
|
||||
@classmethod
|
||||
def get_resource_benchmarks(cls, resource):
|
||||
constraints = []
|
||||
for constraint in ifcopenshell.util.constraint.get_constraints(resource) or []:
|
||||
metrics = []
|
||||
for metric in ifcopenshell.util.constraint.get_metrics(constraint) or []:
|
||||
metrics.append(
|
||||
{
|
||||
"reference": ifcopenshell.util.constraint.get_metric_reference(metric),
|
||||
"Benchmark": metric.Benchmark,
|
||||
"ConstraintGrade": metric.ConstraintGrade,
|
||||
}
|
||||
)
|
||||
constraints.append({"ObjectiveQualifier": constraint.ObjectiveQualifier, "metrics": metrics})
|
||||
return constraints
|
||||
|
||||
@classmethod
|
||||
def get_productivity(cls, resource):
|
||||
return ifcopenshell.util.resource.get_productivity(resource, should_inherit=False)
|
||||
|
||||
@@ -620,7 +620,6 @@ class Resource:
|
||||
def get_constraints(cls, resource): pass
|
||||
def get_metrics(cls, constraint): pass
|
||||
def get_metric_reference(cls, metric, is_deep): pass
|
||||
def get_resource_benchmarks(cls, resource): pass
|
||||
def has_metric_constraint(cls, resource, attribute): pass
|
||||
def has_usage_metric(cls, resource): pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user