Get "name" and "area" of FromRoom

Hi everyone!

I’m new API,
I tried get “name” and “area” of FromRoom but result don’t correct.

“Room Name” contain room number and “Area” not round all element.
Please show me where is incorrect code.
Thank Advance!

===============================================================
import Autodesk
from Autodesk.Revit.DB import *

doc = revit.ActiveUIDocument.Document
uidoc = revit.ActiveUIDocument

def get_from_room_name(element):
try:
return Autodesk.Revit.DB.Element.Name.get(element.FromRoom[phase])
except:
return None

def get_from_room_area(element):
return round(((element.FromRoom[phase].Area)*0.092903),2)

phases = doc.Phases
phase = phases[phases.Size - 1]

#Select all elements category from revit
selection = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()

#get From_Room_Name
room_name =
for i in selection:
room_name.append(get_from_room_name(i))
for i in room_name:
print(i)

#get From_Room_Area
room_area =
for i in selection:
room_area.append(get_from_room_area(i))
print(room_area)

image

Hi, maybe try to change room name with basics python functions (Python Remove Character from String: A Guide | Career Karma) and the same with room area (Python round() Function)?

Hi!

You might have to use

room.LookupParameter("Room Name")

to access the Room Name parameter. Accessing the area parameter is similar, just use “Area” I think.

I hope this helps! If you’re still having trouble tomorrow I can post some code from a Room Manager script I wrote.