Hello
the problem is that spaces have the same name
Try this version of “Elements in Space”
#Copyright(c) 2015, Konrad Sobon
# @arch_laboratory, http://archi-lab.net
# This code is based on Family.InRoom node originally created
# by Peter Kompolschek and published on Dynamo blog. Big thanks
# to Peter for sharing his work so graciously.
# modified by Cyril Poupin
import clr
import sys
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def FamiliesInSpace(_space, _families, _doc):
outList = []
for family in _families:
location = family.Location
bbx_e = family.get_BoundingBox(None)
checkSpace = next((family.get_Space(ph) for ph in _doc.Phases if family.GetPhaseStatus(ph.Id) == ElementOnPhaseStatus.New), None)
if checkSpace is not None and _space.Id == checkSpace.Id:
outList.append(family)
else:
pt = location.Point if type(location) == LocationPoint else ( bbx_e.Min + bbx_e.Max ) * 0.5
if _space.IsPointInSpace(pt):
outList.append(family)
return outList
try:
errorReport = None
families = []
for i in IN[0]:
families.append(UnwrapElement(i))
spaces = []
for i in IN[1]:
if UnwrapElement(i).Area > 0:
spaces.append(UnwrapElement(i))
outData = [[] for i in range(len(spaces))]
for index, space in enumerate(spaces):
outData[index].extend(FamiliesInSpace(space, families, doc))
except:
# if error accurs anywhere in the process catch it
import traceback
errorReport = traceback.format_exc()
#Assign your output to the OUT variable
if errorReport == None:
OUT = outData
else:
OUT = errorReport