(n: bpy.types.Node)
| 49 | |
| 50 | |
| 51 | def collect_node_data(n: bpy.types.Node): |
| 52 | ns, inputs, outputs, dependencies = [], [], [], [] |
| 53 | node_data = {"inputs": inputs, "outputs": outputs, "node_specific": ns, "bl_idname": n.bl_idname} |
| 54 | is_group = False |
| 55 | |
| 56 | if n.bl_idname == "ShaderNodeGroup" or n.bl_idname[0:11] == "SvGroupNode": |
| 57 | is_group = True |
| 58 | |
| 59 | # certain nodes that do not support some operations, like having no .inputs or .outputs, |
| 60 | node_exclude_list = ['NodeReroute', 'NodeGroupInput', 'NodeGroupOutput'] |
| 61 | socket_field_list = ['default_value', "value", "objectName", "fontName", "category", "groupName", "textBlockName", |
| 62 | "sequenceName", 'isUsed', 'easeIn', 'easeOut'] |
| 63 | |
| 64 | # types that can be converted to lists |
| 65 | list_types = (Color, Vector, Euler, Quaternion, bpy.types.bpy_prop_array) |
| 66 | |
| 67 | if n.bl_idname not in node_exclude_list: # Reroute does have in and out, but does not know type until linked |
| 68 | # inputs |
| 69 | for j in range(len(n.inputs)): |
| 70 | socket = n.inputs[j] |
| 71 | data = {"index": j, "bl_idname": socket.bl_idname, 'values': {}} |
| 72 | for i in socket_field_list: |
| 73 | try: |
| 74 | val = eval("socket.{}".format(i)) |
| 75 | if isinstance(val, list_types): # list |
| 76 | data["values"][i] = make_list(val) |
| 77 | elif isinstance(val, (str, bool)): |
| 78 | data["values"][i] = val |
| 79 | elif isinstance(val, (float, int)): |
| 80 | data["values"][i] = round(val, ROUND) |
| 81 | except AttributeError: |
| 82 | pass |
| 83 | |
| 84 | if data['values']: |
| 85 | inputs.append(data) |
| 86 | |
| 87 | # outputs |
| 88 | for j in range(len(n.outputs)): |
| 89 | socket = n.outputs[j] |
| 90 | data = {"index": j, "bl_idname": socket.bl_idname, 'values': {}} |
| 91 | for i in socket_field_list: |
| 92 | try: |
| 93 | val = eval("socket.{}".format(i)) |
| 94 | if isinstance(val, list_types): # list |
| 95 | data["values"][i] = make_list(val) |
| 96 | elif isinstance(val, (str, bool)): |
| 97 | data["values"][i] = val |
| 98 | elif isinstance(val, (float, int)): |
| 99 | data["values"][i] = round(val, ROUND) |
| 100 | except AttributeError: |
| 101 | pass |
| 102 | |
| 103 | if data['values']: |
| 104 | outputs.append(data) |
| 105 | elif n.bl_idname == "NodeGroupInput": |
| 106 | temp = [] |
| 107 | for i in n.outputs: |
| 108 | temp.append(i.bl_idname) |
no test coverage detected