Files
IfcOpenShell/src/ifcopenshell-python/ifcopenshell/api/resource/calculate_resource_work.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
2.9 KiB
Python
Raw Normal View History

# IfcOpenShell - IFC toolkit and geometry engine
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of IfcOpenShell.
#
# IfcOpenShell is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# IfcOpenShell is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import math
import ifcopenshell.api
2024-05-10 11:21:53 +05:00
import ifcopenshell.util.constraint
import ifcopenshell.util.date
import ifcopenshell.util.element
import ifcopenshell.util.resource
2024-05-10 11:21:53 +05:00
def calculate_resource_work(file: ifcopenshell.file, resource: ifcopenshell.entity_instance) -> None:
"""Calculates the work that a resource is used for
2022-12-16 15:07:02 +11:00
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.
2022-12-16 15:07:02 +11:00
A resource may store a productivity rate in a property set called
EPset_Productivity. This stores three properties:
2022-12-16 15:07:02 +11:00
* 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.
2022-12-16 15:07:02 +11:00
For example, a labour or equipment resource might produce 100m3 of
NetVolume every day (i.e. 8 hours are consumed).
2022-12-16 15:07:02 +11:00
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.
2022-12-16 15:07:02 +11:00
This calculated work is stored against the resource as scheduled work
under the resource time data.
2022-12-16 15:07:02 +11:00
:param resource: The IfcConstructionResource that you want to calculate
the work performed.
:type resource: ifcopenshell.entity_instance
:return None:
:rtype: None:
"""
settings = {"resource": resource}
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