# Replace By condition (list and sublist)

**URL:** <https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [November 16, 2017, 4:40pm UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568 "2017-11-16T16:40:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![clement.cazi](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@clement.cazi](https://forum.dynamobim.com/u/clement.cazi)\
**Post date:** [November 16, 2017, 4:40pm UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/1 "2017-11-16T16:40:38Z")

</div>

I have a problem with Replace By Condition Node.

When I have a list wich just one item and sublists, the node doesn’t work. The warning is “\_Converting an array to var would cause array rank reduction and is not permitted”.

but if I have a list only with sublists (even if sublists have only one item), it works.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/81a92a6f386274092d914f873f8ba75eea68c8ff.png)

Do you have and idea :

- either to convert list to have all item in sublists. I tried with List.slice but It doesn’t work very well.
- or a node like Replace By condition to works with any list structure ?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/8/58da7e0820cf0713b14a35d4a7eedbf6a60e62ae.png)

Thanks,

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 16, 2017, 4:48pm UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/2 "2017-11-16T16:48:53Z")

</div>

At first sight: see if feeding the “y” input of the == node instead of the “x” makes a difference

---

<div class="post-metadata">

**Author:** ![clement.cazi](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@clement.cazi](https://forum.dynamobim.com/u/clement.cazi)\
**Post date:** [November 17, 2017, 8:13am UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/3 "2017-11-17T08:13:29Z")

</div>

@Yna_Db, it doesn’t change anything.

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 17, 2017, 8:40am UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/4 "2017-11-17T08:40:35Z")

</div>

You could try it with “replace” nodes since your values are strings. Furthermore, they offer the possibility to play with levels. Try also those in _DanEDU_ or _Clockwork_ packages.

---

<div class="post-metadata">

**Author:** ![clement.cazi](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@clement.cazi](https://forum.dynamobim.com/u/clement.cazi)\
**Post date:** [November 17, 2017, 8:51am UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/5 "2017-11-17T08:51:26Z")

</div>

The Node “Replace” have the same issue.

I found TurnintoList node, from clockwork, and it can replace the node List.Slice.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c46d0bee993fb3cba1abb452cae85b1855a36c6a.png)

So, with tun into list, Replace By Condition Works 🙂.

Thank you for you help.

Clement

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [November 17, 2017, 9:29am UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/6 "2017-11-17T09:29:27Z")

</div>

@clement.cazi You could try this work around too …

 ![20171117-4](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/7/5704977faac22a63f8515f2d60062e268b0845c5.png)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [November 17, 2017, 9:41am UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/7 "2017-11-17T09:41:09Z")

</div>

You found one of the limitations of imperative code - mixing singletons and lists can be tricky, you usually get a “Rank Reduction” exception. If you want to stick with nodes, one way to get around this is to manually use function mapping techniques:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/9/2956b0782b5836484dd7168b4e9ee86c0aa40d68.png)

---

<div class="post-metadata">

**Author:** ![clement.cazi](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@clement.cazi](https://forum.dynamobim.com/u/clement.cazi)\
**Post date:** [November 17, 2017, 9:51am UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/8 "2017-11-17T09:51:37Z")

</div>

Thank you for all your solution.

---

<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:** [March 1, 2018, 1:18pm UTC](https://forum.dynamobim.com/t/replace-by-condition-list-and-sublist/16568/9 "2018-03-01T13:18:21Z")

</div>

5 posts were split to a new topic: [Replace By Condition (with Any List Structure)](https://forum.dynamobim.com/t/replace-by-condition-with-any-list-structure/19560)
