RVTDocs.com
Namespace: Autodesk.Revit.Creation Class: Document

Document.NewRoomTag

Method
Description:
Creates a new RoomTag referencing a room in the host model or in a Revit link.
Syntax
public RoomTag NewRoomTag(
	LinkElementId roomId,
	UV point,
	ElementId viewId
)
Examples
RoomTag CreateRoomTag(Autodesk.Revit.DB.Document document, Room room)
{
    // Create a UV structure which determine the room tag location
   UV roomTagLocation = new UV(0, 0); 

    // Create a new room tag in the created room
    LinkElementId roomId = new LinkElementId(room.Id);
    RoomTag roomTag = document.Create.NewRoomTag(roomId, roomTagLocation, ElementId.InvalidElementId);
    if (null == roomTag)
    {
        throw new Exception("Create a new room tag failed.");
    }

    // Give the user some information
    TaskDialog.Show("Revit","Room tag created successfully.");

    return roomTag;
}
Parameters
Parameter Type Description
roomId LinkElementId The HostOrLinkElementId of the Room.
point UV A 2D point that defines the tag location on the level of the room.
viewId ElementId The id of the view where the tag will be shown. If <span class="keyword"><span data-languagespecifictext="cpp=nullptr|vb=Nothing|nu=null" id="LSTE7AA469F_1"></span></span> and the room in not in a Revit link, the view of the room will be used.
Return Value
Type Description
RoomTag If successful a RoomTag object will be returned, otherwise .
Exceptions
Exception Condition
ArgumentException viewId is not associated with a plan view or section view.
InvalidOperationException viewId is null and the room is in a linked file.