ifcopenshell.api.cost.calculate_cost_item_resource_value

Module Contents

ifcopenshell.api.cost.calculate_cost_item_resource_value.calculate_cost_item_resource_value(file, cost_item=None) None

Calculates the total cost of all resources associated with a cost item

A cost item may have construction resources (e.g. equipment, material, etc) assigned to it. Construction resources may be assigned directly to the cost item, or assigned first to a task, and the task is then assigned to the cost item.

The cost of a resource is calculated by the total sum of all of its base costs. If no quantity is provided, that sum is considered to be the total cost. Otherwise, it is considered to be a unit cost, and is then multiplied by the resource quantity. The quantity is either stored as a base quantity (such as a volume) for a things like material resources, or as a duration as a daily rate for labour resources.

The final calculated cost is set as the cost item’s value. Any previously existing values are removed.

Parameters:

cost_item (ifccopenshell.entity_instance.entity_instance) – The IfcCostItem to calculate

Returns:

None

Return type:

None

Example:

# First, we need a cost schedule and item
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
item = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)

# Let's imagine we have our own formworking crew
crew = ifcopenshell.api.run("resource.add_resource", model, ifc_class="IfcCrewResource")

# ... and they need concrete
concrete = ifcopenshell.api.run("resource.add_resource", model,
    ifc_class="IfcConstructionMaterialResource", parent_resource=crew)
ifcopenshell.api.run("control.assign_control", model,
    relating_control=item, related_object=concrete)
# ... which has a unit price of 42.0 per m3
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=concrete)
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
    attributes={"AppliedValue": 42.0})
# ... and a volume of 200m3
quantity = ifcopenshell.api.run("resource.add_resource_quantity", model,
    resource=concrete, ifc_class="IfcQuantityVolume")
ifcopenshell.api.run("resource.edit_resource_quantity", model,
    physical_quantity=quantity, "attributes": {"VolumeValue": 200.0})

# Let's say they also need some equipment
equipment = ifcopenshell.api.run("resource.add_resource", model,
    ifc_class="IfcConstructionEquipmentResource", parent_resource=crew)
ifcopenshell.api.run("control.assign_control", model,
    relating_control=item, related_object=equipment)
# ... with a fixed price of 50,000
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=concrete)
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
    attributes={"AppliedValue": 42.0})

# (42 * 200) + 50000 = 58400 is our calculated cost
ifcopenshell.api.run("cost.calculate_cost_item_resource_value", model, cost_item=item)