Get Index of Parent List for Items in its Sub List

I’m trying to convert a list into (x,y) where y is value in a list and x is the index number of parent list in which the value is present.


How can I get the value of x?

It’s hard to help you when we can only see a small portion of the graph and aren’t given the list structure. From the picture it looks like the list has up to @L4 so you will need to either flatten or tweak this but this method should work (it does add the number in front of empty lists so if that is undesired then you will need to do another method of filtering):

1 Like

Is there a DisignScript equivalent that you know of?

I’m not too good with DesignScript’s imperative syntax but python would be like this:

data = IN[0]
for i, v in enumerate(data):
	if v != []: v.insert(0,i)

OUT = data

addindextolist_python

1 Like

Sounds like a challenge to me :slight_smile:

@kennyb6 Here are the files if it helps
BFS.dyn (164.5 KB)
BFS.rvt (2.0 MB)

Depends on how you want your Empty Lists formatted, but here’s a start.

3 Likes

@Nick_Boyts That is exactly what I required.
Thank you.