Hi, I am into what I believe should be a trivial task, but I am having big troubles with it.
I've filtered all the walls model elements in my project:
Dictionary<ElementId, Element> idToInstance = collectorElements.WhereElementIsNotElementType()
.WherePasses(filterWall)
.Where(e => e.Category != null)
.Where(e => e.Category.HasMaterialQuantities)
.ToDictionary(e => e.Id);
And now, I want to compute their surface area. The problem is that Walls only seem to have a Width property, not height nor area directly.
Maybe there's something I'm missing, but shouldn't there be an easy way to achieve this?
Thanks in advance and sorry if this question feels too easy. I've navegated and have found some similar topics, but couldn't be able to get it on point.
Thank you,
Jose Antonio Lorencio Abril
Solved! Go to Solution.
Solved by RPTHOMAS108. Go to Solution.
I thought walls have an area property?
Please check what properties and parameters are available in your model, e.g., using RevitLookup and other tools:
Furthermore, The Building Coder has published a large number of wall area calculation samples for all kinds of different specific requirements:
https://www.google.com/search?q=wall+area&as_sitesearch=thebuildingcoder.typepad.com
I also think they do, but for some reason I am not able to retrieve it. I've achieved what I want by getting the MaterialArea. Probably not the most elegant solution, but it works.
Thank you, Jeremy.
That sounds like a perfectly valid and effective solution to me. Congratulations. Would you like to share a code snippet showing others exactly how you do it? Thank you!
1) The face geometry of the element will have the surface area (Face.Area).
2) There is also Element.GetMaterialArea but you will need to know the material of the finish and decide if you want to include painted materials in that consideration.
Option (1) may be the best because it allows you to distinguish the area of each face. Option (2) is also a bit vague in terms of compound layers but since it is inherited from Element I assume it only considers the outer surfaces.
Of course, the code is the following:
//Now we find all the instances of walls in the project
ElementFilter filterWall = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
FilteredElementCollector collectorWalls = new FilteredElementCollector(doc);
//We use this filter to get all model elements instanced as walls
Dictionary<ElementId, Element> idToWallInstance = collectorWalls.WhereElementIsNotElementType()
.WherePasses(filterWall)
.Where(e => e.Category != null)
.Where(e => e.Category.HasMaterialQuantities)
.ToDictionary(e => e.Id);
ICollection<ElementId> materiales = w.GetMaterialIds(false);
double A = UnitUtils.ConvertFromInternalUnits(w.GetMaterialArea(materiales.First(), false), UnitTypeId.SquareMeters);
//Needed as some types of wall have double cover of some materials, so we need to get the area of the least used material
foreach(ElementId id in materiales)
{
double temp = UnitUtils.ConvertFromInternalUnits(w.GetMaterialArea(id, false), UnitTypeId.SquareMeters);
if (temp < A)
A = temp;
}
Notice that this would not work if we had a wall with every material used on it appearing twice. This does not happen in my case, and I don't know if such a thing is ever used.
Thanks for all your fast replies, Jeremy, this community is helping me a lot!
I did not know about the faces, I'll look at that. Thank you very much!!
Can't find what you're looking for? Ask the community or share your knowledge.