black format

This commit is contained in:
Andrej730
2024-04-09 16:44:26 +05:00
parent 8df04091ff
commit 846ff3b9fd
@@ -23,36 +23,36 @@ import ifcopenshell.util.element
class Usecase:
def __init__(self, file, cost_item=None):
"""Copies all cost items and related relationships
The following relationships are also duplicated:
* The copy will have the same attributes and property sets as the original cost item
* The copy will be assigned to the parent cost schedule
* The copy will have duplicated nested cost items
:param cost_item: The cost item to be duplicated
:type cost_item: ifcopenshell.entity_instance.entity_instance
:return: The duplicated cost item or the list of duplicated cost items if the latter has children
:rtype: ifcopenshell.entity_instance.entity_instance or list of ifcopenshell.entity_instance.entity_instance
Example:
.. code:: python
# We have a cost item
cost_item = CostItem(name="Design new feature", deadline="2023-03-01")
# And now we have two
duplicated_cost_item = project.duplicate_cost_item(cost_item)
duplicated_cost_item = project.duplicate_cost_item(cost_item)
"""
self.file = file
self.settings = {"cost_item": cost_item}
def execute(self):
self.new_cost_items = []
self.duplicate_cost_item(self.settings["cost_item"])
def duplicate_cost_item(self, cost_item):
new_cost_item = ifcopenshell.util.element.copy_deep(self.file, cost_item)
self.new_cost_items.append(new_cost_item)
@@ -64,9 +64,7 @@ class Usecase:
if inverse.is_a("IfcRelDefinesByProperties"):
inverse = ifcopenshell.util.element.copy(self.file, inverse)
inverse.RelatedObjects = [to_element]
pset = ifcopenshell.util.element.copy_deep(
self.file, inverse.RelatingPropertyDefinition
)
pset = ifcopenshell.util.element.copy_deep(self.file, inverse.RelatingPropertyDefinition)
inverse.RelatingPropertyDefinition = pset
elif inverse.is_a("IfcRelNests") and inverse.RelatingObject == from_element:
nested_cost_items = [e for e in inverse.RelatedObjects]
@@ -79,9 +77,7 @@ class Usecase:
inverse.RelatingObject = to_element
inverse.RelatedObjects = new_cost_items
for cost_item in new_cost_items:
ifcopenshell.api.run(
"nest.unassign_object", self.file, related_object=cost_item
)
ifcopenshell.api.run("nest.unassign_object", self.file, related_object=cost_item)
rel = ifcopenshell.api.run(
"nest.assign_object",
self.file,