diff --git a/ui/presets.py b/ui/presets.py index 5b6a4c2f09..2660ade84f 100644 --- a/ui/presets.py +++ b/ui/presets.py @@ -336,7 +336,7 @@ def description(cls, context, properties): return "Load node settings from the preset `{}' (overwrite current settings)".format(properties.preset_name) def execute(self, context): - ntree = context.space_data.node_tree + ntree = context.space_data.path[-1].node_tree # in case if the node in a node group node = ntree.nodes[self.node_name] id_tree = ntree.name ng = bpy.data.node_groups[id_tree] diff --git a/utils/sv_json_struct.py b/utils/sv_json_struct.py index 0d8a96e3eb..f27a334473 100644 --- a/utils/sv_json_struct.py +++ b/utils/sv_json_struct.py @@ -11,6 +11,7 @@ import sys from abc import abstractmethod, ABC from enum import Enum, auto +from itertools import chain from typing import Type, Generator, TYPE_CHECKING, Dict, Tuple, Optional, List, Any import bpy @@ -73,7 +74,7 @@ def grab_from_module(cls) -> StructFactory: module_classes = inspect.getmembers(sys.modules[__name__], lambda member: inspect.isclass(member) and member.__module__ == __name__) for class_name, module_class in module_classes: - if hasattr(module_class, 'type') and module_class.type in StrTypes: + if hasattr(module_class, 'type') and isinstance(module_class.type, StrTypes): factory_classes.append(module_class) return cls(factory_classes) @@ -363,6 +364,12 @@ def build(self, node): for node in tree.nodes: imported_structs[StrTypes.NODE, tree.name, node.name] = node.name + # in case the node is inside group tree it should be also imported with its sockets + # to be able connect links to group out/in nodes + imported_structs[StrTypes.TREE, '', tree.name] = tree.name + for sock in chain(tree.inputs, tree.outputs): + imported_structs[StrTypes.INTERFACE, tree.name, sock.identifier] = sock.identifier + # import the node and rebuild the links if possible node_struct.build(node, factories, imported_structs) node.location = location # return to initial position, it has to be after node build