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

Document.NewRoom(Room, PlanCircuit)

Method
Description:
Creates a new room within the confines of a plan circuit, or places an unplaced room within the confines of the plan circuit.
Remarks:
This method will regenerate the document even in manual regeneration mode.
Syntax
public Room NewRoom(
	Room room,
	PlanCircuit circuit
)
Examples
Room InsertNewRoomInPlanCircuit(Autodesk.Revit.DB.Document document, Level level, Phase newConstructionPhase)
{
    // create room using Phase
    Room newScheduleRoom = document.Create.NewRoom(newConstructionPhase);

    // set the Room Number and Name
    string newRoomNumber = "101";
    string newRoomName = "Class Room 1";
    newScheduleRoom.Name = newRoomName;
    newScheduleRoom.Number = newRoomNumber;

    // Get a PlanCircuit
    PlanCircuit planCircuit = null;
    // first get the plan topology for given level
    PlanTopology planTopology = document.get_PlanTopology(level);

    // Iterate circuits in this plan topology
    foreach (PlanCircuit circuit in planTopology.Circuits)
    {
        // get the first circuit we find
        if (null != circuit)
        {
            planCircuit = circuit;
            break;
        }
    }

    Room newRoom2 = null;
    if (null != planCircuit)
    {
        using (Transaction transaction = new Transaction(document, "Create Room"))
        {
           if (transaction.Start() == TransactionStatus.Started)
           {
               // The input room must exist only in the room schedule, 
               // meaning that it does not display in any plan view.
               newRoom2 = document.Create.NewRoom(newScheduleRoom, planCircuit);
               // a model room with the same name and number is created in the 
               // view where the PlanCircuit is located
               if (null != newRoom2)
               {
                   // Give the user some information
                   TaskDialog.Show("Revit", "Room placed in Plan Circuit successfully.");
               }
               transaction.Commit();
           }
        }
    }

    return newRoom2;
}
Parameters
Parameter Type Description
room Room The room which you want to locate in the circuit. Pass <span class="keyword"><span data-languagespecifictext="cpp=nullptr|vb=Nothing|nu=null" id="LST89FE8A2A_1"></span></span> to create a new room.
circuit PlanCircuit The circuit in which you want to locate a room.
Return Value
Type Description
Room If successful the room is returned, otherwise .
Exceptions
Exception Condition
InvalidOperationException If the existing room is already placed.
ArgumentException Thrown if the room does not exist in the given document.
ArgumentException Thrown if the circuit does not exist in the given document.
InvalidOperationException Thrown if the level obtained from the circuit has no associated view .