Computing wall area?

Computing wall area?

Anonymous
Not applicable
800 Views
6 Replies
Message 1 of 7

Computing wall area?

Anonymous
Not applicable

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

0 Likes
Accepted solutions (1)
801 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

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:

 

https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-onto...

 

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

  

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 7

Anonymous
Not applicable

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.

0 Likes
Message 4 of 7

jeremy_tammik
Alumni
Alumni

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!

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 7

RPTHOMAS108
Mentor
Mentor
Accepted solution

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.

Message 6 of 7

Anonymous
Not applicable

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!

0 Likes
Message 7 of 7

Anonymous
Not applicable

I did not know about the faces, I'll look at that. Thank you very much!!

0 Likes