mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 08:13:14 +00:00
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
This commit is contained in:
@@ -1596,8 +1596,14 @@ class ReloadDrawingStyles(bpy.types.Operator):
|
|||||||
|
|
||||||
json_path = Path(tool.Ifc.resolve_uri(rel_path))
|
json_path = Path(tool.Ifc.resolve_uri(rel_path))
|
||||||
if not json_path.exists():
|
if not json_path.exists():
|
||||||
self.report({"ERROR"}, "Shading styles file not found: {}".format(json_path))
|
ootb_resource = Path(context.scene.BIMProperties.data_dir) / "assets" / "shading_styles.json"
|
||||||
return {"CANCELLED"}
|
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:
|
with open(json_path, "r") as fi:
|
||||||
shading_styles_json = json.load(fi)
|
shading_styles_json = json.load(fi)
|
||||||
|
|||||||
Reference in New Issue
Block a user