Преглед изворни кода

fix: autogen nodes to overlay

Joseph Brandenburg пре 1 недеља
родитељ
комит
7c0e7e9aa9
1 измењених фајлова са 27 додато и 21 уклоњено
  1. 27 21
      execution/readtree.py

+ 27 - 21
execution/readtree.py

@@ -61,7 +61,7 @@ def make_connections_to_ng_dummy(base_tree, tree_path_names, local_mantis_nodes,
         if not inp.is_linked: # make an autogenerated NC for the inputs of the group node
             # This can be run inside schema. Make it unique with uuid() to be safe.
             from uuid import uuid4
-            signature = ("MANTIS_AUTOGENERATED", *tree_path_names, to_mantis_node.ui_signature[-1], inp.identifier, inp.identifier, str(uuid4()))
+            signature = (None, *tree_path_names, to_mantis_node.ui_signature[-1]+"_"+inp.name+"_"+inp.identifier+"_"+str(uuid4()) )
             from_mantis_node = all_mantis_nodes.get(signature) # creating this without checking and
                                                                #  using UUID signature leads to TERRIBLE CONFUSING BUGS.
             if from_mantis_node is None: 
@@ -178,8 +178,10 @@ forbidden_key_names = ["",]
 forbidden_in_key_name = ['$',]
 def node_scan_overlays(node, socket_id,):
     from ..misc_nodes import SimpleInputNode
+    from ..internal_nodes import AutoGenNode
+    from ..utilities.utilities import get_ui_node
     overlay_data_type = str
-    if isinstance(node, SimpleInputNode):
+    if isinstance(node, (SimpleInputNode,AutoGenNode) ):
         overlay_data_type = type(node.parameters[list(node.outputs.values())[0].name])
     else:
         match node.inputs[socket_id].socket_type:
@@ -189,25 +191,28 @@ def node_scan_overlays(node, socket_id,):
                 overlay_data_type = float
     from ..utilities.node_common import GraphError
     interface_nodes = node.mContext.interface_nodes
-    from ..utilities.utilities import get_ui_node
-    ui_node = get_ui_node(node.ui_signature, node.base_tree)
-    # we'll assume that the overlay tag system checked if this is linked.
-    # TODO this is probably redundant with the check above this
-    # First let's check if it is a simple input node, by checking outputs that are marked "input"
-    for socket in ui_node.outputs:
-        # weird edge case for simple input nodes with unnamed sockets
-        # the socket.identifier is not used by Mantis but it defaults to 'socket'\
-        if socket.identifier == socket_id and socket.input == True: break
-    else:
-        for socket in ui_node.inputs:
-            if socket.identifier == socket_id: break
+    if not isinstance(node, AutoGenNode):
+        ui_node = get_ui_node(node.ui_signature, node.base_tree)
+        # we'll assume that the overlay tag system checked if this is linked.
+        # TODO this is probably redundant with the check above this
+        # First let's check if it is a simple input node, by checking outputs that are marked "input"
+        for socket in ui_node.outputs:
+            # weird edge case for simple input nodes with unnamed sockets
+            # the socket.identifier is not used by Mantis but it defaults to 'socket'\
+            if socket.identifier == socket_id and socket.input == True: break
         else:
-            raise KeyError(f"Socket not found by ID {socket_id} in node {node.ui_signature}\n"
-                        f"Candidates: {[socket.identifier for socket in ui_node.inputs]}")
+            for socket in ui_node.inputs:
+                if socket.identifier == socket_id: break
+            else:
+                raise KeyError(f"Socket not found by ID {socket_id} in node {node.ui_signature}\n"
+                            f"Candidates: {[socket.identifier for socket in ui_node.inputs]}")
+
+        value = socket.default_value # get the ACTUAL UI value
+        if hasattr(socket, 'overlay_text'): # TODO this is all wrong but for now
+            value = "$"+socket.overlay_text # I am not implementing the Parser feature
+    else: # since it doesn't have a UI node
+        value = node.parameters[socket_id]
     
-    value = socket.default_value # get the ACTUAL UI value
-    if hasattr(socket, 'overlay_text'): # TODO this is all wrong but for now
-        value = "$"+socket.overlay_text # I am not implementing the Parser feature
     if not isinstance(value, str): return
     # First step: get the interface nodes and the overlay keys
     # this should only check interfaces that are ancestors of this node
@@ -223,13 +228,14 @@ def node_scan_overlays(node, socket_id,):
             interface = interface_nodes.get(
                 interface_signature := (*node.signature[:index+1],
                 "InputInterface."+str( 0 ).zfill(4)))
-            if interface not in my_interfaces: my_interfaces.append(interface)
+            if interface and interface not in my_interfaces: my_interfaces.append(interface)
             if current_schema_interface_index == 0: continue # just did it
             # we need to get the schema of the current index
             interface = interface_nodes.get(
                 interface_signature := (*node.signature[:index+1],
                 "InputInterface."+str(current_schema_interface_index).zfill(4)))
-        my_interfaces.append( interface )
+        if interface:
+            my_interfaces.append( interface )
     # the my_interfaces list is sorted in REVERSE order of importance
     # Next, get all the overlay providers.
     name_to_id_map = {}