Quellcode durchsuchen

v0.12.21 fix absolutely inexcusable group node bug

Joseph Brandenburg vor 1 Monat
Ursprung
Commit
9118961d79
4 geänderte Dateien mit 25 neuen und 21 gelöschten Zeilen
  1. 1 1
      __init__.py
  2. 1 1
      blender_manifest.toml
  3. 5 2
      i_o.py
  4. 18 17
      ops_nodegroup.py

+ 1 - 1
__init__.py

@@ -18,7 +18,7 @@ from .utilities import prRed
 
 MANTIS_VERSION_MAJOR=0
 MANTIS_VERSION_MINOR=12
-MANTIS_VERSION_SUB=20
+MANTIS_VERSION_SUB=21
 
 classLists = [module.TellClasses() for module in [
  link_nodes_ui,

+ 1 - 1
blender_manifest.toml

@@ -3,7 +3,7 @@ schema_version = "1.0.0"
 # Example of manifest file for a Blender extension
 # Change the values according to your extension
 id = "mantis"
-version = "0.12.20"
+version = "0.12.21"
 name = "Mantis"
 tagline = "Mantis is a rigging nodes toolkit"
 maintainer = "Nodespaghetti <josephbburg@protonmail.com>"

+ 5 - 2
i_o.py

@@ -406,6 +406,7 @@ def get_node_data(ui_node):
         finally: # ensure this line is run even if there is an error
             ui_node.is_updating = False
     node_props, inputs, outputs = {}, {}, {}
+    node_props["inputs"], node_props['outputs'] = {}, {} # just good to have a default
     for propname  in dir(ui_node):
         value = getattr(ui_node, propname)
         if propname in ['fake_fcurve_ob']:
@@ -558,8 +559,10 @@ def export_to_json(trees, base_tree=None, path="", write_file=True, only_selecte
         in_sockets, out_sockets = {}, {}
         unique_sockets_from, unique_sockets_to = {}, {}
 
-        in_node = {"name":"MANTIS_AUTOGEN_GROUP_INPUT", "bl_idname":"NodeGroupInput", "inputs":in_sockets}
-        out_node = {"name":"MANTIS_AUTOGEN_GROUP_OUTPUT", "bl_idname":"NodeGroupOutput", "outputs":out_sockets}
+        # TODO BUG HACK BAD UGLY WRONG this code should NOT be isolated from the node generation code!
+        # in the future, try to use dataclasses to enforce defaults and such. then as_dict() or whatever
+        in_node = {"name":"MANTIS_AUTOGEN_GROUP_INPUT", "bl_idname":"NodeGroupInput", "inputs":in_sockets, "outputs":{}}
+        out_node = {"name":"MANTIS_AUTOGEN_GROUP_OUTPUT", "bl_idname":"NodeGroupOutput", "inputs":{}, "outputs":out_sockets}
         add_input_node, add_output_node = False, False
 
         for link in tree.links:

+ 18 - 17
ops_nodegroup.py

@@ -94,24 +94,25 @@ class MantisGroupNodes(Operator):
 
             # for each node in the JSON
             for n in selected_nodes[base_tree.name][2].values():
-                for s in n["sockets"].values(): # for each socket in the node
-                    if source := s.get("source"):
-                        prGreen (s["name"], source[0], source[1])
-                        base_tree_node=base_tree.nodes.get(source[0])
-                        if s["is_output"]:
-                            for output in base_tree_node.outputs:
-                                if output.identifier == source[1]:
-                                    break
+                for socket_collection in ['inputs', 'outputs']:
+                    for s in n[socket_collection].values(): # for each socket in the node
+                        if source := s.get("source"):
+                            prGreen (s["name"], source[0], source[1])
+                            base_tree_node=base_tree.nodes.get(source[0])
+                            if s["is_output"]:
+                                for output in base_tree_node.outputs:
+                                    if output.identifier == source[1]:
+                                        break
+                                else:
+                                    raise RuntimeError(wrapRed("Socket not found when grouping"))
+                                base_tree.links.new(input=output, output=grp_node.inputs[s["name"]])
                             else:
-                                raise RuntimeError(wrapRed("Socket not found when grouping"))
-                            base_tree.links.new(input=output, output=grp_node.inputs[s["name"]])
-                        else:
-                            for s_input in base_tree_node.inputs:
-                                if s_input.identifier == source[1]:
-                                    break
-                            else:
-                                raise RuntimeError(wrapRed("Socket not found when grouping"))
-                            base_tree.links.new(input=grp_node.outputs[s["name"]], output=s_input)
+                                for s_input in base_tree_node.inputs:
+                                    if s_input.identifier == source[1]:
+                                        break
+                                else:
+                                    raise RuntimeError(wrapRed("Socket not found when grouping"))
+                                base_tree.links.new(input=grp_node.outputs[s["name"]], output=s_input)
 
             for n in delete_me: base_tree.nodes.remove(n)
             base_tree.nodes.active = grp_node