Which room has a beamer?

Hello,

my script works well, unit i call the room of my beamer ?
2024-05-07_11h36_22

how can i get my instances based on that ?

my code so far?

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


# 📐🌈 Linked electromodel
linked_docs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().ToElements()
lnkInstance = [i for i in linked_docs if i.Name.Contains("FM_E")]
doclnk = lnkInstance[0].GetLinkDocument()

# 0️⃣ get rooms
rooms = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements()

# 🏓 get beamers
devices = FilteredElementCollector(doclnk).OfCategory(BuiltInCategory.OST_AudioVisualDevices).WhereElementIsNotElementType().ToElements()
beamer = [ i for i in devices if i.Symbol.FamilyName.Contains("Beamer")]
roomBeamer = [i.Room for i in beamer]

OUT = rooms, devices, roomBeamer

You could use CPython3 or use the get_Room() method

phases = {ph.Name: ph for ph in doc.Phases}
phase = phases["New Construction"]  # Use the required phase name
roomBeamer = [i.get_Room(phase) for i in beamer]

Items without a room or not associated with the phase will return null

1 Like

@Mike.Buttery ,

all of them have null. so that can`t be


there is a intersection.

Is the family location (origin) outside the room? Try different phases?
Try another category and see if you get results

1 Like

@Mike.Buttery

i did a workaround… it works perfectly

import clr
import sys 


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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


# 📐🌈 Linked electromodel
linked_docs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().ToElements()
lnkInstance = [i for i in linked_docs if i.Name.Contains("FM_E")]
doclnk = lnkInstance[0].GetLinkDocument()

# 0️⃣ get rooms
rooms = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements()

# 🏓 get beamers
devices = FilteredElementCollector(doclnk).OfCategory(BuiltInCategory.OST_AudioVisualDevices).WhereElementIsNotElementType().ToElements()
beamers = [ i for i in devices if i.Symbol.FamilyName.Contains("Beamer")]
locationPoints = [i.Location.Point for i in beamers]
points = [i.ToPoint() for i in locationPoints]

output = []

for i in points:
	if doc.GetRoomAtPoint(i.ToXyz()) == None:
		output.append("No Room")
	else:
		output.append(doc.GetRoomAtPoint(i.ToXyz()))
	
OUT = output





1 Like

Do those devices have a room calculation point and does it fall within the room bounds?

The ReflectedIndexer suggests that you’re calling something that either doesn’t exist or is missing an argument.

1 Like

@Nick_Boyts ,

yes it has it. i can even see the roomsname with the lookupTable but i can`t access the information.

i had i.Room

I’ve had cases where the default Room property doesn’t work and I’ve always been able to work around it with the get_Room[Phase] method. You just need to make sure you’re providing the correct phase otherwise you’ll get a null. Although GetRoomAtPoint is valid as long as you ensure you’re using the right phase again.

1 Like

@Nick_Boyts

but here i am not considering a phase at all

output = []

for i in points:
	if doc.GetRoomAtPoint(i.ToXyz()) == None:
		output.append("No Room")
	else:
		output.append(doc.GetRoomAtPoint(i.ToXyz()))
	
OUT = output

You actually are. The default method (with no phase specified) uses the last phase in the project - same as the Room property. Both methods have alternatives to specify the phase you want to query for rooms. It’s usually pretty safe to assume the final phase is accurate for room data, since most projects don’t require rooms on multiple phases anyway.

1 Like

an example, when rooms are not necessarily created in the last phase

import sys
import clr
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
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

doors = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
room_location_doors = []
for elem in doors:
    room = next((elem.get_Room(ph) for ph in doc.Phases if elem.GetPhaseStatus(ph.Id) == DB.ElementOnPhaseStatus.New), None)
    room_location_doors.append([elem, room])
    
OUT = room_location_doors
2 Likes