diff --git a/src/blenderbim/blenderbim/bim/module/model/product.py b/src/blenderbim/blenderbim/bim/module/model/product.py index 36dcba4f26..b7dfa0e510 100644 --- a/src/blenderbim/blenderbim/bim/module/model/product.py +++ b/src/blenderbim/blenderbim/bim/module/model/product.py @@ -40,7 +40,7 @@ from mathutils import Vector, Matrix from bpy_extras.object_utils import AddObjectHelper from . import prop import json -from typing import Any, Union, Optional +from typing import Any, Union, Optional, assert_never class EnableAddType(bpy.types.Operator, tool.Ifc.Operator): @@ -524,13 +524,17 @@ def ensure_material_assigned(usecase_path: str, ifc_file: ifcopenshell.file, set if material_type == "IfcMaterial": assigned_material = ifcopenshell.util.element.get_material(element, should_inherit=False) assert assigned_material # Type checker. - # 1) Material usages just inherit the style from the type material, so can't override it. - # 2) If type is Set and no material argument were provided, then Set was just created + # Material usages just inherit the style from the type material, so can't override it. + elif material_type in ("IfcMaterialLayerSetUsage", "IfcMaterialProfileSetUsage"): + return + # If type is Set and no material argument were provided, then Set was just created # and not yet have any IfcMaterials. - elif material_type.endswith("Usage") or material_type.endswith("Set"): + elif material_type in ("IfcMaterialConstituentSet", "IfcMaterialLayerSet", "IfcMaterialProfileSet"): return elif material_type == "IfcMaterialList": assert False, "Current assign_material implementation requires 'material' argument for IfcMaterialList." + else: + assert_never(material_type) for element in elements[:]: if element.is_a("IfcElementType"): diff --git a/src/blenderbim/blenderbim/bim/module/model/root.py b/src/blenderbim/blenderbim/bim/module/model/root.py index 7e8d55e79a..861033b750 100644 --- a/src/blenderbim/blenderbim/bim/module/model/root.py +++ b/src/blenderbim/blenderbim/bim/module/model/root.py @@ -17,17 +17,22 @@ # along with BlenderBIM Add-on. If not, see . import bpy +import ifcopenshell.file import blenderbim.bim.handler import blenderbim.tool as tool from blenderbim.bim.ifc import IfcStore +from typing import Any -def sync_name(usecase_path, ifc_file, settings): +def sync_name(usecase_path: str, ifc_file: ifcopenshell.file, settings: dict[str, Any]) -> None: if usecase_path == "attribute.edit_attributes": element = settings["product"] elif usecase_path == "style.edit_presentation_style": element = settings["style"] + else: + raise Exception(f"Unsupported usecase: '{usecase_path}'.") + element: ifcopenshell.entity_instance if "Name" not in settings["attributes"]: return obj = tool.Ifc.get_object(element) diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index e9aeb99403..d7af95bd17 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -512,12 +512,10 @@ def get_types(type: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_in def get_shape_aspects(element: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]: - """Gets element shape aspects + """Get element's shape aspects. - :param element: The element to get the shape aspects of. - :type element: ifcopenshell.entity_instance + :param element: IfcProduct or IfcTypeProduct. :return: The associated shape aspects of the element. - :rtype: list[ifcopenshell.entity_instance] Example: