RVTDocs.com

Room

Class
Description:
Provides access to the room topology in Autodesk Revit.
Remarks:
The room object can be queried for its boundary for use in space planning tools.
Inheritance Hierarchy:
System.Object
  Autodesk.Revit.DB.Element
    Autodesk.Revit.DB.SpatialElement
      Autodesk.Revit.DB.Architecture.Room
Syntax
public class Room : SpatialElement
Examples
private void Getinfo_Room(Room room)
{
    string message = "Room: ";

    //get the name of the room
    message += "\nRoom Name: " + room.Name;

    //get the room position
    LocationPoint location = room.Location as LocationPoint;
    XYZ point = location.Point;
    message += "\nRoom position: " + XYZToString(point);

    //get the room number
    message += "\nRoom number: " + room.Number;

    IList<IList<Autodesk.Revit.DB.BoundarySegment>> segments = room.GetBoundarySegments(new SpatialElementBoundaryOptions());
    if (null != segments)  //the room may not be bound
    {
        foreach (IList<Autodesk.Revit.DB.BoundarySegment> segmentList in segments)
        {
            message += "\nBoundarySegment of the room: ";
            foreach (Autodesk.Revit.DB.BoundarySegment boundarySegment in segmentList)
            {
                // Get curve start point
                XYZ start = boundarySegment.GetCurve().GetEndPoint(0);
                message += "\nCurve start point: " + XYZToString(start);
                // Get curve end point
                XYZ end = boundarySegment.GetCurve().GetEndPoint(1);
                message += " Curve end point: " + XYZToString(end);

                // Show the boundary elements
                message += "\nBoundary element id: " + boundarySegment.ElementId.ToString();
            }
        }
    }

    TaskDialog.Show("Revit",message);
}

// output the point's three coordinates
string XYZToString(XYZ point)
{
    return "(" + point.X + ", " + point.Y + ", " + point.Z + ")";
}