revit api find outside wall in csharp

To find outside walls in Revit using the API in C#, you can follow these steps:

  1. Get all the walls in the Revit document using FilteredElementCollector class and OfCategory method:
main.cs
FilteredElementCollector collector = new FilteredElementCollector(doc);
ICollection<Element> walls = collector.OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements();
194 chars
3 lines
  1. Iterate through all the walls and check their Function property. Walls with Function property set to Exterior are considered as outside walls:
main.cs
List<Element> outsideWalls = new List<Element>();

foreach (Element wall in walls)
{
    Parameter parameter = wall.get_Parameter(BuiltInParameter.FUNCTION_PARAM);

    if (parameter != null)
    {
        Type parameterType = parameter.GetType();

        if (parameterType == typeof(BuiltInParameter))
        {
            BuiltInParameter builtInParameter = (BuiltInParameter)Enum.Parse(typeof(BuiltInParameter), parameter.AsValueString(), true);

            if (builtInParameter == BuiltInParameter.FUNCTION_PARAM && parameter.AsValueString() == "Exterior")
            {
                outsideWalls.Add(wall);
            }
        }
    }
}
650 chars
22 lines
  1. The outsideWalls list will contain all the outside walls in the Revit document.

Note: This code assumes that the outside walls have their Function property set to Exterior. If there are other ways to identify outside walls, then the code needs to be modified accordingly.

gistlibby LogSnag