# OR statement in custom node

**URL:** <https://forum.dynamobim.com/t/or-statement-in-custom-node/35855>\
**Category:** Revit\
**Created:** [May 12, 2019, 1:26pm UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855 "2019-05-12T13:26:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![el.kik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/el.kik/32/71938_2.png) [@el.kik](https://forum.dynamobim.com/u/el.kik)\
**Post date:** [May 12, 2019, 1:26pm UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/1 "2019-05-12T13:26:33Z")

</div>

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](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/0/e/0e49c13ee021314c65ea175266f222b14ddd423d.jpeg)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [May 12, 2019, 2:41pm UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/2 "2019-05-12T14:41:30Z")

</div>

Hi @el.kik

Is this what you need?  
 ![image](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/3/0/306cb79cea29fa95efa35faa5549300bc21af55e.png)

---

<div class="post-metadata">

**Author:** ![el.kik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/el.kik/32/71938_2.png) [@el.kik](https://forum.dynamobim.com/u/el.kik)\
**Post date:** [May 13, 2019, 10:48am UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/3 "2019-05-13T10:48:21Z")

</div>

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?

![Capture](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/c/5/c54535313ba1808184d354ba910ee10eb4076f73.jpeg)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [May 13, 2019, 11:43am UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/4 "2019-05-13T11:43:17Z")

</div>

> [@el.kik](#):
>
> 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 🙂

---

<div class="post-metadata">

**Author:** ![el.kik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/el.kik/32/71938_2.png) [@el.kik](https://forum.dynamobim.com/u/el.kik)\
**Post date:** [May 13, 2019, 12:39pm UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/5 "2019-05-13T12:39:57Z")

</div>

Great!  
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?

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [May 14, 2019, 3:02am UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/6 "2019-05-14T03:02:01Z")

</div>

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.

![ifinlist](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/9/b/9b34b105fdb22adf449ffb40c7a8a227d14424cd.png)

---

<div class="post-metadata">

**Author:** ![el.kik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/el.kik/32/71938_2.png) [@el.kik](https://forum.dynamobim.com/u/el.kik)\
**Post date:** [May 14, 2019, 3:09pm UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/7 "2019-05-14T15:09:39Z")

</div>

@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!

 ![Captureaaa](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/d/8d0dcd45afdfc3f8adc83955e4ef16b8eb14efed.jpeg)

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [May 15, 2019, 1:26am UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/8 "2019-05-15T01:26:08Z")

</div>

Something like this?

 ![orstatementpython](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/4/343543b3fda17c38fb82409ed2ddf32d4b225621.png)

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:

 ![orstatementnode](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/0/500f1b2d624504e0f1e73de74bbc3e82268bf09d.png)

---

<div class="post-metadata">

**Author:** ![el.kik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/el.kik/32/71938_2.png) [@el.kik](https://forum.dynamobim.com/u/el.kik)\
**Post date:** [May 15, 2019, 11:05am UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/9 "2019-05-15T11:05:51Z")

</div>

Thanks for the tips, the last year I worked with java so I am used to this typing scheme 😃  
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?

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [May 16, 2019, 1:05pm UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/10 "2019-05-16T13:05:01Z")

</div>

> [@el.kik](#):
>
> 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

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

 ![Untitled](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/c/fcc5e7908722b674b502cd5bbbaa80812330445b.png)

---

<div class="post-metadata">

**Author:** ![el.kik](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/el.kik/32/71938_2.png) [@el.kik](https://forum.dynamobim.com/u/el.kik)\
**Post date:** [May 17, 2019, 8:36am UTC](https://forum.dynamobim.com/t/or-statement-in-custom-node/35855/11 "2019-05-17T08:36:10Z")

</div>

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!
