Which schedules are on a sheet and which are not?

Jason wonders if there is an easy way to find out which schedules are on a sheet and which are not?

Yes, there is. Find all schedules and then find which ones have a corresponding ScheduleSheetInstance

Capture

public void schedulesSheets()
{
    UIDocument uidoc = this.ActiveUIDocument;
    Document doc = uidoc.Document;   
    IList<string> onSheet = new List<string>();
    IList<string> notOnSheet = new List<string>();
    
    foreach (ViewSchedule vs in new FilteredElementCollector(doc)
             .OfClass(typeof(ViewSchedule))
             .Cast<ViewSchedule>()
             .Where(q => !q.IsTitleblockRevisionSchedule && !q.IsInternalKeynoteSchedule))
    {
        // ScheduleSheetInstance.ScheduleId is the Id of the "master" schedule that generates this ScheduleInstance
        if (new FilteredElementCollector(doc)
            .OfClass(typeof(ScheduleSheetInstance))
            .Cast<ScheduleSheetInstance>()
            .FirstOrDefault(q => q.ScheduleId == vs.Id) == null)
            notOnSheet.Add(vs.Name);
        else
            onSheet.Add(vs.Name);
    }
    
    string data = "--- Schedules On Sheets = " + onSheet.Count() + Environment.NewLine;
    foreach (string s in onSheet)
    {
        data += s + Environment.NewLine;
    }
    data += Environment.NewLine + "--- Schedules Not On Sheets = " + notOnSheet.Count() + Environment.NewLine;
    foreach (string s in notOnSheet)
    {
        data += s + Environment.NewLine;
    }
    TaskDialog.Show("output",data);
}
Advertisements

2 thoughts on “Which schedules are on a sheet and which are not?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s