This commit is contained in:
Andrej730
2024-11-18 11:09:59 +05:00
parent ec521916da
commit b2e3a4dd82
10 changed files with 62 additions and 34 deletions
@@ -56,7 +56,9 @@ def get_total_quantity(root_element: ifcopenshell.entity_instance) -> Union[floa
def calculate_applied_value(
root_element: ifcopenshell.entity_instance, cost_value: ifcopenshell.entity_instance, category_filter=None
root_element: ifcopenshell.entity_instance,
cost_value: ifcopenshell.entity_instance,
category_filter: Optional[str] = None,
) -> float:
if cost_value.ArithmeticOperator and cost_value.Components:
component_values = []
@@ -211,7 +211,7 @@ def string_to_duration(duration_string):
return isodate.duration_isoformat(datetime.timedelta(days=days, hours=hours, minutes=minutes, seconds=seconds))
def parse_duration(value):
def parse_duration(value: Union[str, None]) -> Union[datetime.timedelta, None]:
if not value:
return None
if isinstance(value, str):
@@ -246,6 +246,9 @@ class BatchReassignClass:
class Migrator:
migrated_ids: dict[int, int]
attribute_overrides: dict[int, dict[int, str]]
def __init__(self):
self.migrated_ids = {}
self.attribute_overrides = {}
@@ -308,7 +311,7 @@ class Migrator:
"User": None,
}
def preprocess(self, old_file: ifcopenshell.file, new_file: ifcopenshell.file):
def preprocess(self, old_file: ifcopenshell.file, new_file: ifcopenshell.file) -> None:
to_delete = set()
if old_file.schema == "IFC2X3" and new_file.schema == "IFC4":
@@ -381,7 +384,13 @@ class Migrator:
new_element = new_file.create_entity(self.class_2x3_to_4[ifc_class])
return new_element
def migrate_attributes(self, element, new_file, new_element, new_element_schema):
def migrate_attributes(
self,
element: ifcopenshell.entity_instance,
new_file: ifcopenshell.file,
new_element: ifcopenshell.entity_instance,
new_element_schema: ifcopenshell_wrapper.declaration,
) -> ifcopenshell.entity_instance:
for attribute_index, value in self.attribute_overrides.get(element.id(), {}).items():
new_element[attribute_index] = value
for i, attribute in enumerate(new_element_schema.all_attributes()):