Here is a quick sample on how read gross and rentable area elements on Revit, starting from the Area element, where the FilteredElementCollector uses a SpatialElement, and the AreaScheme and, if needed, the Level linked to it. Finally show the total gross and rentable area.
Note it starts with the Area element, so you need to define it on the project, otherwise it will not even show on the schedule, right?
Update: Ed Silky pointed that if the AreaPlan is not added to the project, then the Level will return as Invalid (-1). This is expected behavior on parameters that store ElementId but still empty. Thanks Ed!
FilteredElementCollector coll = new
FilteredElementCollector(doc);
coll.OfClass(typeof(SpatialElement));
double rentableArea = 0.0;
double grossArea = 0.0;
foreach (SpatialElement spartialElement in coll)
{
Area areaElement = spartialElement as Area;
if (areaElement == null) continue; // skip if not an area
// area and type
double areaValue = areaElement.Area;
AreaScheme areaScheme = areaElement.AreaScheme;
bool isGross = areaScheme.IsGrossBuildingArea;
// get the level, just in case...
Level level = doc.GetElement(
areaElement.get_Parameter(
BuiltInParameter.ROOM_LEVEL_ID).AsElementId())
as Level;
if (isGross)
grossArea += areaValue;
else
rentableArea += areaValue;
}
// show only total result
TaskDialog.Show("Total:",
string.Format("Gross: {0}\nRentable: {1}",
FormatUtils.Format(doc, UnitType.UT_Area, grossArea),
FormatUtils.Format(doc, UnitType.UT_Area, rentableArea)));