Message 1 of 3
Retrieve all parameters that can be assigned to a multi-category Schedule programmatically

Not applicable
06-12-2021
04:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
//Code to retrieve all multi-Category-Schedules
FilteredElementCollector elementCollector = new FilteredElementCollector(Common.ProjectDocument);
List<ViewSchedule> multiCategorySchedules = elementCollector.OfClass(typeof(ViewSchedule))
.ToElements()
.Cast<ViewSchedule>()
.ToList()
.Where(x => x.Definition.CategoryId.IntegerValue == -1)
.ToList<ViewSchedule>();
//The loop is not needed in this case because the project only has
//one multi-category - schedule, but out of habit I left it
foreach ( ViewSchedule schedule in multiCategorySchedules)
{
//Retireve all the unique fields for one schedule
Dictionary<ElementId, string> availableParameters = new
Dictionary<ElementId, string>();
ScheduleDefinition def = schedule.Definition;
foreach(SchedulableField p in def.GetSchedulableFields())
{
if (!availableParameters.ContainsKey(parameterId))
{
availableParameters.Add(parameterId, name);
}
}
}
Hello,
Currently I am working on code that is supposed to retrieve all available parameters for a multi-category schedule. As shown the in the screenshot below ,I have four different fields available (Multiple Categories, Room, Space, Project Information) from which I can select parameters.
The code that I attached is able to retrieve all of them, however, it also retrieves about 200 more parameters that I am not able to assign to this schedule. I did check for unique element ids, however, it only eliminated a few extra parameters. Could somebody take a look at my code and help my understand if I am missing something or if the parameters that I don't seem to be able to find are hidden somewhere in Revit.
Thanks a lot in advance!