Message 1 of 5

Not applicable
11-16-2014
12:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How would I go about getting a collection of levels sorted by elevation? From reading the info I've found so far I think that filtered element collector returns an Ienumerable and that can be sorted by using "OrderBy", then ToElementIds could be used to create the collection of element ids in the correct order. Is that correct? Below is some code I tried and didn't work. Can someone please point me in the right direction?
Also, is an Icollection sortable?
UIDocument uiDoc = this.ActiveUIDocument; Document doc = uiDoc.Document; FilteredElementCollector levCollector = new FilteredElementCollector(doc);
ICollection<Element> levelsCollection = levCollector.OfClass(typeof(Level)).OrderBy(lev => lev.Elevation).ToElementIds();
Solved! Go to Solution.