static List<PlanarFace> GetWallOpeningPlanarFaces(
Wall wall,
ElementId openingId)
{
List<PlanarFace> faceList = new List<PlanarFace>();
List<Solid> solidList = new List<Solid>();
Options geomOptions = wall.Document.Application.Create.NewGeometryOptions();
if( geomOptions != null )
{
//geomOptions.ComputeReferences = true; // expensive, avoid if not needed
//geomOptions.DetailLevel = ViewDetailLevel.Fine;
//geomOptions.IncludeNonVisibleObjects = false;
GeometryElement geoElem = wall.get_Geometry( geomOptions );
if( geoElem != null )
{
foreach( GeometryObject geomObj in geoElem )
{
if( geomObj is Solid )
{
solidList.Add( geomObj as Solid );
}
}
}
}
foreach( Solid solid in solidList )
{
foreach( Face face in solid.Faces )
{
if( face is PlanarFace )
{
if( wall.GetGeneratingElementIds( face )
.Any( x => x == openingId ) )
{
faceList.Add( face as PlanarFace );
}
}
}
}
return faceList;
}