The ViewSchedule class has several methods for creating new schedules depending on the type of schedule. All of the methods have a Document parameter that is the document to which the new schedule or schedule-like view will be added. The newly created schedule views will appear under the Schedules/Quantities node in the Project Browser.
A standard single-category or multi-category schedule can be created with the static ViewSchedule.CreateSchedule() method.
Code Region: ViewSchedule.CreateSchedule() |
public ViewSchedule ViewSchedule.CreateSchedule(Document document, ElementId categoryId); |
The second parameters the ID of the category whose elements will be included in the schedule, or InvalidElementId for a multi-category schedule.
A second CreateSchedule() method can be used to create an area schedule and takes an additional parameter that is the ID of an area scheme for the schedule.
Code Region: Creating an area schedule |
FilteredElementCollector collector1 = new FilteredElementCollector(doc); collector1.OfCategory(BuiltInCategory.OST_AreaSchemes); //Get first ElementId of AreaScheme. ElementId areaSchemeId = collector1.FirstElementId(); //If you want to create an area schedule, you must use CreateSchedule method with three arguments. //The input of second argument must be ElementId of BuiltInCategory.OST_Areas category and the input of third argument must be ElementId of a areaScheme. ViewSchedule areaSchedule = Autodesk.Revit.DB.ViewSchedule.CreateSchedule(doc, new ElementId(BuiltInCategory.OST_Areas), areaSchemeId); |
A material takeoff is a schedule that displays information about the materials that make up elements in the model. Unlike regular schedules where each row (before grouping) represents a single element, each row in a material takeoff represents a single <element, material> pair. The ViewSchedule.CreateMaterialTakeoff() method has the same parameters as the ViewSchedule.CreateSchedule() method and allows for both single- and multi-category material takeoff schedules.
View lists, sheet lists, and keynote legends are associated with a designated category and therefore their creation methods do take a category ID as a parameter. A view list is a schedule of views in the project. It is a schedule of the Views category and is created using ViewSchedule.CreateViewList().
A sheet list is a schedule of sheets in the project. It is a schedule of the Sheets category and is created using the ViewSchedule.CreateSheetList() method.
A keynote legend is a schedule of the Keynote Tags category and is created using ViewSchedule.CreateKeynoteLegend().
Revision schedules are added to titleblock families and become visible as part of titleblocks on sheets. The ViewSchedule.CreateRevisionSchedule() method will throw an exception if the document passed in is not a titleblock family.
A note block is a schedule of the Generic Annotations category that shows elements of a single family rather than all elements in a category.
Code Region: ViewSchedule.CreateNoteBlock() |
public ViewSchedule ViewSchedule.CreateNoteBlock(Document document, ElementId familyId); |
The second parameter is the ID of the family whose elements will be included in the schedule.
Code Region: Creating a note block schedule |
//Get first ElementId of AnnotationSymbolType families. ElementId annotationSymbolTypeId = ElementId.InvalidElementId; if (!doc.AnnotationSymbolTypes.IsEmpty) { foreach (AnnotationSymbolType type in doc.AnnotationSymbolTypes) { annotationSymbolTypeId = type.Family.Id; break; } } //Create a noteblock view schedule. ViewSchedule noteBlockSchedule = ViewSchedule.CreateNoteBlock(doc, annotationSymbolTypeId); |