PanelScheduleView represents a panel schedule which displays information about a panel, the circuits connected to the panel, and their corresponding loads.
You can create a schedule that lists the circuits connected to a panel, and displays information about each circuit such as location on the panel, circuit name and apparent loads. Panel schedules display four main information sections: a header, circuit table, a loads summary and a footer. A new Panel Schedule view for the selected panel is displayed in the drawing area, and panel schedules are added to the project browser under the Panel Schedules folder. A panel schedule shows the following data:
Additional circuit and panel information to display can be specified in the panel schedule templates, represented in the Revit API by the PanelScheduleTemplate class.
PanelScheduleView is derived from the TableView class as is ViewSchedule. Some of the common functionality between schedules and panel schedules can be found in the Schedule Classes topic.
There are two static overloads for creating a PanelScheduleView. One overload of PanelScheduleView.CreateInstanceView() only requires the document in which to create the panel schedule and the id of the electrical panel element associated with the schedule. This method uses the default panel schedule template to create the new view. The other overload takes the id of a specific PanelScheduleTemplate to use.
The following example creates a new panel schedule from a user-selected electrical panel using the default template and switches the active view to the new panel schedule view.
Code Region: Create a panel schedule |
// Create a new panel schedule and switch to that view public void CreatePanelSchedule(UIDocument uiDocument) { Document doc = uiDocument.Document; Reference selected = uiDocument.Selection.PickObject(ObjectType.Element, "Select an electrical panel"); Element panel = doc.GetElement(selected); if (null != panel) { PanelScheduleView psv = null; using (Transaction trans = new Transaction(doc, "Create a new panel schedule")) { trans.Start(); psv = PanelScheduleView.CreateInstanceView(doc, panel.Id); trans.Commit(); } if (null != psv) { uiDocument.ActiveView = psv; // make new view the active view } else { TaskDialog.Show("Revit", "Please select one electrical panel."); } } } |
After a schedule is created, you may want to modify it. Several methods are helpful for moving data in the schedule. To move data around, use PanelScheduleView.GetCellsBySlotNumber() to get the range of cells for a specified slot number. PanelScheduleView.MoveSlotTo() moves the circuits in the source slot to the specific slot. Prior to moving the circuits, call PanelScheduleView.CanMoveSlotTo() to ensure the move is allowable.
If the moving circuit is in a group, all circuits in the group will be moved accordingly. The IsSlotGrouped() method will check if the slot is in a group. This method returns 0 if the slot is not in a group. If it is in a group, the returned value with be the group number (a value greater than 0).