Creates a new room on a level at a specified point.

Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)

Syntax

C#
public Room NewRoom(
	Level level,
	UV point
)
Visual Basic
Public Function NewRoom ( _
	level As Level, _
	point As UV _
) As Room
Visual C++
public:
Room^ NewRoom(
	Level^ level, 
	UV^ point
)

Parameters

level
Type: Autodesk.Revit.DB..::..Level
The level on which the room is to exist.
point
Type: Autodesk.Revit.DB..::..UV
A 2D point that dictates the location of the room on that specified level.

Return Value

If successful the new room will be returned, otherwise nullNothingnullptra null reference (Nothing in Visual Basic).

Remarks

This method will regenerate the document even in manual regeneration mode.

Examples

CopyC#
Room CreateRoom(Autodesk.Revit.DB.Document document, Level level)
{
    // Create a UV structure which determines the room location
   UV roomLocation = new UV(0, 0);

    // Create a new room
    Room room = document.Create.NewRoom(level, roomLocation);
    if (null == room)
    {
        throw new Exception("Create a new room failed.");
    }

    return room;
}
CopyVB.NET
Private Function CreateRoom(document As Autodesk.Revit.DB.Document, level As Level) As Room
    ' Create a UV structure which determines the room location
    Dim roomLocation As New UV(0, 0)

    ' Create a new room
    Dim room As Room = document.Create.NewRoom(level, roomLocation)
    If room Is Nothing Then
        Throw New Exception("Create a new room failed.")
    End If

    Return room
End Function

Exceptions

ExceptionCondition
Autodesk.Revit.Exceptions..::..ArgumentExceptionThrown if the level does not exist in the given document.

See Also