This commit is contained in:
Andrej730
2025-07-23 17:34:42 +05:00
parent 3dde609519
commit c82191f40b
3 changed files with 49 additions and 36 deletions
@@ -56,20 +56,18 @@ def add_cost_item(
# Alternatively you may add them as subitems
item2 = ifcopenshell.api.cost.add_cost_item(model, cost_item=item1)
"""
settings = {"cost_schedule": cost_schedule, "cost_item": cost_item}
cost_item_ = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem")
cost_item = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem")
if settings["cost_schedule"]:
if cost_schedule:
file.create_entity(
"IfcRelAssignsToControl",
**{
"GlobalId": ifcopenshell.guid.new(),
"OwnerHistory": ifcopenshell.api.owner.create_owner_history(file),
"RelatedObjects": [cost_item],
"RelatingControl": settings["cost_schedule"],
"RelatedObjects": [cost_item_],
"RelatingControl": cost_schedule,
},
)
elif settings["cost_item"]:
ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item], relating_object=settings["cost_item"])
return cost_item
elif cost_item:
ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item_], relating_object=cost_item)
return cost_item_