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
@@ -16,7 +16,9 @@
# 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 ifcopenshell.api
import ifcopenshell.api.root
import ifcopenshell.api.nest
import ifcopenshell.api.owner
import ifcopenshell.guid
from typing import Optional
@@ -49,30 +51,30 @@ def add_cost_item(
.. code:: python
# The very first cost item must be in a cost schedule
schedule = ifcopenshell.api.run("cost.add_cost_schedule", model)
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
# You may add cost items as top level item in the schedule
item1 = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule)
item1 = ifcopenshell.api.cost.add_cost_item(model, cost_schedule=schedule)
# Alternatively you may add them as subitems
item2 = ifcopenshell.api.run("cost.add_cost_item", model, cost_item=item1)
item2 = ifcopenshell.api.cost.add_cost_item(model, cost_item=item1)
"""
settings = {"cost_schedule": cost_schedule, "cost_item": cost_item}
cost_item = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcCostItem")
cost_item = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem")
if settings["cost_schedule"]:
file.create_entity(
"IfcRelAssignsToControl",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": [cost_item],
"RelatingControl": settings["cost_schedule"],
},
)
elif settings["cost_item"]:
ifcopenshell.api.run(
"nest.assign_object", file, related_objects=[cost_item], relating_object=settings["cost_item"]
ifcopenshell.api.nest.assign_object(
file, related_objects=[cost_item], relating_object=settings["cost_item"]
)
return cost_item