# Nested list replace items problem

**URL:** <https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267>\
**Category:** Lists-Logic\
**Created:** [August 24, 2017, 1:47pm UTC](https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267 "2017-08-24T13:47:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![isaac.wall](https://avatars.discourse-cdn.com/v4/letter/i/82dd89/32.png) [@isaac.wall](https://forum.dynamobim.com/u/isaac.wall)\
**Post date:** [August 24, 2017, 1:47pm UTC](https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267/1 "2017-08-24T13:47:57Z")

</div>

Hi all,

I have two lists with a complex structure, one of these contains indices of items i want to replace in the other.

A screenshot of parts of these lists is below, with my haphazard scribbling over the top. What I want to do is replace the items of the second list at the indices given in the first list just with a simple ‘X’. I’m sure this should be easy to do with the ReplaceItemAtIndex node but after some time experimenting with this I can’t work out a solution. I’m hoping someone out there with more experience at list management may be able to help me!

Many thanks in advance  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3f873deb35354a52cc7feedf889c6f9da457acd9.png)

---

<div class="post-metadata">

**Author:** ![lkichenin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lkichenin/32/96679_2.png) [@lkichenin](https://forum.dynamobim.com/u/lkichenin)\
**Post date:** [August 24, 2017, 2:06pm UTC](https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267/2 "2017-08-24T14:06:29Z")

</div>

Hey there,

For this task, I recommend using “Replace item at index” with lacing set to "Longest.

Maybe this was part of your testing if not you can give it a try.

Otherwise, I see you have four levels for your list so you might need to use the list levels option (as shown in the attached file).

This is my first idea, let me know wether this is the answer you needed.

Cheers,

![List level](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/b/2b2a01501cc1e018787e5a829f9a2fd076abe365.PNG)

---

<div class="post-metadata">

**Author:** ![isaac.wall](https://avatars.discourse-cdn.com/v4/letter/i/82dd89/32.png) [@isaac.wall](https://forum.dynamobim.com/u/isaac.wall)\
**Post date:** [August 24, 2017, 2:21pm UTC](https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267/3 "2017-08-24T14:21:11Z")

</div>

Hi Ikichenin,

Thanks for your reply. I tried it out and experimented with different kinds of lacing at different list levels and still haven’t been able to find quite the solution I’m look for.

The screenshot below shows what lacing at longest and with the list levels set. This kind of creates a new list for each index so only one index is replaced in each list, but what i’m looking for is the structure of the list on the left to be preserved to give the solution below:

| | 0 list  
| | | 0 X  
| | | 1 X  
| | | 2 ’  
| | | 3 ’  
| | | 4 ’  
| | | 5 ’  
| | 1 list  
| | | 0 X  
| | | 1 X  
| | | 2 ’  
| | | 3 ’  
| | | 4 ’  
| | | 5 ’  
| | 2 list  
| | | 0 X  
| | | 1 X  
| | | 2 X  
| | | 3 X  
| | | 4 ’  
| | | 5 ’  
| | 3 list  
| | | 0 X  
| | | 1 ’  
| | | 2 X  
| | | 3 X  
| | | 4 X  
| | | 5 ’

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

---

<div class="post-metadata">

**Author:** ![isaac.wall](https://avatars.discourse-cdn.com/v4/letter/i/82dd89/32.png) [@isaac.wall](https://forum.dynamobim.com/u/isaac.wall)\
**Post date:** [August 24, 2017, 2:22pm UTC](https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267/4 "2017-08-24T14:22:49Z")

</div>

A link to a test file is below if this helps things

[Test.dyn](https://forum.dynamobim.com/uploads/short-url/nxSpT5MqIFM6GAy52ZkMlUTGW9t.dyn) (12.4 KB)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 24, 2017, 2:26pm UTC](https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267/5 "2017-08-24T14:26:03Z")

</div>

Use List.ReplaceItemAtIndex from Clockwork instead. It works for lists.

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

---

<div class="post-metadata">

**Author:** ![isaac.wall](https://avatars.discourse-cdn.com/v4/letter/i/82dd89/32.png) [@isaac.wall](https://forum.dynamobim.com/u/isaac.wall)\
**Post date:** [August 24, 2017, 2:30pm UTC](https://forum.dynamobim.com/t/nested-list-replace-items-problem/14267/6 "2017-08-24T14:30:01Z")

</div>

Amazing! Thank you
