# Arguments invalid in index of

**URL:** <https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941>\
**Category:** Uncategorized\
**Created:** [March 12, 2018, 8:18pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941 "2018-03-12T20:18:56Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 12, 2018, 8:18pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/1 "2018-03-12T20:18:56Z")

</div>

Hello, as far as I know this should work, but Ive tried everything and I cannont find the index number of these elements in this list. What am I doing wrong it says my argument is invalid weather or not I use strings??

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/2/22df2632de507214b226c00ec2c25c9fbe2ab392.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:** [March 12, 2018, 8:28pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/2 "2018-03-12T20:28:31Z")

</div>

I believe you want @1 for telement, not list. The node is currently looking for a list at level 1, but level 1 will always be a singleton.

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 12, 2018, 8:44pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/3 "2018-03-12T20:44:21Z")

</div>

Like this?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/3/c3a1d5ac63ed028214a212859b0808b6a5e23df1.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:** [March 12, 2018, 9:03pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/4 "2018-03-12T21:03:40Z")

</div>

No list levels for the list input. I think it will check each level by default.

Edit: You should be using the IndexOf node from DanEDU.

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 12, 2018, 9:20pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/5 "2018-03-12T21:20:46Z")

</div>

ok now we are making progress, but how do I get elements at these indicies? There is no get element at index that works with indicies in this format is there?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/2/42638b01826bffb109b37064329de96abaa3e571.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:** [March 12, 2018, 9:25pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/6 "2018-03-12T21:25:37Z")

</div>

Oddly enough I don’t think there is. Hey @erfajo, I know you have a ReplaceItems node but do you have any plans to make a GetItems node as well?

What you’ll have to do in the meantime, @mix, is write a quick python script that would get items from a list using this format. (I assume that’s what Erik would do for a custom node anyway.)

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 12, 2018, 9:27pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/7 "2018-03-12T21:27:07Z")

</div>

Thats a good Idea, but no can do, I havent learned python yet. Its on my to-do list. but by to-do list is very loooong. ☹

---

<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:** [March 12, 2018, 9:39pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/9 "2018-03-12T21:39:36Z")

</div>

Right, we use IndexOf to get the nD indices of an item, but now if you want to get items from another list at those indices (not replace them) what do you do? I’m looking for something like GetItemAtIndex.

---

<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:** [March 13, 2018, 3:07am UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/11 "2018-03-13T03:07:43Z")

</div>

I hope you don’t mind but I have been going through the forums looking for Dynamo/Python practice and took a shot at making a python script to get items using your list of indices format:

 ![listindex_danedu](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/7/b7469d8c802f55aa8378421c294ee03c1370f88a.PNG)

```
elems = IN[0]
indices = IN[1]

def recGet(ele,ind,out):
	temp = list(ind)
	if len(temp)>1:
	  recGet(ele[temp.pop(0)],temp,out)
	else:
	  out.append(ele[temp[0]])

outlist = []

for i in indices:
	recGet(elems,i,outlist)
	
OUT = outlist

```

I believe it works but I don’t know what the best format for output would be, if keeping the structure is important, then this would be it:  
 ![listindex2_danedu](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/5932d6937d5c22b924c3e6317503be9dda430917.PNG)

```
elems = IN[0]
indices = IN[1]

def recGet(ele,ind,out):
	temp = list(ind)
	tempL = []
	if len(temp)>1:
	  recGet(ele[temp.pop(0)],temp,tempL)
	  out.append(tempL)
	else:
	  out.append(ele[temp[0]])

outlist = []

for i in indices:
	recGet(elems,i,outlist)
	
OUT = outlist
```

---

<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:** [March 13, 2018, 5:33pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/13 "2018-03-13T17:33:59Z")

</div>

Nice. I would think you would want to keep list structure, but maybe you could add a toggle as an option?

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 13, 2018, 9:11pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/15 "2018-03-13T21:11:38Z")

</div>

Neither of these scripts appear to work:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/f/2f07c290dee4e4d9ff461fc52f5e11bed3851f18.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/1/51e28e32f345ea751303c59c103aad5cf66ee1bf.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/2/42746a27d77dab6f7eb26dd7e9000bbab53b3805.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/f/7fbc125f5adae165ddc3b3077a9aae73ed4ae096.png)

---

<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:** [March 14, 2018, 8:09am UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/16 "2018-03-14T08:09:47Z")

</div>

That is because for some reason your index lists are within a nested list at level 2, as seen in the picture where IN[1] comes from, the output is a 0 list, 0 list, then the indices. Try feeding that node through a flatten by n node, where the amt is 1. See below:

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/3/23f38f3ae4caec36714aad79259b02235e8b7f56.png)

Edit: Alternatively, you could replace the python node with this script:

```
elems = IN[0]
indices = IN[1]

def recGet(ele,ind,out):
	temp = list(ind)
	if len(temp)>1:
	  recGet(ele[temp.pop(0)],temp,out)
	else:
	  out.append(ele[temp[0]])

outlist = []

for i in indices:
	recGet(elems,i[0],outlist)
	
OUT = outlist

```

 ![2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/b/fb4a51b1ffc2a7c319c9af950b764f8bae463494.png)

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 14, 2018, 7:49pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/18 "2018-03-14T19:49:07Z")

</div>

I cant seem to get this node to work as indicated. Please advise.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/b/fb25f69efb33880c3282e245c94741ef1caea2e6.png)

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 14, 2018, 7:57pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/19 "2018-03-14T19:57:21Z")

</div>

Wait, it appears i found the magic list level structure, however, how do I keep the elements in their original sublist? My parent list has 3 groups, I want to find and group the elements in those groups with out losing the groups. So I should have 3 lists of 8 elements each. RN its finding 24 lists of 1 element each.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/6/767ab30451b193caa6a61ae144e15b4f5e0a8f9f.png)

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 15, 2018, 12:51pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/22 "2018-03-15T12:51:47Z")

</div>

You mean like this? This way it doesnt work at all. 😕

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/5/057145bcb508937eec3d8b842b81a4611384d8ff.png)

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 16, 2018, 1:11pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/24 "2018-03-16T13:11:10Z")

</div>

@erfajo  
Sure, im sorry, I know I dont have the most organized graphs. Ill try to explain it better here.  
these nodes appear to take the element types that I am feeding them just fine. The only problem is that it is not grouping the elements into their proper repective subgroups like your example post did. I want that. But this is what is happening:

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

However, if I turn off levels like you suggest. They dont work at all.

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

Are you suggesting that this is better, or am I doing something wrong?  
Thanks

---

<div class="post-metadata">

**Author:** ![mix](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@mix](https://forum.dynamobim.com/u/mix)\
**Post date:** [March 16, 2018, 1:57pm UTC](https://forum.dynamobim.com/t/arguments-invalid-in-index-of/19941/25 "2018-03-16T13:57:44Z")

</div>

For once I think I finally solved my own problem. I used Group by function node to do it. I grouped all the lines by their initial index which appears to be consistently the number of the sublist group the element belongs to. I have yet to test this but it is finally in the format I was after. I didnt think of this before because I still dont understand the Groupbykey or Groupbyfunction nodes (so if anyone has more documentation than what is in the dynamo dictionary on these nodes please send it my way!) but I managed to hack my way through it in a way that made sense in my brain. Here is what it looks like, please comment if you see an error in my logic. Thanks!

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