diff --git a/src/bonsai/bonsai/bim/module/profile/operator.py b/src/bonsai/bonsai/bim/module/profile/operator.py index 459f9bf1ce..ba5c0f168a 100644 --- a/src/bonsai/bonsai/bim/module/profile/operator.py +++ b/src/bonsai/bonsai/bim/module/profile/operator.py @@ -18,6 +18,7 @@ import bpy import ifcopenshell.api +import ifcopenshell.util.element import bonsai.bim.helper import bonsai.tool as tool import bonsai.bim.module.model.profile as model_profile diff --git a/src/bonsai/bonsai/bim/module/spatial/prop.py b/src/bonsai/bonsai/bim/module/spatial/prop.py index c2b1def5b6..10b5ec1111 100644 --- a/src/bonsai/bonsai/bim/module/spatial/prop.py +++ b/src/bonsai/bonsai/bim/module/spatial/prop.py @@ -34,6 +34,7 @@ import bonsai.tool as tool import bonsai.core.geometry import ifcopenshell import ifcopenshell.util.element +import ifcopenshell.util.unit def get_subelement_class(self, context): diff --git a/src/bonsai/bonsai/tool/blender.py b/src/bonsai/bonsai/tool/blender.py index 5ea0cb05e8..7d15d5772c 100644 --- a/src/bonsai/bonsai/tool/blender.py +++ b/src/bonsai/bonsai/tool/blender.py @@ -803,7 +803,7 @@ class Blender(bonsai.core.tool.Blender): return collections_mapping @classmethod - def is_editable(cls, obj): + def is_editable(cls, obj: bpy.types.Object) -> bool: if obj.type not in cls.OBJECT_TYPES_THAT_SUPPORT_EDIT_MODE: return False if not (element := tool.Ifc.get_entity(obj)): diff --git a/src/bonsai/bonsai/tool/pset.py b/src/bonsai/bonsai/tool/pset.py index b4d9e936d6..e5436513db 100644 --- a/src/bonsai/bonsai/tool/pset.py +++ b/src/bonsai/bonsai/tool/pset.py @@ -327,4 +327,3 @@ class Pset(bonsai.core.tool.Pset): return value except: return value - return value diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py index c58bd7e657..b160803d0a 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/calculate_cost_item_resource_value.py @@ -102,9 +102,10 @@ def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcop for resource in resources: cost, unit = ifcopenshell.util.resource.get_cost(resource) if not cost: - cost, unit = ifcopenshell.util.resource.get_parent_cost( - resource - ) # Concept to standardise - Not defined in schema, but this makes manual scheduling of resources 10x faster and less duplicate data. + # Concept to standardise - Not defined in schema, but this makes manual scheduling of resources 10x faster and less duplicate data. + parent_cost = ifcopenshell.util.resource.get_parent_cost(resource) + assert parent_cost + cost, unit = parent_cost quantity = ifcopenshell.util.resource.get_quantity(resource) if not cost or not quantity: continue diff --git a/src/ifcopenshell-python/ifcopenshell/util/resource.py b/src/ifcopenshell-python/ifcopenshell/util/resource.py index adce5bfa3f..8a444e6371 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/resource.py +++ b/src/ifcopenshell-python/ifcopenshell/util/resource.py @@ -166,9 +166,9 @@ def get_quantity(resource: ifcopenshell.entity_instance) -> float: return duration.total_seconds() / 3600 -def get_parent_cost(resource: ifcopenshell.entity_instance) -> Union[None, tuple[float, Union[str, None]]]: - if not resource.Nests: +def get_parent_cost(resource: ifcopenshell.entity_instance) -> Union[tuple[float, Union[str, None]], None]: + if not (nests := resource.Nests): return else: - cost = get_cost(resource.Nests[0].RelatingObject) + cost = get_cost(nests[0].RelatingObject) return cost