How to get all spaces of a zone

Hi all! I’m looking for a way to have all spaces of a chosen zone. The ideal it could be to obtain a list in which they are all listed and divided for zone of appartenance.
Thanks to everyone in advance!

1 Like

Hi @Lucaly1994,

This should work :

#By Nick_Boyts
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
import RevitServices
import Autodesk
from Autodesk.Revit.DB import *

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import ToDSType  (bool) extension method
clr.AddReference("RevitNodes")
import Revit
# Adds ToProtoType, ToRevitType geometry conversion extension methods to objects
clr.ImportExtensions(Revit.GeometryConversion)
# Import Element wrapper extension methods
clr.ImportExtensions(Revit.Elements)
from Revit.Elements import *

zones=UnwrapElement(IN[0])

if not hasattr(zones, '__iter__'):
    zones = [zones]

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
2 Likes

Hi Alban, I’m really sorry but I don’t know anything about python so I can’t understand what i have to do. Can you explicate me better this? I have to do a custom node? I have to write this in a code block? How can I set input and output?
Thanks very much!

1 Like

Hi,

Here is a graph with the python script.


Zones HVAC.dyn (3.5 KB)

1 Like

Thanks very much Alban! Very kind!

1 Like

You’re welcome.

I just saw that there is already an existing node in the MepOver package : the Zone.Spaces node.

You can mark the topic as solved.

1 Like

Hi Alban,

I have another question regarding the zones and space.
I want to use Dynamo/ python to assign each space to a separate zone, or combine certain zones. But I am not sure which function I should use. Do you have any chance know that?