"IF" node for List

Hi everyone, I’m trying to work with the “if” node for lists, but when I input the list, in the cases it would be false the output is the list itself, and not the item that is returning false.

I understand this is the intended behaviour but is there a workaround to get the actual value? Searching a little bit I’ve seen people recomend the “if” node from zebra or similar packages but I wanted to avoid too many custom nodes.

Thanks in advance.

IF is an Imperative approach. In Dynamo, while working with lists, try to avoid IF

You could use List.FilterByBoolMask Instead

3 Likes

What are you trying to accomplish? That might help provide a better answer for what you are looking for.

It seems like you want to return any values over 0.5 and replace any values lower than 0.5 with 0.5? Here would be one way to do that.

1 Like

There is some jiggery pokery going on with your If node as there are some nested lists
Try and get you lists flat and then use a design script comparator - or - nodes

3 Likes


Hello, you need to filter your list first, then use an if condition. Also, make sure to set the list level properly

1 Like

Hello! Could you please tell me which package you use to organize your nodes like that? Thank you!

1 Like

This is a built in feature.

Pins were introduced in Dynamo 2.13 - more here: Dynamo Core 2.13 Release - Part 1/3 - Dynamo BIM!

6 Likes

Thanks for all the replies. Indeed this is what I’m looking to acomplish, filter and replace, not just filter. So I’ll try to follow this workflow, thanks!

PS: I tried to flatten the lists to get them to work with the “if” node as mentioned by @Mike.Buttery but seems it’s still not working and I hoped.

You will need to adjust the list levels in the If node

2 Likes

I had not considered that :see_no_evil_monkey: , but yeah, it works, thanks!

1 Like