From 618ba5187cd556a166cc0b8cf5bd3d3585ce0295 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 9 Dec 2024 13:06:25 +0500 Subject: [PATCH] Readable error trying to create a texture style without textures #5855 --- .../bonsai/bim/module/style/operator.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/style/operator.py b/src/bonsai/bonsai/bim/module/style/operator.py index 8e05772b37..fbbc388b66 100644 --- a/src/bonsai/bonsai/bim/module/style/operator.py +++ b/src/bonsai/bonsai/bim/module/style/operator.py @@ -825,14 +825,17 @@ class EditSurfaceStyle(bpy.types.Operator, tool.Ifc.Operator): "Define shading/render style first", ) return {"CANCELLED"} - textures = tool.Ifc.run("style.add_surface_textures", textures=self.get_texture_attributes(), uv_maps=[]) - if textures: - texture_style = tool.Ifc.run( - "style.add_surface_style", - style=self.style, - ifc_class="IfcSurfaceStyleWithTextures", - attributes={"Textures": textures}, - ) + textures = self.get_texture_attributes() + if not textures: + self.report({"ERROR"}, "Cannot create texture style without any textures.") + return {"CANCELLED"} + textures = tool.Ifc.run("style.add_surface_textures", textures=textures, uv_maps=[]) + texture_style = tool.Ifc.run( + "style.add_surface_style", + style=self.style, + ifc_class="IfcSurfaceStyleWithTextures", + attributes={"Textures": textures}, + ) tool.Loader.create_surface_style_with_textures(material, shading_style, texture_style) else: attributes = tool.Style.get_style_ui_props_attributes(self.props.is_editing_class)