Keeping List Structure in Python

I am finding spaces which are under same zone. Is there any way to get space element from below image rather than showing space type?
I can go inside the “SpaceSet” list and get each element from there but by doing so I am loosing the “nested” list. Any idea how to do that?

image

It would be common courtesy to add the python code to your post using the “</>” option. :slight_smile:

Sure... sorry for that.

zones=UnwrapElement(IN[0])

output=[]
p=[]
spaces=[]
for i in zones:
	#output.append(i.GetType())
	#output.append(dir(i))
	spaces.append(i.Spaces)
for j in spaces:
	#element=doc.GetElement(i.Id)
	for i in j:
		output.append(i)	
	#p.append(i.Id.ToString())
	

	
#Assign your output to the OUT variable.
OUT =spaces,output

SpaceSet is already a list, so appending it creates a list of sublists. In order to keep spaces as nested lists you would need to append to two separate lists. One for each zone, and one to append the zone lists to a final “output” list.

zones=UnwrapElement(IN[0])

output=[]
for i in zones:
	spaceSet = []
	spaces = i.Spaces
	for j in spaces:
		spaceSet.append(j)
	output.append(spaceSet)
	
#Assign your output to the OUT variable.
OUT =output
1 Like

I’ve changed your post title to more accurately reflect the issue you posed.