mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-18 03:19:53 +00:00
Replace all ifcopenshell.api.run with ifcopenshell.api static functions.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user