Some times we need retrieve all level elevatioins, here is the code:
string strMsg = “”;
Transaction trans = new Transaction(doc, “Show Level”);
trans.Start();
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> elems = collector.WhereElementIsNotElementType().OfClass(typeof(Level)).ToElements();
foreach (Level lv in elems)
{
strMsg += lv.Name + ” : elevation” + lv.Elevation.ToString(“F2″) + “\n”;
}
TaskDialog.Show(“Level elements”, strMsg);
trans.RollBack();
Just notice that, the Elevation got from the Level element is stored in feet unit, if you want to show other unit (like inches or meters), you need to transform it before use it.