Reading Gross and Rentable area elements

By Augusto Goncalves

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!

schedule

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 resultTaskDialog.Show("Total:",  string.Format("Gross: {0}nRentable: {1}",  FormatUtils.Format(doc, UnitType.UT_Area, grossArea),  FormatUtils.Format(doc, UnitType.UT_Area, rentableArea)));

Comments

One response to “Reading Gross and Rentable area elements”

  1. I’d like to thank the author for writing such an insightful and informative blog post about reading gross and rentable that is not just useful to the readers but also revealing.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading