Creates a new room within the confines of a plan circuit, or places an unplaced room within the confines of the plan circuit.
Namespace: Autodesk.Revit.CreationAssembly: RevitAPI (in RevitAPI.dll) Version: 26.4.0.0 (26.4.0.0)
Syntax
C#
public Room NewRoom(
Room room,
PlanCircuit circuit
)
Parameters
- room Room
- The room which you want to locate in the circuit. Pass null to create a new room.
- circuit PlanCircuit
- The circuit in which you want to locate a room.
Return Value
Room If successful the room is returned, otherwise
null.
Exceptions
Remarks
This method will regenerate the document even in manual regeneration mode.
Example
C#
Room InsertNewRoomInPlanCircuit(Autodesk.Revit.DB.Document document, Level level, Phase newConstructionPhase)
{
Room newScheduleRoom = document.Create.NewRoom(newConstructionPhase);
string newRoomNumber = "101";
string newRoomName = "Class Room 1";
newScheduleRoom.Name = newRoomName;
newScheduleRoom.Number = newRoomNumber;
PlanCircuit planCircuit = null;
PlanTopology planTopology = document.get_PlanTopology(level);
foreach (PlanCircuit circuit in planTopology.Circuits)
{
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)
{
newRoom2 = document.Create.NewRoom(newScheduleRoom, planCircuit);
if (null != newRoom2)
{
TaskDialog.Show("Revit", "Room placed in Plan Circuit successfully.");
}
transaction.Commit();
}
}
}
return newRoom2;
}
VB
Private Function InsertNewRoomInPlanCircuit(document As Autodesk.Revit.DB.Document, level As Level, newConstructionPhase As Phase) As Room
Dim newScheduleRoom As Room = document.Create.NewRoom(newConstructionPhase)
Dim newRoomNumber As String = "101"
Dim newRoomName As String = "Class Room 1"
newScheduleRoom.Name = newRoomName
newScheduleRoom.Number = newRoomNumber
Dim planCircuit As PlanCircuit = Nothing
Dim planTopology As PlanTopology = document.PlanTopology(level)
For Each circuit As PlanCircuit In planTopology.Circuits
If circuit IsNot Nothing Then
planCircuit = circuit
Exit For
End If
Next
Dim newRoom2 As Room = Nothing
If planCircuit IsNot Nothing Then
Using transaction As New Transaction(document, "Create Room")
If transaction.Start() = TransactionStatus.Started Then
newRoom2 = document.Create.NewRoom(newScheduleRoom, planCircuit)
If newRoom2 IsNot Nothing Then
TaskDialog.Show("Revit", "Room placed in Plan Circuit successfully.")
End If
transaction.Commit()
End If
End Using
End If
Return newRoom2
End Function
See Also
Reference