Application: Rooms
Revit Platform: Architecture
Revit Version: 2011.0
First Released For: 9.1
Programming Language: C#
Skill Level: Beginning
Category: Rooms/Spaces
Type: ExternalCommand

Subject: Room data retrieval and modification.
Summary: 
 This sample demonstrates how to get Room’s information (Number, Area, Department, etc), add room tags and change Room numbers.

Classes: 
Autodesk.Revit.UI.IExternalCommand
Autodesk.Revit.DB.Creation.Document
Autodesk.Revit.DB.Architecture.Room
Autodesk.Revit.DB.Architecture.RoomTag
Autodesk.Revit.DB.Parameters.BuiltInParameter

Project Files: 
Command.cs
This file contains the class Command which inherits from IExternalCommand interface and implements the Execute method.

RoomsData.cs
This class defines a data class for implementing all the functionalities of this sample, such as: get Room’s information (Area, Department, etc), add Room Tags, change Room Number and so on.

RoomInfoForm.cs
This file contains a Form class which consists of two ListView controls: one is for showing the Number, Area, and Department information of Rooms, the other one is for showing the total Area of different Room Departments.

Description: 
This sample uses Rooms and Creation classes mostly to implement the functionality: get Room’s information (Number, Department, Tags, etc), add Tags to Room and change Room’s number.
-	Room objects can be gotten via ActiveDocument.Elements property.
-	To add Tags for Room, use Document.Create.NewRoomTag method.
-	To get department and area of Room, use BuiltInParameter.ROOM_DEPARTMENT and BuiltInParameter.ROOM_AREA as parameters for Room.get_Parameter() methods.
-	Number property of Room can be used to get/set the Room’s Number.

Instructions: 
1.	Draw some Walls and Rooms in Revit firstly (you can define different Departments for Rooms or delete some Rooms’ tags for the following steps).
2.	Click the extern command, the Rooms Information form will be popped up: information (Name, Number, Department, etc) of all Rooms will be listed in upper ListView control, the lower ListView control will list total areas for different Departments.
3.	Click “Add Tags” button to add tags for the Rooms which don’t have Tags.
4.	Click the “Reorder” button, the Numbers of all Rooms will be sorted by ascending order according to Room’s Location coordinate value (first is Z, next is X, the last is Y).
5.	Click “Export” button to export the Department summary Area to a .csv file.

Notes: 
Because we need location of room when adding tag, this sample will skip those rooms which don’t locate at level yet (Room.Location property is null for those rooms).