Creating Node - Return Multiple Outputs

Hey all,
I created a custom node and I get 2 outputs. Thing is that the node gives me 1 result containing a list and not to individual outputs.
How can I change it to give me two objects as an output?

Attached pic of node result

image

We need to see the insides of the custom node, but my guess is that you only have one Output node there, which has both the boolean and the object(s).

1 Like

Attached is a pic with the content. What should I do different?

Not the python - look at the OUTPUT node in the custom node environment.

I would like to split it to two outputs: one for the True/False and one for the object.
I tried adding another output node but with it returning the same output as the current existing one…

try something here…

2 Likes

Thanks for the response.
I am trying to write it in the form of code to help develop my coding skills to quicken further solutions.
In any case, my code was a condition to test if the input was a list or single element, that is the IsList node that will return True/False and or the first element of the list in case of it being a list or the element itself in case of it being a single element.
I would like the python node to give me to outputs as supposed to one output composing of a list with two objects…

Copy the output node and change the value which says ‘Results’ to something else. Then use a code block from your Python node the way @sovitek indicated, and wire the results of each line of the code block into the appropriate Output nodes. Note that the order of creation will define the sequencing (top to bottom = first to last).

2 Likes

Your Python node replaces the code block [a,b] in this screenshot. Add the indexers to disassemble the list, then add outputs for each result you want to push to the Dynamo environment. Be sure to name them as well. Note the order will be determined by the order you add the outputs to the canvas.

End result works like this:

1 Like

As people have stated, the Python node only has one output variable so the typical method we all use is to send the OUT variable as a list and then break it up using a code block after. This is the most efficient way to do it in Python/custom nodes as far as I’m aware.

I thought I’d also add that the input node can also be tuned to work with variable list sizes if you use the syntax ‘input: var’. This is a game changer when building custom nodes in my experience.

1 Like

Hey Gavin, love your vids - I took and still take a lot from them!

Can you explain further about the addition you suggested of adding var? I don’t really understand the utility of it. Maybe show a short example?

**Your suggestion already came in handy in a custom node that I created and had and issue and the Var solved it. Here is a link to the post in case you’re curious Get Element's LevelId - #12 by zvith

In this case it just informs a custom node to accept anything that can store itself to a variable and that it can be in the form of a list. It means that the node input takes exactly what it’s given in structure as well versus working across a list automatically.

I use it in nearly every custom node input I make in Crumple if you want to check some examples out there.

This YouTube video of the community conversation @solamour and I hosted around custom nodes may be worth reviewing: 19 - The Dyfference Between Dynamo Things - YouTube

2 Likes