From ab0ade2091c3b6f45923dd6867349a1d5df92784 Mon Sep 17 00:00:00 2001 From: Vasyl Pidhirskyi Date: Mon, 15 May 2023 15:39:38 +0300 Subject: [PATCH 1/3] Update after property changes. --- materialx/nodes/generate_node_classes.py | 2 ++ materialx/nodes/node.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index 6f46e2d8e..a2b899a4c 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -133,6 +133,8 @@ def generate_property_code(mx_param, category): if mx_type == 'filename' and category in ("texture2d", "texture3d"): prop_attr_strings.insert(0, "type=bpy.types.Image") + prop_attr_strings.append('update=MxNode.update_prop') + return f"{prop_type}({', '.join(prop_attr_strings)})" diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py index 7c612844b..00c09aebc 100644 --- a/materialx/nodes/node.py +++ b/materialx/nodes/node.py @@ -78,6 +78,9 @@ class MxNode(bpy.types.ShaderNode): _ui_folders = () # list of ui folders mentioned in nodedef category = "" + def update_prop(self, context): + self.socket_value_update(context) + @classmethod def get_nodedef(cls, data_type): if not cls._data_types[data_type]['nd']: @@ -150,6 +153,8 @@ class MxNode(bpy.types.ShaderNode): for i, nd_output in enumerate(nodedef.getActiveOutputs()): self.outputs[i].name = nd_output.getName() + self.update_prop(context) + def init(self, context): nodedef = self.nodedef @@ -368,6 +373,8 @@ class MxNode(bpy.types.ShaderNode): if f: self.inputs[i].hide = not getattr(self, self._folder_prop_name(f)) + self.update_prop(context) + def check_ui_folders(self): if not self._ui_folders: return -- 2.30.2 From 012e5e0bdd4142b45c366361c05763a0b9c6ffcf Mon Sep 17 00:00:00 2001 From: Vasyl-Pidhirskyi Date: Mon, 15 May 2023 16:31:39 +0300 Subject: [PATCH 2/3] Improved for context is None. --- materialx/nodes/node.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py index 00c09aebc..277df65e5 100644 --- a/materialx/nodes/node.py +++ b/materialx/nodes/node.py @@ -373,7 +373,8 @@ class MxNode(bpy.types.ShaderNode): if f: self.inputs[i].hide = not getattr(self, self._folder_prop_name(f)) - self.update_prop(context) + if context: + self.update_prop(context) def check_ui_folders(self): if not self._ui_folders: -- 2.30.2 From 13e9d95c08fcf8a49efb13975d1816318e3c5f5d Mon Sep 17 00:00:00 2001 From: Vasyl-Pidhirskyi Date: Wed, 17 May 2023 10:56:58 +0300 Subject: [PATCH 3/3] Improved update for link/unlink. --- materialx/nodes/node.py | 1 + 1 file changed, 1 insertion(+) diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py index 277df65e5..38f8c068a 100644 --- a/materialx/nodes/node.py +++ b/materialx/nodes/node.py @@ -123,6 +123,7 @@ class MxNode(bpy.types.ShaderNode): def update(self): bpy.app.timers.register(self.mark_invalid_links) + self.socket_value_update(bpy.context) def mark_invalid_links(self): if not is_mx_node_valid(self): -- 2.30.2