소스 검색

fix: nodegroups JSON import

Node Groups were not importing from JSON properly because their sockets did not exist. Added ability to force update, so that the sockets will exist even though the tree is importing.
Joseph Brandenburg 8 달 전
부모
커밋
28022834e0
2개의 변경된 파일9개의 추가작업 그리고 6개의 파일을 삭제
  1. 4 3
      base_definitions.py
  2. 5 3
      i_o.py

+ 4 - 3
base_definitions.py

@@ -168,9 +168,10 @@ def poll_node_tree(self, object):
     return False
 
 # TODO: try to check identifiers instead of name.
-def node_group_update(node):
-    if (node.id_data.do_live_update == False) or (node.id_data.is_executing == True):
-        return
+def node_group_update(node, force = False):
+    if not force:
+        if (node.id_data.do_live_update == False) or (node.id_data.is_executing == True):
+            return
     # note: if (node.id_data.is_exporting == True) I need to be able to update so I can make links.
     toggle_update = node.id_data.do_live_update
     node.id_data.do_live_update = False

+ 5 - 3
i_o.py

@@ -482,6 +482,9 @@ def do_import(data, context):
                 n.inputs.remove(n.inputs[1]) # get rid of the wildcard
             # prPurple(n.bl_idname)
 
+            # if propslist["bl_idname"] in ["MantisNodeGroup"]:
+            #     n.node_tree = bpy.data.node_groups[propslist["node_tree"]]
+
             if n.bl_idname in [ "SchemaArrayInput",
                                 "SchemaArrayInputGet",
                                 "SchemaArrayOutput",
@@ -496,9 +499,8 @@ def do_import(data, context):
             if sub_tree := propslist.get("node_tree"):
                 in_group_node = True
                 n.node_tree = bpy.data.node_groups.get(sub_tree)
-                # for s_name, s_val in propslist["sockets"].items():
-                #     print( wrapRed(s_name), wrapWhite(s_val))
-                # we have to do this first or the sockets won't exist to set their data.
+                from .base_definitions import node_group_update
+                node_group_update(n, force = True)
             #
 
             for i, (s_id, s_val) in enumerate(propslist["sockets"].items()):