I have retreive the levels as treeview(List of levels in treeview in WPF form) and then selected a wall(e.g xyz_wall) from a specific level(e.g. Level1) in Revit project, I want to retrieve the list openings(doors and windows) of selected wall and show to the message box (in message box-list of openings:).
Asked
Active
Viewed 404 times
1 Answers
0
Window and Doors are FamilyInstances, and an Opening cut through a wall is an Opening object.
private IList<Element> GetHostedElements(Wall wall)
{
Document doc = wall.Document;
ElementId id = wall.Id;
IList<Element> result = new List<Element>();
IEnumerable<Opening> openingInstances =
new FilteredElementCollector(doc)
.OfClass(typeof(Opening))
.WhereElementIsNotElementType()
.Cast<Opening>();
foreach (Opening openingInstance in openingInstances)
{
if (openingInstance.Host.Id.Equals(id))
{
result.Add(openingInstance);
}
}
IEnumerable<FamilyInstance> familyInstances =
new FilteredElementCollector(doc)
.OfClass(typeof(FamilyInstance))
.WhereElementIsNotElementType()
.Cast<FamilyInstance>();
foreach (FamilyInstance familyInstance in familyInstances)
{
if (familyInstance.Host.Id.Equals(id))
{
result.Add(familyInstance);
}
}
return result;
}

Nimantha
- 6,405
- 6
- 28
- 69

user3493725
- 42
- 8