4-way switch node

I’m pretty new to Dynamo and have not found a similar subject in this forum.

I have 4 lists. I want to connect these to a node with four inputs and one output. The node needs to have an attribute which allows me to select which input will be passed to the output. Only one input will be passed to the output at a time.

Thank you for your help!

Welcome!
How to get help on the Dynamo forums - FAQ - Dynamo (dynamobim.com)

That’s a very specific selection/UI process you’re looking for. You’re going to have to create some logic yourself here.

Are you looking to return only one of the 4 input lists as a whole or only one value from each list per item? You can probably manage this with some conditional statements or a combination of UI nodes based on your criteria.

1 Like

As Nick mentioned the approach you take will depend on how hard coded into the solution your lists can be. A simple UI approach is an integer slider, corrected for 0 based indexing (list 1 is actually is index 1-1 = 0). I’d recommend taking on Dynamo Primer if you haven’t as most of the below techniques I use are covered in there:

2 Likes

I am not sure if I understood it correctly but usually if you connect a list to an input, you need check the list structure of your input data first. If you dont need a list structure you can use List.Flatten to get rid of it, afterwards your node will take the inputs one by one and run the function. But this depends on your other inputs. If your other inputs has one value while you have multiple elements in your list input, to make your script run correctly you need to use lacing operations(shortest, longest, cross product). One by one your script will take the items from the list and match it with other input and run the function.

You can check here for further information.

Thank you, Gavin. That did the trick and reduced the complexity of my script. I’m doing the Dynamo Primer, as well.

And thank you Nick_Boyts & emru-y. You’ve taught me some things.

image

1 Like