Message 1 of 5
Sort Scheduled Elements base on it's Sort/Group Fields to be export in Excel

Not applicable
11-12-2019
05:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
i'm trying to export the schedule elements to Excel with the same order as it is in Revit Schedule. I retrieved the sorting field of the schedule and try to apply it to elements list with no luck. For now my goal is just to apply one sort/group field and apply multiple sorting condition as i progress. Hope someone can help me.
here is the schedule
here is my code which not working
private IEnumerable<Element> ScheduledElement(Document doc,ViewSchedule view) { var sort = (from ScheduleSortGroupField i in view.Definition.GetSortGroupFields() select view.Definition.GetField(i.FieldId)).First(); IEnumerable<Element> elementsOnSchedule = new FilteredElementCollector(doc, view.Id) .WhereElementIsNotElementType() .OrderBy(c => c.LookupParameter(sort.GetName())); return elementsOnSchedule; }
Thanks in advance