Handle dict output

pull/4/head
Carson Katri 2022-12-09 15:51:38 -05:00
rodzic 7d539baf6a
commit 16a11e91af
1 zmienionych plików z 14 dodań i 6 usunięć

Wyświetl plik

@ -98,12 +98,20 @@ def tree(name):
outputs = builder(**builder_inputs)
# Create the output sockets
for i, result in enumerate(_as_iterable(outputs)):
if not issubclass(type(result), Type):
result = Type(value=result)
# raise Exception(f"Return value '{result}' is not a valid 'Type' subclass.")
node_group.outputs.new(result.socket_type, 'Result')
link = node_group.links.new(result._socket, group_output_node.inputs[i])
if isinstance(outputs, dict):
# Use a dict to name each return value
for i, (k, v) in enumerate(outputs.items()):
if not issubclass(type(v), Type):
v = Type(value=v)
node_group.outputs.new(v.socket_type, k)
node_group.links.new(v._socket, group_output_node.inputs[i])
else:
for i, result in enumerate(_as_iterable(outputs)):
if not issubclass(type(result), Type):
result = Type(value=result)
# raise Exception(f"Return value '{result}' is not a valid 'Type' subclass.")
node_group.outputs.new(result.socket_type, 'Result')
node_group.links.new(result._socket, group_output_node.inputs[i])
_arrange(node_group)