# Getting sublists from list automated

**URL:** <https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663>\
**Category:** DesignScript\
**Created:** [August 3, 2020, 1:02pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663 "2020-08-03T13:02:56Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 3, 2020, 1:02pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/1 "2020-08-03T13:02:56Z")

</div>

Hello,  
I have a list of 7 items which are basically 7 houses, which have further sublists. Manually its easy for me to get any list giving index from 0 to 6 as shown in figure. I want to make it flexible and automated. Because sometimes it could be 5 or 4 houses and then it would be 5 or 4 main lists respectively. I dont know how to make it autoamated so as each time i run it should count how much items it has and give me that much of lists separately ![C1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/b/cb8ac0093600e960d01ff49cd45f02423415adae.png)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 3, 2020, 1:07pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/2 "2020-08-03T13:07:24Z")

</div>

Does this help?

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

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 3, 2020, 1:17pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/3 "2020-08-03T13:17:05Z")

</div>

yes i also tried on counting and its helping but whats bothering me is the next step. For example, ok we got to know that the list has 6 items now should it automatically create 6 different lists. As we can manually use List.GetItemAtIndex 6 times to create 6 separate lists

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 3, 2020, 1:26pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/4 "2020-08-03T13:26:47Z")

</div>

How about this?

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

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 3, 2020, 1:33pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/5 "2020-08-03T13:33:32Z")

</div>

This node says it would repeat an item by certain number of times. My case is i think different

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [August 3, 2020, 1:39pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/6 "2020-08-03T13:39:07Z")

</div>

I think you need to post more of what you’re trying to do with a dynamo graph.  
Explaining it all in text can be very confusing.

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 3, 2020, 1:57pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/7 "2020-08-03T13:57:32Z")

</div>

For example, In this picture, we can split this list to 4 times as we can manually get every main list. Suppose next time it is having 8 items in main list instead of 4. I want to automatiacally create other small lists equal to main items in this main sublist.

 ![D1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/e/fe0992d4e0587bd1f7f4ade1b71557d3a4338be0.png)

---

<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 3, 2020, 3:02pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/8 "2020-08-03T15:02:14Z")

</div>

What is the reasoning for this? I’m guessing whatever you’re going to do with those separated lists can be done with sublists. Breaking your graph apart to do the same thing multiple times is actually what you should be avoiding. Proper lacing and list levels will probably get you what you want.

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 3, 2020, 3:10pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/9 "2020-08-03T15:10:46Z")

</div>

you are right and upto some extent i was doing with lists considering suitable lacing. But actually the results i have to show separately for each house and then within same house for each level. Thats why i have to divivde in the end.

---

<div class="post-metadata">

**Author:** ![Robert\_Younger](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/robert_younger/32/205603_2.png) [@Robert\_Younger](https://forum.dynamobim.com/u/Robert_Younger)\
**Post date:** [August 3, 2020, 5:59pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/10 "2020-08-03T17:59:02Z")

</div>

That may get tricky. Taking your base example, you are developing 7 lists that then need to get pushed into at least 7 new nodes, and then revising it so that 5 lists get pushed into at least 5 nodes, etc… What you are in effect asking for is for the script to re-build itself.

It may help to take a quick step back: what is your next task after generating multiple lists? Do you need to do unique things to each list? If not, there’s probably some method available that allows the list to stay grouped.

---

<div class="post-metadata">

**Author:** ![FabioDeAgostini](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/fabiodeagostini/32/93820_2.png) [@FabioDeAgostini](https://forum.dynamobim.com/u/FabioDeAgostini)\
**Post date:** [August 3, 2020, 7:16pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/11 "2020-08-03T19:16:41Z")

</div>

List.Chop with length 1 will do it

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 6:38am UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/12 "2020-08-04T06:38:16Z")

</div>

After getting each separate list from list i am doing all these tasks for each separate list as shown in green colored group in picture. I need to divide each inti two groups (R and S) Based on paramter given in Revit , then exploding the geometry(Solids) of both groups, getting its botom suface area and area of walls of mass.

 ![h1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/f/6f5904f27579afb5bf7708b26ac2a7b2af4565ea.png)

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 6:38am UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/13 "2020-08-04T06:38:40Z")

</div>

After getting each separate list from list i am doing all these tasks for each separate list as shown in green colored group in picture. I need to divide each inti two groups (R and S) Based on paramter given in Revit , then exploding the geometry(Solids) of both groups, getting its botom suface area and area of walls of mass

 ![h1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/f/6f5904f27579afb5bf7708b26ac2a7b2af4565ea.png)

---

<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 4, 2020, 1:49pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/14 "2020-08-04T13:49:05Z")

</div>

So all you have to do is make that group of nodes work for a list rather than a single input. You can either turn it into a custom node and make the custom node run for each sublist or you can make each individual node work for a sublist of elements. It’s all about list structure and lacing/list levels.

Start by using a Transpose node to “flip” your sublists from pairs to `x[0]` and `x[1]` sublists.

---

<div class="post-metadata">

**Author:** ![shershahbacha9](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@shershahbacha9](https://forum.dynamobim.com/u/shershahbacha9)\
**Post date:** [August 4, 2020, 2:08pm UTC](https://forum.dynamobim.com/t/getting-sublists-from-list-automated/53663/15 "2020-08-04T14:08:43Z")

</div>

Thanks @Nick_Boyts. You were right I did all in one long listing.
