From the Building Coder blog:
Collect all Rooms on a Given Level
From the Revit API discussion forum thread on collecting all rooms in level xx:
Question: How can I collect all rooms on a given level?
Answer 1: You can’t collect Rooms directly, you need to collect SpatialElement instead, its parent class, and then post-process the results:
public List<Room> GetRoomFromLevel(
Document document,
Level level )
{
List<Element> Rooms
= new FilteredElementCollector( document )
...