Hi, I have electrical revit model and want to get room name, which linked in the arch-rvt model, architectural file not used for the space,if they used in space then we can get, but they used room, tried to search in the forum also, but not succeed,
Could any help on this regard, would appreciated, I’m attaching the both model of this revit files, if anyone can guide me with dynamo script for to get this room name in the schedule.
import clr
import sys
import System
from System.Collections.Generic import List
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
toList = lambda x : x if hasattr(x, '__iter__') else [x]
lstCats = toList(UnwrapElement(IN[0]))
out = []
cat_list = [System.Enum.ToObject(BuiltInCategory, c.Id.IntegerValue) for c in lstCats]
typed_list = List[BuiltInCategory](cat_list)
filtercat = ElementMulticategoryFilter(typed_list)
# get the host Link Document
oneElemInCurrentDoc = FilteredElementCollector(doc).WherePasses(filtercat).WhereElementIsNotElementType().FirstElement()
host = oneElemInCurrentDoc.Host
linkdoc = host.GetLinkDocument()
# get all rooms in Link Document
allRoomslnk = FilteredElementCollector(linkdoc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType()
# check rooms
calculator = SpatialElementGeometryCalculator(linkdoc)
for room in allRoomslnk:
if calculator.CanCalculateGeometry(room):
results = calculator.CalculateSpatialElementGeometry(room)
roomSolid = results.GetGeometry()
filterSolid = ElementIntersectsSolidFilter(roomSolid)
andFilter = LogicalAndFilter(filterSolid, filtercat)
elemsInRooms = FilteredElementCollector(doc).WherePasses(andFilter).WhereElementIsNotElementType()
for i in elemsInRooms:
out.append([Element.Name.__get__(room), i])
results.Dispose()
calculator.Dispose()
OUT = out
Note: However, pay attention to the heights of rooms in the linked model some elements could be found outside rooms volume
Thank you Sovitek, for your kind response in detail, as i am the beginner in the dynamo, not having programming background, could you please help me further, as i did on the same on your script, with no error after running, but i checked in schedule its not showing any room name, I am using revit version-2019 and dynamo 2.0.3.8811,
@c.poupin Thank you for pointing out, I just made sample file without sharing the original file the project privacy, didn’t notice orientation of the object,
Thank you
by mistake, Its electrical fixture, I had removed the parameter and added new parameter as text, but not getting, can you share the dyn again,
Thanks a lot for the time for helping me to this issue sort out,
Appreciated