Get room bounding elements from linked models

Hi,

try the python code below. Input is a list of rooms. Output is bounding elements, regardless if they are from current or linked doc.

import clr

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices

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

#The inputs to this node will be stored as a list in the IN variables.
rooms = UnwrapElement(IN[0])

options = SpatialElementBoundaryOptions()
options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish

output = []

for r in rooms:
	segments = r.GetBoundarySegments(options)
	boundaries = []
	for sl in segments:
		for s in sl:
			#boundaries.append([s.ElementId,s.LinkElementId])
			e = doc.GetElement(s.ElementId)
			if isinstance(e,RevitLinkInstance):
				linkDoc = e.GetLinkDocument()
				linkElement = linkDoc.GetElement(s.LinkElementId)
				boundaries.append(linkElement)
			else:
				boundaries.append(e)
	output.append(boundaries)

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

4 Likes