log external styles names when they fail to load

This commit is contained in:
Andrej730
2024-04-03 17:35:09 +05:00
parent af3e2e0cf3
commit 14efd59ff8
2 changed files with 9 additions and 4 deletions
@@ -330,16 +330,21 @@ class ActivateExternalStyle(bpy.types.Operator, tool.Ifc.Operator):
style_path = Path(tool.Ifc.resolve_uri(external_style.Location))
if style_path.suffix != ".blend":
self.report({"ERROR"}, f"Error loading external style - only Blender external styles are supported")
self.report(
{"ERROR"},
f"Error loading external style for \"{material.name}\" - only Blender external styles are supported",
)
return {"CANCELLED"}
if not style_path.exists():
self.report({"ERROR"}, f"Error loading external style - cannot find file: '{style_path}'")
self.report(
{"ERROR"}, f"Error loading external style for \"{material.name}\" - cannot find file: '{style_path}'"
)
return {"CANCELLED"}
db = tool.Blender.append_data_block(str(style_path), data_block_type, data_block)
if not db["data_block"]:
self.report({"ERROR"}, f"Error loading external style - {db['msg']}")
self.report({"ERROR"}, f"Error loading external style for \"{material.name}\" - {db['msg']}")
return {"CANCELLED"}
self.copy_material_attributes(db["data_block"], material)
@@ -259,7 +259,7 @@ def update_shading_style(self, context):
try:
bpy.ops.bim.activate_external_style(material_name=blender_material.name)
except RuntimeError as error:
if str(error).startswith("Error: Error loading external style - "):
if str(error).startswith("Error: Error loading external style for "):
return
raise error