Generate functions for all API usecases for better static code features. See #2693.

This commit is contained in:
Dion Moult
2024-05-06 14:35:39 +10:00
parent 10f894e2ea
commit d11ec67129
330 changed files with 13283 additions and 13751 deletions
@@ -23,52 +23,49 @@ import ifcopenshell.util.element
import ifcopenshell.util.resource
class Usecase:
def __init__(self, file, resource=None):
"""Calculates the work that a resource is used for
def calculate_resource_work(file, resource=None) -> None:
"""Calculates the work that a resource is used for
This is an unofficial parametric calculation that may be done on a
resource based on careful analysis of the relationships between the
costing, scheduling, and resource domains in IFC.
This is an unofficial parametric calculation that may be done on a
resource based on careful analysis of the relationships between the
costing, scheduling, and resource domains in IFC.
A resource may store a productivity rate in a property set called
EPset_Productivity. This stores three properties:
A resource may store a productivity rate in a property set called
EPset_Productivity. This stores three properties:
* BaseQuantityConsumed - a duration that the resource is consumed for.
* BaseQuantityProducedName - what quantity the resource can produce,
such as area or volume.
* BaseQuantityProducedValue - what value of that quantity the resource
can produce during that duration.
* BaseQuantityConsumed - a duration that the resource is consumed for.
* BaseQuantityProducedName - what quantity the resource can produce,
such as area or volume.
* BaseQuantityProducedValue - what value of that quantity the resource
can produce during that duration.
For example, a labour or equipment resource might produce 100m3 of
NetVolume every day (i.e. 8 hours are consumed).
For example, a labour or equipment resource might produce 100m3 of
NetVolume every day (i.e. 8 hours are consumed).
Then, if a resource is assigned to a construction task, and that
construction task is assigned to concrete slabs totalling 200m3, we can
calculate that the resource consumes 16 hours of work.
Then, if a resource is assigned to a construction task, and that
construction task is assigned to concrete slabs totalling 200m3, we can
calculate that the resource consumes 16 hours of work.
This calculated work is stored against the resource as scheduled work
under the resource time data.
This calculated work is stored against the resource as scheduled work
under the resource time data.
:param resource: The IfcConstructionResource that you want to calculate
the work performed.
:type resource: ifcopenshell.entity_instance
:return None:
:rtype: None:
"""
self.file = file
self.settings = {"resource": resource}
:param resource: The IfcConstructionResource that you want to calculate
the work performed.
:type resource: ifcopenshell.entity_instance
:return None:
:rtype: None:
"""
settings = {"resource": resource}
def execute(self):
if ifcopenshell.util.constraint.is_attribute_locked(self.settings["resource"], "Usage.ScheduleWork"):
return
amount_worked = ifcopenshell.util.resource.get_resource_required_work(self.settings["resource"])
if not amount_worked:
return
if not self.settings["resource"].Usage:
ifcopenshell.api.run(
"resource.add_resource_time",
self.file,
resource=self.settings["resource"],
)
self.settings["resource"].Usage.ScheduleWork = amount_worked
if ifcopenshell.util.constraint.is_attribute_locked(settings["resource"], "Usage.ScheduleWork"):
return
amount_worked = ifcopenshell.util.resource.get_resource_required_work(settings["resource"])
if not amount_worked:
return
if not settings["resource"].Usage:
ifcopenshell.api.run(
"resource.add_resource_time",
file,
resource=settings["resource"],
)
settings["resource"].Usage.ScheduleWork = amount_worked