Replace all ifcopenshell.api.run with ifcopenshell.api static functions.

This commit is contained in:
Dion Moult
2024-06-28 12:36:31 +10:00
parent b5d613989e
commit 07060fc769
432 changed files with 4633 additions and 4856 deletions
@@ -55,40 +55,40 @@ def add_cost_value(file: ifcopenshell.file, parent: ifcopenshell.entity_instance
.. code:: python
# We always need a schedule first prior to adding any cost items
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
# Option 1: This cost item will have a full cost of 42.0
item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item1)
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
value = ifcopenshell.api.cost.add_cost_value(model, parent=item1)
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 42.0})
# Option 2: This cost item will have a unit cost of 5.0 per unit
# area, multiplied by the quantity of area specified explicitly as
# 3.0, giving us a subtotal cost of 15.0.
item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item2)
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value,
item2 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
value = ifcopenshell.api.cost.add_cost_value(model, parent=item2)
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value,
attributes={"AppliedValue": 5.0})
quantity = ifcopenshell.api.run("cost.add_cost_item_quantity", model,
quantity = ifcopenshell.api.cost.add_cost_item_quantity(model,
cost_item=item2, ifc_class="IfcQuantityVolume")
ifcopenshell.api.run("cost.edit_cost_item_quantity", model,
ifcopenshell.api.cost.edit_cost_item_quantity(model,
physical_quantity=quantity, "attributes": {"VolumeValue": 3.0})
# A cost value may also be specified in terms of the sum of its
# subcomponents. In this case, it's broken down into 2 subvalues.
item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item1)
subvalue1 = ifcopenshell.api.run("cost.add_cost_value", model, parent=value)
subvalue2 = ifcopenshell.api.run("cost.add_cost_value", model, parent=value)
item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
value = ifcopenshell.api.cost.add_cost_value(model, parent=item1)
subvalue1 = ifcopenshell.api.cost.add_cost_value(model, parent=value)
subvalue2 = ifcopenshell.api.cost.add_cost_value(model, parent=value)
# This specifies that the value is the sum of all subitems
# regardless of their cost category. The first subvalue is 2.0 and
# the second is 3.0, giving a total value of 5.0.
ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value, attributes={"Category": "*"})
ifcopenshell.api.run("cost.edit_cost_value", model,
ifcopenshell.api.cost.edit_cost_value(model, cost_value=value, attributes={"Category": "*"})
ifcopenshell.api.cost.edit_cost_value(model,
cost_value=subvalue1, attributes={"AppliedValue": 2.0})
ifcopenshell.api.run("cost.edit_cost_value", model,
ifcopenshell.api.cost.edit_cost_value(model,
cost_value=subvalue2, attributes={"AppliedValue": 3.0})
"""
settings = {"parent": parent}