NewRoomTag Method


Creates a new RoomTag referencing a room in the host model or in a Revit link.

Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2014

Syntax

C#
public RoomTag NewRoomTag(
	LinkElementId roomId,
	UV point,
	ElementId viewId
)
Visual Basic
Public Function NewRoomTag ( _
	roomId As LinkElementId, _
	point As UV, _
	viewId As ElementId _
) As RoomTag
Visual C++
public:
RoomTag^ NewRoomTag(
	LinkElementId^ roomId, 
	UV^ point, 
	ElementId^ viewId
)

Parameters

roomId
Type: Autodesk.Revit.DB LinkElementId
The HostOrLinkElementId of the Room.
point
Type: Autodesk.Revit.DB UV
A 2D point that defines the tag location on the level of the room.
viewId
Type: Autodesk.Revit.DB ElementId
The id of the view where the tag will be shown. If a null reference ( Nothing in Visual Basic) and the room in not in a Revit link, the view of the room will be used.

Return Value

If successful a RoomTag object will be returned, otherwise a null reference ( Nothing in Visual Basic) .

Examples

Copy C#
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;
}
Copy VB.NET
Private Function CreateRoomTag(document As Autodesk.Revit.DB.Document, room As Room) As RoomTag
    ' Create a UV structure which determine the room tag location
    Dim roomTagLocation As New UV(0, 0)

    ' Create a new room tag in the created room
    Dim roomId As New LinkElementId(room.Id)
    Dim roomTag As RoomTag = document.Create.NewRoomTag(roomId, roomTagLocation, ElementId.InvalidElementId)
    If roomTag Is Nothing Then
        Throw New Exception("Create a new room tag failed.")
    End If

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

    Return roomTag
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException viewId is not associated with a plan view or section view.
Autodesk.Revit.Exceptions InvalidOperationException viewId is null and the room is in a linked file.

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →