diff --git a/src/bonsai/bonsai/bim/module/debug/operator.py b/src/bonsai/bonsai/bim/module/debug/operator.py index 8bc0c21f60..e2378e2104 100644 --- a/src/bonsai/bonsai/bim/module/debug/operator.py +++ b/src/bonsai/bonsai/bim/module/debug/operator.py @@ -92,8 +92,9 @@ class ConvertToBlender(bpy.types.Operator): for obj in bpy.data.objects: if obj.type in {"MESH", "EMPTY"}: tool.Ifc.unlink(obj=obj) - if obj.data: - obj.data.BIMMeshProperties.ifc_definition_id = 0 + data = obj.data + if tool.Geometry.has_mesh_properties(data): + data.BIMMeshProperties.ifc_definition_id = 0 for material in bpy.data.materials: tool.Ifc.unlink(obj=material) context.scene.BIMProperties.ifc_file = "" diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index c14d33bd24..80ce1a28a7 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -661,6 +661,25 @@ class Geometry(bonsai.core.tool.Geometry): return False return isinstance(data, supported_types) + @classmethod + def has_mesh_properties(cls, data: Union[bpy.types.ID, None]) -> TypeIs[ + Union[ + bpy.types.Mesh, + bpy.types.Curve, + bpy.types.Camera, + bpy.types.PointLight, + ] + ]: + supported_types = ( + bpy.types.Mesh, + bpy.types.Curve, + bpy.types.Camera, + bpy.types.PointLight, + ) + if not data: + return False + return isinstance(data, supported_types) + @classmethod def is_edited(cls, obj: bpy.types.Object) -> bool: return not all([tool.Cad.is_x(o, 1.0) for o in obj.scale]) or obj in IfcStore.edited_objs