Browse Source

Fix: Ignore empty xForm inputs to node groups

this fix makes it possible to e.g. create parent-less objects by not connecting the xForm input
Joseph Brandenburg 8 months ago
parent
commit
652e4bc8d9
1 changed files with 16 additions and 13 deletions
  1. 16 13
      readtree.py

+ 16 - 13
readtree.py

@@ -122,6 +122,8 @@ def make_connections_to_ng_dummy(base_tree, tree_path_names, local_nc, all_nc, n
             continue # it isn't a real input so I don't think it is good to check it.
         to_s = inp.identifier
         if not inp.is_linked: # make an autogenerated NC for the inputs of the group node
+            if inp.bl_idname in ['xFormSocket']:
+                continue
             from .node_container_common import get_socket_value
             nc_cls = gen_nc_input_for_data(inp)
             if (nc_cls):
@@ -134,7 +136,7 @@ def make_connections_to_ng_dummy(base_tree, tree_path_names, local_nc, all_nc, n
                 # 
                 local_nc[sig] = nc_from; all_nc[sig] = nc_from
                 from_s = inp.name
-            else: # should this be an error instead?
+            else:
                 prRed("No available auto-generated class for input", *tree_path_names, np.name, inp.name)
             nc_from.outputs[from_s].connect(node=nc_to, socket=to_s, sort_id=0)
 
@@ -193,21 +195,22 @@ def data_from_tree(base_tree, tree_path, dummy_nodes, all_nc, all_schema):
     local_nc, group_nodes = {}, []
     tree_path_names = [tree.name for tree in tree_path if hasattr(tree, "name")]
     if tree_path[-1]:
-        current_tree = tree_path[-1].node_tree
+        current_tree = tree_path[-1].node_tree # this may be None.
     else:
         current_tree = base_tree
     #
-    from .utilities import clear_reroutes
-    links = clear_reroutes(list(current_tree.links))
-    gen_node_containers(base_tree, current_tree, tree_path_names, all_nc, local_nc, dummy_nodes, group_nodes, all_schema)
-    
-    from .utilities import link_node_containers
-    for link in links:
-        link_node_containers((None, *tree_path_names), link, local_nc)
-    # Now, descend into the Node Groups and recurse
-    for nc in group_nodes:
-        # ng = get_node_prototype(nc.signature, base_tree)
-        data_from_tree(base_tree, tree_path+[nc.prototype], dummy_nodes, all_nc, all_schema)
+    if current_tree: # the node-group may not have a tree set - if so, ignore it.
+        from .utilities import clear_reroutes
+        links = clear_reroutes(list(current_tree.links))
+        gen_node_containers(base_tree, current_tree, tree_path_names, all_nc, local_nc, dummy_nodes, group_nodes, all_schema)
+        
+        from .utilities import link_node_containers
+        for link in links:
+            link_node_containers((None, *tree_path_names), link, local_nc)
+        # Now, descend into the Node Groups and recurse
+        for nc in group_nodes:
+            # ng = get_node_prototype(nc.signature, base_tree)
+            data_from_tree(base_tree, tree_path+[nc.prototype], dummy_nodes, all_nc, all_schema)
     return dummy_nodes, all_nc, all_schema
 
 from .utilities import check_and_add_root, init_connections, init_dependencies, init_schema_dependencies