# ReplaceByCondition node - replace individual item with a list

**URL:** <https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913>\
**Category:** Lists-Logic\
**Created:** [January 4, 2021, 5:34pm UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913 "2021-01-04T17:34:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubenbosetti](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@rubenbosetti](https://forum.dynamobim.com/u/rubenbosetti)\
**Post date:** [January 4, 2021, 5:34pm UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/1 "2021-01-04T17:34:05Z")

</div>

I have an issue with the ReplaceByCondition node.  
I have a nested list of elements (lines in my case) and I have to replace 2 specific elements on level @1 in a specific position. I can get the specific position because the 2 elements to be replaced are unique, so ReplaceByCondition seemed an obvious solution.

But, here’s the problem:  
The elements to be substituted are 2 lines. The element to replace them are two lists.  
As you see from the image, the node is taking just the first element of the list.

Any idea on how to make it work?

I could also have used ReplaceItemAtIndex, but I would have to input to the node a specific index of the nested list, something like [0][0][1][0], and this doesn’t work either…

 ![2021.01.04_ReplaceByCondition Issue](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/8/0820c9ba828a2f75d77d3b0150c5e87b5654bd06.png)

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [January 4, 2021, 8:37pm UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/2 "2021-01-04T20:37:27Z")

</div>

Hi @rubenbosetti - I can’t see what you are feeding into your Condition here, but you could try something as follows? 🙂

The **condition** is a _predicate_, which is a fancy term for a _function_. In this case you are expected to **pass that function** , which means Dynamo will fill in a few blanks.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/d/cd97f716c9d11771cf97eb97ede491b8980a6376.png)

---

<div class="post-metadata">

**Author:** ![rubenbosetti](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@rubenbosetti](https://forum.dynamobim.com/u/rubenbosetti)\
**Post date:** [January 5, 2021, 8:40am UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/3 "2021-01-05T08:40:06Z")

</div>

Thank you very much solamur!  
That’s what I was doing, but I have no issue with this, that was working perfectly.  
The problem comes out when i try to replace an item with a list. Check this, I reproduced your script with the variant that gives me problems…

 ![2021.01.05_ReplaceByCondition Issue 3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/b/0bbed3737267cdbd2684cc2e1b9bb22bd17b488f.png)

The item “Line 3” should be replaced with a sublist with two elements. Instead the node is splitting [“Hello”,“World”] into the constituent elements and placing them separately into two different positions.

---

<div class="post-metadata">

**Author:** ![rubenbosetti](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@rubenbosetti](https://forum.dynamobim.com/u/rubenbosetti)\
**Post date:** [January 5, 2021, 8:53am UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/4 "2021-01-05T08:53:39Z")

</div>

Another way to do it could be this: (on the right side of the image)

 ![2021.01.05_ReplaceByCondition Issue 4](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/7/b7edbfb194e952eb2badee7a388097412fc4b5d0.png)

But I don’t know how I can use design script sintax for putting a specific index of sublists in input…

---

<div class="post-metadata">

**Author:** ![rubenbosetti](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@rubenbosetti](https://forum.dynamobim.com/u/rubenbosetti)\
**Post date:** [January 5, 2021, 9:44am UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/5 "2021-01-05T09:44:12Z")

</div>

I’ve half-solved this using design script. It was more simple than expected (top right of the image):

 ![2021.01.05_ReplaceByCondition Issue 5](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/5/35059ba2bae39bc7ed282f7ddd80e888b47d9b93.png)

Although it won’t be simple to do this if you have multiple indexes to replace…

---

<div class="post-metadata">

**Author:** ![Bjorn\_Keulemans1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bjorn_keulemans1/32/54676_2.png) [@Bjorn\_Keulemans1](https://forum.dynamobim.com/u/Bjorn_Keulemans1)\
**Post date:** [January 5, 2021, 10:01am UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/6 "2021-01-05T10:01:07Z")

</div>

![replace](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/6/16d0484b5c0b9198d224a2482fc1a6ec7efeafee.png)

---

<div class="post-metadata">

**Author:** ![rubenbosetti](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@rubenbosetti](https://forum.dynamobim.com/u/rubenbosetti)\
**Post date:** [January 5, 2021, 1:09pm UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/7 "2021-01-05T13:09:23Z")

</div>

brilliant!

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [January 5, 2021, 2:52pm UTC](https://forum.dynamobim.com/t/replacebycondition-node-replace-individual-item-with-a-list/58913/8 "2021-01-05T14:52:24Z")

</div>

Ah yes, for multiple elements please do use @Bjorn_Keulemans1’s solution 😃

The _ReplaceByCondition_ node is coded as a singleton and won’t allow you to use **List@Level** or **Lacing** that would allow for your desired solution.
