From 60174fbb16bcbd6d9f4112a38afeed60f9014135 Mon Sep 17 00:00:00 2001 From: Swann Martinez Date: Thu, 11 Jul 2019 17:09:01 +0200 Subject: [PATCH] fix: material nodes parameters loading --- helpers.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/helpers.py b/helpers.py index 691682c..2add769 100644 --- a/helpers.py +++ b/helpers.py @@ -494,12 +494,14 @@ def load_material(target=None, data=None, create=False): target.node_tree.nodes[index].image = bpy.data.images[data["node_tree"]["nodes"][node]['image']['name']] for input in data["node_tree"]["nodes"][node]["inputs"]: - + try: - target.node_tree.nodes[index].inputs[input].default_value = data[ - "node_tree"]["nodes"][node]["inputs"][input]["default_value"] - except: - pass + if hasattr(target.node_tree.nodes[index].inputs[input],"default_value"): + target.node_tree.nodes[index].inputs[input].default_value = data[ + "node_tree"]["nodes"][node]["inputs"][input]["default_value"] + except Exception as e: + logger.error("Fail loading {} node value from {} ({}) ".format(target.name, target.node_tree.nodes[index].inputs[input].default_value,e)) + continue # Load nodes links target.node_tree.links.clear() @@ -613,7 +615,7 @@ def dump(key): elif target_type == 'Material': data = dump_datablock(target, 2) if target.node_tree: - dump_datablock_attibute(target.node_tree, ["nodes","links"] , 3, data['node_tree']) + dump_datablock_attibute(target.node_tree, ["nodes","links"] , 5, data['node_tree']) elif target_type == 'GreasePencil': data = dump_datablock(target, 2) dump_datablock_attibute(