我已经将级别检索为树视图(WPF 形式的树视图中的级别列表),然后从 Revit 项目中的特定级别(例如 Level1)中选择了一堵墙(例如 xyz_wall),我想检索列表开口(门和窗)选定的墙并显示到消息框(在消息框-开口列表中:)。
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;
}
If this answers your question, please accept the answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.