List management - Maintain List structure when using the Flatten List node (empty List)

How can i make data structure like

0 List
0 Material 01 ID
1 List
0 Empty List
2 List
0 Material 02 ID
3 List
0 Material 04 Id

@Chan What are you trying to achieve? post your files dyn and Revit (if needed)

1 Like

@salvatoredragotta thank you for replying

I would like to make a higher tier on the empty list. This is because the empty value disappears when I use Flatten to match the data structure. So what I would like to do is select the empty values from the list and make a higher tier like below image

try this:

OUT=[]
for lst in IN[0]:
	if lst:
		OUT.append(lst)
	else:
		OUT.append([""])
2 Likes

It really helpful!. @salvatoredragotta

but is there a way to keep “Empty List” instead of “” ??

use this code instead; no need of the List.Flatten node

OUT=[]
for lst in IN[0]:
	if lst:
		for sublst in lst:			
				OUT.append(sublst)
	else:
		OUT.append([])
2 Likes

salvatoredragotta

It works well thank you !!!

1 Like