kopia lustrzana https://github.com/carson-katri/geometry-script
Handle dict output
rodzic
7d539baf6a
commit
16a11e91af
20
api/tree.py
20
api/tree.py
|
@ -98,12 +98,20 @@ def tree(name):
|
||||||
outputs = builder(**builder_inputs)
|
outputs = builder(**builder_inputs)
|
||||||
|
|
||||||
# Create the output sockets
|
# Create the output sockets
|
||||||
for i, result in enumerate(_as_iterable(outputs)):
|
if isinstance(outputs, dict):
|
||||||
if not issubclass(type(result), Type):
|
# Use a dict to name each return value
|
||||||
result = Type(value=result)
|
for i, (k, v) in enumerate(outputs.items()):
|
||||||
# raise Exception(f"Return value '{result}' is not a valid 'Type' subclass.")
|
if not issubclass(type(v), Type):
|
||||||
node_group.outputs.new(result.socket_type, 'Result')
|
v = Type(value=v)
|
||||||
link = node_group.links.new(result._socket, group_output_node.inputs[i])
|
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)
|
_arrange(node_group)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue