From 19dcbf5ffbb78ed81d3f49e97f4e58dd83b49fb5 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 3 Apr 2024 16:44:56 +0500 Subject: [PATCH] use default shading_styles.json in case if project's file is missing to make it consistent with how we use in similar cases default styles, symbols, etc --- .../blenderbim/bim/module/drawing/operator.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index 806fe810e8..2849becbd4 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -1596,8 +1596,14 @@ class ReloadDrawingStyles(bpy.types.Operator): json_path = Path(tool.Ifc.resolve_uri(rel_path)) if not json_path.exists(): - self.report({"ERROR"}, "Shading styles file not found: {}".format(json_path)) - return {"CANCELLED"} + ootb_resource = Path(context.scene.BIMProperties.data_dir) / "assets" / "shading_styles.json" + print( + f"WARNING. Couldn't find shading_styles for the drawing by the path: {json_path}. " + f"Default BBIM resource will be copied from {ootb_resource}" + ) + if ootb_resource.exists(): + os.makedirs(json_path.parent, exist_ok=True) + shutil.copy(ootb_resource, json_path) with open(json_path, "r") as fi: shading_styles_json = json.load(fi)