OR statement in custom node

I am trying to set the code to check the following, if (A == 0 || (A != “HZ” || “AA”)) then give me the output on a list…
where A = Element.GetParameterValueByName
and 0 stands for empty String box. Namely say check my parameter cell in Revit and if either is not filled out at all or filled out with something else than HZ and AA provide me the list. I am pretty sure that I am not using the OR condition properly since both statements individually give me right result… Qforum

Hi @el.kik

Is this what you need?

Hey @Kulkul,
very helpful answer, thanks!
I substituted the middle part with the code block and worked just fine! Also instead of “Or” I used the logical ||. Do you know the difference between them?


Or will take a variable number of boolean inputs. You can increase or decrease the number of inputs by using the ‘+’ and ‘-’ buttons on the Or node. Each input must be a single boolean value. Or will return ‘true’ if at least one of the inputs are true, otherwise if all inputs are ‘false’, it will return ‘false’ where as || is the Or operator. It takes two boolean values as input and returns true if one or both values are true. If both values are false, it will return false.

@el.kik Please mark the post as solved. You’re welcome :slight_smile:

Another question on that would be, what if I had 100 name variations instead of just two.
I tried to make x in code block as an array of string but it didnt work:
X!= {“AA”,“AB”,“AC”,“AD”,“AE”…“AZ”};
I guess I have to program that with for loop in code block, right?

Couldn’t you do a List.Contains instead? To output a true if it is not in the list, do !List.Contains(checkList, item). That way you can control the test against with a list.


@kennyb6 the thing is, that I do not want a boolean result, but the list of unequal items and my input comes from GetParameter node as you can see in the picture…
I am currently trying to solve it with script, however I am new to IronPython…so if you have any suggestions please go ahead!

Something like this?

In your script, return is meant for inside of a custom defined function, you don’t need it for normal for loops.

Also when you do for i in something, the i is not the index of an item inside something but the actual value. list[i] != ab[j] will not work. So the first loop, i will be the first item inside something, and then the second loop, it will be the next item. This means that you cannot do something[i] because i is not the number. Instead, you can do i != j.

Lastly, the same thing done using List.Contains:

Thanks for the tips, the last year I worked with java so I am used to this typing scheme :smiley:
However, the List.Contains method does not work for me, I am using Dynamo 1.3.4 by the way. Whould that play a role?

You could solve using List.AllIndices node. Advantage of this node is that it will sort your list with your 100 names in order:

Well played @Kulkul ! I will definitely use it in the future, while I see how smooth the filtering and sorting goes with visual programming. For my initial problem above my query runs well but now I have issue with highlighting the List.FilterByBoolMask elements. My Override commands are not dynamic and the color won’t change even if I fix the wrong entries… I post a printscrn soon!